2017-02-22 53 views
-1

我使用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

回答

2

你得到的錯誤信息是「請退出tensorflow源碼樹,並從那裏重新啓動你的python解釋器。」。

通常情況下,如果您下載張量流源,手動編譯等,請安裝它,然後啓動python並導入tensorflow,同時仍在源文件夾中。

東西,你可以嘗試停止此錯誤: - 檢查tensorflow源是你在運行遠程應用程序的文件夾中(你遵循這樣的事情來得到它的工作http://www.pinchofintelligence.com/faster-writing-and-testing-machine-learning-applications/?) - 嘗試找到並刪除tensorflow源文件夾 - 重新啓動您的電腦(這將清除/ tmp文件夾,你可能正在運行你的東西)

希望這些工作之一,讓我知道!

+0

我試過你的建議,請參閱更新1.我安裝了從PIP(sudo pip install tensorflow-gpu)的tensorflow,我確保更新protobuf並刪除任何以前安裝的TF版本(包括cpu和gpu)。我沒有目錄中的源代碼。任何其他想法?我想強調的是,如果我在服務器端執行SSH,那麼python和'import tensorflow'完美地工作,而啓動形式PyCharm不會。 PyCharm的配置方式或者稱爲tensorflow的方式肯定有問題嗎? – Alvise

+0

同樣的問題,但我沒有TF來源,所以問題就像在** UPDATE 1 **中。這可能有相當直接的錯誤信息,但我不斷忘記將Env變量添加到PyCharm項目設置中。 – devforfu

1

解決辦法是正確的路徑添加到Pycharm環境面板:

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

,或者配置相匹配的一個。

相關問題