我想在 Linux Mint 上的 Pycharm 中运行 Tensorflow GPU。
我尝试了一些像这样的指南
我运行这段代码
import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
我有这个错误
Traceback (most recent call last):
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alex/PycharmProjects/TfTestGPU/test.py", line 1, in <module>
import tensorflow as tf
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Process finished with exit code 1
原文由 Alex G 发布,翻译遵循 CC BY-SA 4.0 许可协议
首先确保已成功安装 CUDA 和 CuDNN,并验证配置。
CUDA 驱动程序版本应该足以满足 CUDA 运行时版本。
完成后,打开 PyCharm
选择安装了 tensorflow-gpu 的适当环境
由于代码正在搜索 libcublas.so.10.0 ,
假设您发现“ libcublas.so.10.0 ”的路径类似于 “/home/Alex/anaconda3/pkgs/cudatoolkit-10.0.130-0/lib/”
在环境变量中将 lib 路径添加为 LD_LIBRARY_PATH 作为
保存然后尝试 导入tensorflow