2017-04-22 140 views
35

我有在python3進口tensorflow問題:Tensorflow:導入錯誤:libcusolver.so.8.0:無法打開共享對象文件:沒有這樣的文件或目錄

>>> import tensorflow as tf 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module> 
    from tensorflow.python.pywrap_tensorflow_internal import * 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> 
    _pywrap_tensorflow_internal = swig_import_helper() 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper 
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 
    File "/usr/lib/python3.5/imp.py", line 242, in load_module 
    return load_dynamic(name, filename, file) 
    File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic 
    return _load(spec) 
ImportError: libcusolver.so.8.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 "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module> 
    from tensorflow.python import * 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 51, in <module> 
    from tensorflow.python import pywrap_tensorflow 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module> 
    raise ImportError(msg) 
ImportError: Traceback (most recent call last): 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module> 
    from tensorflow.python.pywrap_tensorflow_internal import * 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> 
    _pywrap_tensorflow_internal = swig_import_helper() 
    File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper 
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 
    File "/usr/lib/python3.5/imp.py", line 242, in load_module 
    return load_dynamic(name, filename, file) 
    File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic 
    return _load(spec) 
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory 


Failed to load the native TensorFlow runtime. 

See https://www.tensorflow.org/install/install_sources#common_installation_problems 

for some common reasons and solutions. Include the entire stack trace 
above this error message when asking for help. 

我使用的Nvidia驅動程序版本381.09 Beta版作爲版本375有這個錯誤:https://askubuntu.com/questions/896221/strange-artifacts-along-window-borders-after-waking-computer-from-sleep-mode?noredirect=1&lq=1

我有安裝CUDA 8.0和cuDNN-V6.0:

[email protected]:~$ cd /usr/local 
[email protected]:/usr/local$ ls 
bin   cuda  etc include man share 
computecpp cuda-8.0 games lib  sbin src 

此外,libcusolver.so.8.0在/ usr /本地/ CUDA/lib64的存在/ :

libcusolver.so.8.0 in 'ls' output

我已經卸載並重新安裝CUDA,cuDNN,並從源代碼構建的tensorflow。自從將Nvidia驅動程序更新至版本381.09測試版以來,這個問題一直存在。任何幫助?

+0

如果你現在有** CUDA 9.0 **,那麼使用'tf-nightly-gpu',直到它穩定。 – OverCoder

+0

@OverCoder我目前正在使用從CUDA 9.0的源代碼構建的1.4.0-rc0,現在我一直沒有問題。我是否仍然應該切換到'tf-nightly-gpu'? –

+0

我錯了,我誤讀了[this](https://github.com/tensorflow/tensorflow/issues/12052#issuecomment-335262465),你需要從源代碼開始構建。 – OverCoder

回答

34

找到了解決方案:

我重新安裝NVIDIA-381,CUDA-8.0(使用RUNFILE)和cuDNN 6.0。然後,我在.bashrc中添加了以下內容:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64/ 
+0

這似乎沒有解決我的問題...我的cuda安裝到'/ opt/cuda /',libcs​​usolver.so也駐留在那裏。我在我的.bashrc中添加了以下內容: 'export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/ opt/cuda/lib64/ ' 仍然出現同樣的錯誤。我的同事們運行tensorflow就好了... –

+0

@FranzHahn奇怪,目前我的安裝位於'/ opt/cuda','export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/ opt/cuda/lib64 /'適用於我。您是否手動檢查了'/ opt/cuda/lib64',看看所請求的確切文件是否存在? –

+0

我有同樣的問題,我安裝在virtualenv使用,但是,當我嘗試在virutalenv中導入時出現此錯誤,但是,奇怪的是它在該virtualenv以外工作正常。任何線索? – Mobeen

6

無需重新安裝。安裝nvidia-cuda-dev

sudo apt install nvidia-cuda-dev 

安裝cuDNN(你從https://developer.nvidia.com/cudnn下載),並設置相應LD_LIBRARY_PATH(以cuda/lib64)。

+0

在我的情況下,我不得不重新安裝,因爲我的安裝也有問題。否則,對於其他人遇到的情況,我想他們不需要重新安裝,除非他們也有安裝損壞。 –

+1

這對我有用!謝謝! – Ivelin

+0

適用於Ubuntu 17 Cuda - 9和Nvidia-384驅動程序的唯一解決方案。 – markroxor

4

如果您安裝了最新版本的CUDA(9.0),則可能出現此問題。如果是這樣,你的計算機上會有libcusolver.so.9.0文件或目錄,但不是8.0,所以python找不到它來導入。 Tensorflow尚不支持CUDA 9.0(截至2017年10月18日)。

要解決這個問題,請安裝CUDA 8.0,它可以找到here。您可以在主下載頁面的底部找到他們所有的legacy releases

+0

實際上,我很久以前就遇到了這個問題,原因是CUDA安裝不成功,而且沒有在LD_LIBRARY_PATH中設置CUDA庫路徑。目前,我正在運行使用CUDA 9.0和cuDNN 7.0從源代碼構建的Tensorflow,並且我沒有任何問題。 –

+0

我想我有這個問題你在談論。我在virtualenv中安裝了tensorflow,但事情是當我嘗試在該virtualenv中導入時出現此錯誤。我不明白爲什麼我能夠在本機python3中導入tensorflow。 – Mobeen

相關問題