我爱编程

ubuntu下cudnn和tensorflow安装

2018-04-13  本文已影响0人  大脸猫猫脸大

1 cudnn安装

按照官网教程进行安装:https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#download

1.1  下载

https://developer.nvidia.com/cudnn上下载cudnn相应版本的压缩包,若非tgz版本,修改后缀名为tgz

1.2 解压缩

$ tar -xzvf cudnn-9.0-linux-x64-v7.tgz

1.3 复制和修改权限

$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include 

$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 

$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

1.4 查看cudnn版本:

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A2

2 tensorflow安装

2.1 安装native pip, python2.7,GPU support ,tensorflow

$ sudo apt-get install python-pip python-dev         **安装pip**

$ pip install tensorflow-gpu                **安装tensorflow**

#若成功,则进入验证阶段,否则执行第三行指令

$ sudo pip install --upgrade \

https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp27-none-linux_x86_64.whl

2.2 验证

进入python,执行如下指令

# Python

import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')

sess = tf.Session()

print(sess.run(hello))

屏幕显示 Hello, TensorFlow!,代表tensorflow安装成功

参考https://www.tensorflow.org/install/install_linux

上一篇下一篇

猜你喜欢

热点阅读