Install CUDA-9.0, cuDNN-7.0.5, TensorFlow-1.5 on ubuntu16.04(64bit)

1. Install the CUDA-9.0

1. install NVIDIA driver

# sudo apt-get update

# sudo apt-get upgrade

# sudo add-apt-repository ppa:graphics-drivers/ppa

# sudo apt-get update

# sudo apt-get install nvidia-390

# sudo apt-get install mesa-common-dev

# sudo apt-get install freeglut3-dev

# reboot

2. Install CUDA-9.0

_ Dont’t install the driver inside CUDA_

# sudo sh cuda_9.0.176_384.81_linux.run

# sudo sh cuda_9.0.176.1_linux.run

Edit the environment variable

# sudo vim ~/.bashrc


export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}

export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

export CUDA_HOME=/usr/local/cuda

# reboot

test the CUDA

# cd

# cd NVIDIA_CUDA-9.0_Samples

# nvidia-smi

2. Install cuDNN-7.0.5

1. install cuDNN

# tar -zxvf 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/ -d

# sudo chmod a+r /usr/local/cuda/include/cudnn.h

# sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

# sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb

# sudo dpkg -i libcudnn7-dev_7.0.3.11-1+cuda9.0_amd64.deb

# sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.deb

2. Test the result

# cp -r /usr/src/cudnn_samples_v7/ $HOME

# cd $HOME/cudnn_samples_v7/mnistCUDNN

# make clean && make

# ./mnistCUDNN

check the result, if it showed

# Test passed!

3. Install TensorFlow-1.5

1. Install the library

# sudo apt-get install libcupti-dev

2. check python version

# python -V

# sudo vim ~/.bashrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

# reboot

3. Installing with Virtualenv

Because I am running the python 2.7.12. So I chooose to intall the Virtualenv with python 2

# sudo apt-get install python-pip python-dev python-virtualenv

# cd

# sudo apt-get install python-pip python-dev python-virtualenv

# cd ~/TensorFlow_1.5/bin

# source activate

(TensorFlow_1.5) test@test-ThinkPad-W530:~/TensorFlow_1.5/bin$ pip install --upgrade tensorflow-gpu

4. Validate the installation

# cd ~/TensorFlow_1.5/bin

# source activate

(TensorFlow_1.5) test@test-ThinkPad-W530:~/TensorFlow_1.5/bin$ python


import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))

if the terminal show

Hello, TensorFlow!

OK!!! Finish!!!

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.