时间:2020-12-17 02:59:48 | 栏目:Python代码 | 点击:次
安装TensorFlow后,在Python中输入 import tensorflow as tf 时 提示一下类似错误
ImportError: libcusolver.so.*.0: cannot open shared object file: No such file or directory
libcusolver.so..0 ( 代表某一版本)
解决办法:
1. 输入下面命令,查找libcusolver.so 相关文件的目录
locate libcusolver.so.9
2. 输入下面命令 , 将缺失文件的目录添加到环境变量中。
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64"
输入python , import tf 如果依然缺失文件,重复 1. 2.
然后
locate libcudnn.so.7
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cudnn/cudnn-v7.0.5-for-cuda8.0/lib64" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cudnn/cudnn-v5.1/lib64"
最终,成功import tensorflow
如果需要长期保持环境变量有效,要在 .bashrc文件中添加环境变量,如下
# added by Anaconda3 installer export PATH="/home/yourname/anaconda3/bin:$PATH" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cudnn/cudnn-v5.1/lib64"
保存后激活 bashrc文件
source ~/.bashrc