PyCharm远程解释器和Tensorflow - >无法导入Cudart.so
我使用PyCharm进行远程调试,客户端Win10,服务器Ubuntu 16.在Ubuntu机器上,我已经正确安装了Cuda 8.0,以及python 2.7和tensorflow 1.0 0.0。 Tensorflow完美地从服务器(ssh +调用python,导入tensorflow等)。PyCharm远程解释器和Tensorflow - >无法导入Cudart.so
在PyCharm我建立了一个远程调试到我的服务器上,但现在进口tensorflow导致错误:
Traceback (most recent call last):
File "/home/*****/*****/********/*******.py", line 24, in <module>
import tensorflow as tf
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 60, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
我想:
添加正确的路径移到sys.path变量
加入LD_LIBRARY_PATH到os.environ和/或PyCharm环境变量
没有成功!
我记得以前我能够在没有任何问题的情况下进行调试,但我无法弄清楚什么是错的。任何建议?
UPDATE 1 重新启动后,错误改变为这
ssh://****@192.168.***.***:22/usr/bin/python -u /home/*****/.pycharm_helpers/pydev/pydevd.py --multiproc --qt-support --client '0.0.0.0' --port 35523 --file /home/*/*/*/*/test.py
warning: Debugger speedups using cython not found. Run '"/usr/bin/python" "/home/*/.pycharm_helpers/pydev/setup_cython.py" build_ext --inplace' to build.
pydev debugger: process 1913 is connecting
Connected to pydev debugger (build 163.10154.50)
Traceback (most recent call last):
File "/home/*/.pycharm_helpers/pydev/pydevd.py", line 1596, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/*/.pycharm_helpers/pydev/pydevd.py", line 974, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/*/*/*/*/test.py", line 1, in <module>
import tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
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
UPDATE 2 /解决 正如我以前尝试过,该解决方案是在pycharm的LD_LIBRARY_PATH添加到环境变量上配置面板。我认为之前它没有工作的名称后面的空格( - >'LD_LIBRARY_PATH')。这里的解决方案: solution
你得到的错误信息是“请退出tensorflow源码树,并从那里重新启动你的python解释器。”。
通常情况下,如果您下载张量流源,手动编译等,请安装它,然后启动python并导入tensorflow,同时仍在源文件夹中。
东西,你可以尝试停止此错误: - 检查tensorflow源是你在运行远程应用程序的文件夹中(你遵循这样的事情来得到它的工作http://www.pinchofintelligence.com/faster-writing-and-testing-machine-learning-applications/?) - 尝试找到并删除tensorflow源文件夹 - 重新启动您的电脑(这将清除/ tmp文件夹,你可能正在运行你的东西)
希望这些工作之一,让我知道!
解决办法是正确的路径添加到Pycharm环境面板:
LD_LIBRARY_PATH='/usr/local/cuda/lib64'
,或者配置相匹配的一个。
我试过你的建议,请参阅更新1.我安装了从PIP(sudo pip install tensorflow-gpu)的tensorflow,我确保更新protobuf并删除任何以前安装的TF版本(包括cpu和gpu)。我没有目录中的源代码。任何其他想法?我想强调的是,如果我在服务器端执行SSH,那么python和'import tensorflow'完美地工作,而启动形式PyCharm不会。 PyCharm的配置方式或者称为tensorflow的方式肯定有问题吗? – Alvise
同样的问题,但我没有TF来源,所以问题就像在** UPDATE 1 **中。这可能有相当直接的错误信息,但我不断忘记将Env变量添加到PyCharm项目设置中。 – devforfu