gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 23:15:55 26 4
gpt4 key购买 nike

我使用 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/已解决
正如我之前尝试过的,解决方案是在 pycharm 上将 LD_LIBRARY_PATH 添加到配置面板上的环境变量中。我认为之前它对名称后面的空格不起作用(-> 'LD_LIBRARY_PATH ')。这里的解决方案:
solution

最佳答案

解决方法是在Pycharm环境面板中添加正确的路径:

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

或适合您的配置。

关于python - PyCharm 远程解释器和 Tensorflow -> 无法导入 Cudart.so,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42398672/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com