ubuntu 14.04搭建tensorflow-gpu开发环境

一、安装nvidia显卡驱动

去navidia官网查看最新的驱动版本号:navidia官网:http://www.geforce.cn/drivers

找到显卡对应的驱动下载,例如下载的驱动为 NVIDIA-Linux-x86_64-375.82.run

ubuntu桌面环境下,按ctrl + alt +F1进入text mode  登录账户,输入下面命令,一路ok

sudo service lightdm stop
sudo ./NVIDIA-Linux-x86_64-375.82.run
sudo service lightdm start

 会重新进入图形桌面

点击左边的设置,点击详细信息,在图形标签栏是否有NVIDIA的标识,如有,则表示驱动安装成功  

二、安装cuda-8.0

官方网站下载:CUDA Toolkit 8.0。下载网址为:https://developer.nvidia.com/cuda-80-ga2-download-archive

下载完后,执行下命令:

sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

  

sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-cublas-performance-update_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

这时在/usr/local目录下产生一个cuda安装的路径叫"cuda-8.0"添加cuda到环境变量:

sudo vi /etc/profile  

在profile的最后添加:

export CUDA_HOME=/usr/local/cuda-8.0  
export PATH=$CUDA_HOME/bin:$PATH    
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH 

使环境变量即时生效 

source /etc/profile

验证cuda是否安装成功,输入以下命令

nvcc --version

显示如下表示cuda安装成功

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

  

尝试编译cuda提供的例子,下载cuda测试用例

sudo cuda-install-samples-8.0.sh ~/cuda_examples 

  

cd ~/cuda_examples/NVIDIA_CUDA-8.0_Samples
sudo make -j7
cd ~/NVIDIA_CUDA-7.5_Samples/bin/x86_64/linux/release
./deviceQuery

看到类似如下图片中的显示,则代表CUDA安装且配置成功  

  

 

三、安装cudnn6.0

到官网下载:cudnn-7.0-linux-x64-v3.0.8-prod.tgz,网址为: https://developer.nvidia.com/cudnn

 

sudo tar xvzf cudnn-8.0-linux-x64-v6.0.tgz  
sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include  
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64  
sudo chmod a+r /usr/local/cuda-8.0/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*   #分配包的权限 

 四、安装tensorflow-gpu

sudo pip install tensorflow-gpu

 

五、安装pycharm用于python开发

1、安装pycharm

 wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -

 sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu trusty-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'

 sudo apt-get update

 sudo apt-get install pycharm

 2、安装pycharm的jdk环境

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java8-installer

 

六、参考链接

http://blog.csdn.net/u012969412/article/details/64502393

http://blog.csdn.net/masa_fish/article/details/51882183

http://blog.csdn.net/qingche456/article/details/65446661

 

posted on 2017-12-23 09:59  Hugh_Sun  阅读(1752)  评论(0编辑  收藏  举报

导航