将Tensorflow升级到1.3.0和cuDNN

时间:2017-09-02 06:02:20

标签: tensorflow ubuntu-16.04 cudnn

我用

升级了我的TensorFlow 1.0.1
$ pip install --upgrade tensorflow-gpu

在Ubuntu 16.04,cuDNN 5.1.5和CUDA 8.0

但是,当我在python模块中导入tensorflow时会出现错误消息,如下所示:

>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>_pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory

Failed to load the native TensorFlow runtime.

我认为这是cuDNN版本兼容性的问题。 任何人都知道如何升级cuDNN并使其与tensorflow 1.3.0兼容

2 个答案:

答案 0 :(得分:0)

TensorFlow 1.3需要cuDNN版本6.按照this link上的平台安装说明进行操作。成功安装cuDNN 6后,您的TensorFlow 1.3安装应该开始工作。

答案 1 :(得分:0)

我编写了一个脚本,可用于通过全新安装升级cuDNN版本。您可以从以下网址下载脚本:

https://github.com/dnzzcn/cuDNNv

这是脚本的作用:

#!/bin/bash

rm -f /usr/include/cudnn.h
rm -f /usr/lib/x86_64-linux-gnu/*libcudnn*
rm -f /usr/local/cuda-*/lib64/*libcudnn*


cp -P packages/cudnn/include/cudnn.h /usr/include
cp -P packages/cudnn/lib64/libcudnn* /usr/lib/x86_64-linux-gnu/
chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn*

rm -rf packages/cudnn

它会自动为您需要的版本执行安装操作。

如果你有TensorFlow 1.3.0,这需要cuDNN v6.0,使用脚本安装cuDNN v6.0就足够了。