编程语言
首页 > 编程语言> > python – PyCharm远程解释器和Tensorflow – >无法导入Cudart.so

python – PyCharm远程解释器和Tensorflow – >无法导入Cudart.so

作者:互联网

我正在使用PyCharm进行远程调试,客户端Win10,服务器Ubuntu 16.在Ubuntu机器上我正确安装了Cuda 8.0,以及python 2.7和tensorflow 1.0.0. Tensorflow完美地从服务器上运行(ssh调用python,导入tensorflow等…).

在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环境变量

没有成功!

我记得很久以前我能够毫无问题地进行调试,但我无法弄清楚出了什么问题.有什么建议吗?

更新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

更新2 /已解决
正如我之前尝试过的,解决方案是在配置面板上将LD_LIBRARY_PATH添加到pycharm上的环境变量.我认为之前它不适用于名称后的空格( – >’LD_LIBRARY_PATH’).这里的解决方案:
solution

解决方法:

解决方案是将正确的路径添加到Pycharm环境面板:

LD_LIBRARY_PATH='/usr/local/cuda/lib64'

或者适合您配置的那个.

标签:python,tensorflow,pycharm,remote-debugging
来源: https://codeday.me/bug/20190823/1701247.html