Environment
python3.5+tensorflow-gpu1.5 + cuda9.0 + cudnn9.0
installation steps
Disable open source nouveau driver
sudo vim /etc/modprobe.d/disable-nouveau.conf
Add the following two lines at the end.
blacklist nouveauoptions
nouveau modeset=0
Then execute the following command to make the configuration take effect.
sudo ldconfig
sudo update-initramfs -u
Verify successful disabling of nouveau.
sudo lspci | grep nouveauinstall
Disable success if there is no output.
Install the Linux4.4.0 kernel
sudo apt-get install linux-headers-4.4.0-93-generic
sudo apt-get install inux-image-4.4.0-93-generic
Restart the computer, enter the Ubuntu advanced options in the boot menu, and select the linux 4.4.0 kernel to start the system.
Press ctrl+alt+f1 on the login interface to enter tty1 mode and close the desktop.
sudo service lightdm stop
Install CUDA9.0
sudo ./cuda_9.0.*_linux.run
Install cuDNN9.0
Switch to the directory where the cuDNN Tar file is located and unzip it.
tar -xzvf cudnn-9.0-linux-x64-v7.tgz
Copy the following files to the CUDA directory.
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
Environment variable configuration
sudo vi ~/.bashrc (console valid) or /etc/profile
Write the following to the end of the file.
export PATH=PATH:/usr/local/cuda-9.0/bin
export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64
After saving, update the file.
source ~/.bashrc
Install NVIDIA Driver
Restart, also press ctrl + alt + f1 on the login interface to enter tty1, and install the NVIDIA graphics card driver.
sudo sh ./NVIDIA-Linux-x86_64-38* -no-x-check -no-nouveau-check -no-opengl-files
Test
Restart, enter the graphical interface. Test if the installation is successful.
python3
import numpy import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))
exit()