关于python:使用cuda 10安装pip tensorflow-gpu后出错

Error after installing pip tensorflow-gpu with cuda 10

我想在conda版本中只使用tensorflow的pip版本,如果tensorflow-gpu获取错误代码在cpu上运行,这是不可取的。

在我导入tensorflow后为ubuntu 18.0.4安装cuda 10和cudnn后,它给了我以下错误。

PS:我清除了与cuda和Nvidia有关的一切,然后安装了新的Cuda 10。

Python 3.6.7 |Anaconda custom (64-bit)| (default, Oct 23 2018, 19:16:44)
[GCC 7.3.0] on linux
Type"help","copyright","credits" or"license" for more information.

>>> import tensorflow

Traceback (most recent call last):
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File"/home/purav/anaconda3/envs/purav/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File"/home/purav/anaconda3/envs/purav/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
File"", line 1, in
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/init.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File"/home/purav/anaconda3/envs/purav/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File"/home/purav/anaconda3/envs/purav/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File"/home/purav/anaconda3/envs/purav/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

我不知道为什么这个错误在那里我没有cuda verison 9


通过pip提供的当前稳定版本的tensorflow-gpu是v1.12,它是针对CUDA 9.0构建的。如果你看一下tensorflow github存储库的第22706号问题,那么即将推出的tensorflow-gpu v1.13的官方二进制文件预计将针对CUDA 10构建。

截至2019年1月23日,已发布了针对CUDA 10构建的tensorflow-gpu v1.13的rc0版本。可以使用pip安装,方法如下:

pip install tensorflow-gpu==1.13.0rc0

由于CUDA 9已在系统中替换为CUDA 10,因此默认的tensorflow-gpu代码失败,因为它是版本1.12并且期望系统中存在CUDA 9二进制文件。所以目前,如果你想在CUDA 10中使用tensorflow,那么最快的解决方案是升级你的tensorflow版本,如上所述。


问题是您还没有完全满足TensorFlow GPU的要求。
完整列表在TF网站上。

您的错误的主要原因似乎是您没有使用cuDNN SDK配置好CUDA工具包9.0请注意您需要大于或等于7.2的版本并将其添加到您的系统路径。


我正在运行python 3.7并且能够通过运行来安装与cuda 10的tensorflow:

1
 pip install --no-cache-dir https://github.com/evdcush/TensorFlow-wheels/releases/download/tf-1.12.0-py37-gpu-10.0/tensorflow-1.12.0-cp37-cp37m-linux_x86_64.whl