安装tensorflowGPU版本

Posted 吹口哨的小蚂蚁

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装tensorflowGPU版本相关的知识,希望对你有一定的参考价值。



ubuntu 16.0
# 安装cuda

## 安装
sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub #执行第一个命令后会有提示
sudo apt-get update
sudo apt-get install cuda

## 设置

sudo gedit ~/.bashrc

在末尾添加  

export CUDA_HOME=/usr/local/cuda-9.0
#export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export PATH=/usr/local/cuda-9.0/bin:$PATH

保存退出。


然后刷新。

source ~/.bashrc

## 重启电脑并测试

执行命令
cat /proc/driver/nvidia/version
nvcc -V

1. The NVIDIA CUDA Toolkit includes sample programs in source form. You should compile them by changing to ~/NVIDIA_CUDA-9.1_Samples and typing make. The resulting binaries will be placed under ~/NVIDIA_CUDA-9.1_Samples/bin.

2. After compilation, find and run `deviceQuery` under` ~/NVIDIA_CUDA-9.1_Samples`. If the CUDA software is installed and configured correctly, the output for deviceQuery should look similar to that shown in Figure 1.

3. Running the `bandwidthTest` program ensures that the system and the CUDA-capable device are able to communicate correctly. Its output is shown in Figure 2.


Read more at: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#ixzz58f8bhHpY
Follow us: @GPUComputing on Twitter | NVIDIA on Facebook

# 安装cudnn

## 安装
下载相应的源码文件并解压
cudnn-9.0-linux-x64-v7.tgz
执行命令:

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  
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

## 验证
参照文档

# 安装tensorflowGPU版本
使用conda创建python3.5环境
conda create -n tfGPU python=3.5
source activate tfGPU

pip install --ignore-installed --upgrade tensorflow_gpu-1.6.0-cp35-cp35m-linux_x86_64.whl
直接参照tensorflow官网


以上是关于安装tensorflowGPU版本的主要内容,如果未能解决你的问题,请参考以下文章

tensorflow只能在装有gpu的机器上运行

CUDA版本与GPU驱动版本问题

为啥 conda 无法在 Windows 上正确安装 tensorflow gpu?

import tensorflow 后没有利用cuda怎么办

tensorflow怎么gpu加速

如何使用 TensorFlow GPU?