更新时间:2021-12-13 07:55:49
我遇到了与消息相同的问题
I was having the same issue with the message
加载共享库时出错:libtensorflow.so.1:无法打开共享库文件:没有这样的文件或目录
error while loading shared libraries: libtensorflow.so.1: cannot open shared object file: No such file or directory
在我的情况下,它正在尝试将TensorFlow与go配合使用.问题是libtensorflow.so(和libtensorflow_framework.so)的官方安装没有如果将该软件包放在/usr/local(推荐)或其他路径中,则似乎可以正常工作.按照针对/usr/local的建议使用ldconfig也无济于事. 另外,在设置LD_LIBRARY_PATH之前,gcc的基本示例不起作用(即使使用-L也是如此).
In my case, it was trying to use TensorFlow with go. The problem is that the official installation for libtensorflow.so (and libtensorflow_framework.so) doesn't seem to be working if the package is left in /usr/local (recommended) or in other path. Using ldconfig as suggested for /usr/local doesn't help either. Also, the base example for gcc doesn't work (even with the -L. This has surprised me) until the LD_LIBRARY_PATH is set:
$ gcc -I/usr/local/include -L/usr/local/lib hello_tf.c -ltensorflow -o hello_tf
$ ./hello_tf
./hello_tf: error while loading shared libraries: libtensorflow.so.1: cannot open shared object file: No such file or directory
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
$ ./hello_tf
Hello from TensorFlow C library version 1.14.0
$ unset LD_LIBRARY_PATH
$ ./hello_tf
./hello_tf: error while loading shared libraries: libtensorflow.so.1: cannot open shared object file: No such file or directory
在我的情况下,这是/usr/local的内容
This is the content of /usr/local in my case
$ ll /usr/local/lib
total 245424
lrwxrwxrwx. 1 root root 28 dic 31 1999 libtensorflow_framework.so -> libtensorflow_framework.so.1
lrwxrwxrwx. 1 root root 33 dic 31 1999 libtensorflow_framework.so.1 -> libtensorflow_framework.so.1.14.0
-r-xr-xr-x. 1 root root 34748520 dic 31 1999 libtensorflow_framework.so.1.14.0
lrwxrwxrwx. 1 root root 18 dic 31 1999 libtensorflow.so -> libtensorflow.so.1
lrwxrwxrwx. 1 root root 23 dic 31 1999 libtensorflow.so.1 -> libtensorflow.so.1.14.0
-r-xr-xr-x. 1 root root 216546752 dic 31 1999 libtensorflow.so.1.14.0
另一种解决方案是手动创建到/usr/lib的符号链接. 我不知道如何在无服务器配置中执行此操作. 打算在评论中写这个,但是仍然没有足够的代表.
The other solution was to manually create the symlinks to /usr/lib. I don't know how to do that in a serverless config. Was going to write this in a comment but still dont have enough rep.