我阅读了this,this和this。这些不是我的情况。我也尝试使用this解决我的问题。
问题描述
我安装了cuda 10.0,pip 19.0.2,python 3.6.7,ipython 7.2.0,tensorflow-gpu 1.13.0-rc1,PyCharm CE 2018.3.4。所有python模块都安装在虚拟环境中。
我选择venv解释器作为PyCharm中的Project Interpreter和Python Console Interpreter。
当我尝试导入tensorflow
import tensorflow as tf
我已经成功使用终端ipython并没有使用PyCharm。
/home/roman/dev/venv/bin/python /home/roman/dev/box.neuro/test.py
Traceback (most recent call last):
File "/home/roman/dev/venv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/roman/dev/venv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/roman/dev/venv/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/roman/dev/venv/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/home/roman/dev/venv/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/roman/dev/box.neuro/test.py", line 1, in <module>
import tensorflow as tf
File "/home/roman/dev/venv/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/roman/dev/venv/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/roman/dev/venv/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/roman/dev/venv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/roman/dev/venv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/roman/dev/venv/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/roman/dev/venv/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/home/roman/dev/venv/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
其他信息
我验证了我是否通过以下方式使用了相同的ipython。我检查了import requests
,发现它没有导入到终端机和PyCharm中,而是将其安装在终端机中,并验证了我现在可以同时将其导入。
我检查了以下内容:
import os
print(os.environ['PATH'])
终端和PyCharm的差异。然后,我在设置->构建,执行,部署->控制台-> Python控制台中添加了环境变量PATH
。现在输出是一样的,但是我仍然无法在PyCharm中导入张量流。
我检查了以下内容:
import os
print(os.environ['LD_LIBRARY_PATH'])
终端和PyCharm的差异。 PyCharm IPython输出为空,终端IPython输出如下:
'/usr/local/cuda-10.0/lib64'
答案 0 :(得分:1)
我自己找到了解决方法。我在设置->构建,执行,部署->控制台-> Python控制台中添加了环境变量“ LD_LIBRARY_PATH”。为了使用运行/调试配置,我为它们添加了相同的环境变量。它不是用户友好的,因为我应该一次又一次地对每种配置进行操作。
以前,我一直在不同的计算机上安装PyCharm,它可以与TF一起正常工作,或者说cuda库更好。
我还在PyCharm追踪器上找到了issue。因此,如果您对修复感兴趣,请随时为其投票。