Configuration
The author uses the Dell Inspiron 7559 notebook computer with the Nvidia GTX 960M graphics card.
Goal
Due to the native graphics card only nvidia-384 driver package can be well supported (nvidia-387, nvidia-390 package are in the system can not be logged in such anomalies), and Cuda 9.1 need to drive at least nvidia-387, so choose to install Cuda 9.0 and cuDNN7.0.
Telsorflow 1.8 fully supports Cuda 9.0 so you can use the latest version.
Installing the video driver
Install the nvidia-384 driver package using apt (the actual installation driver is 390):
sudo apt-get install nvidia-384
Reboot the system after installation is complete.
Run command
nvidia-smi
The ability to display the current health (table) of the graphics card indicates that the driver installation was successful.
Installing Cuda 9.0 Preparation
Cuda and TensorFlow volume are large and download source in foreign countries, please find a good network environment. You can find the appropriate domestic image.
Download Cuda 9.0 version of the. Run installation package (https://developer.nvidia.com/cuda-90-download-archive) from Nvidia official website legacy releases.
Since Cuda 9.0 supports only GCC 6.0 and below, and Ubuntu 18.04 is pre-installed with GCC version 7.3, manually install Gcc-6 and g++-6:
sudo apt-get install gcc-6 g++-6
Then switch to the/usr/bin directory to modify the symbolic link so that gcc 60% is the default version:
cd /usr/binsudo rm gccsudo ln -s gcc-6 gccsudo rm g++sudo ln -s g++-6 g++
Installation
Assign run permissions to the Cuda 9.0 installation package and run it:
chmod 775 cuda_9.0.176_384.81_linux.runsudo ./cuda_9.0.176_384.81_linux.run --no-opengl-libs
Choose not to install the driver during installation, only Cuda and samples are installed. If prompted, "You were attempting to install the on an unsupported configuration." Select Y to force the installation (if you modified the GCC version earlier, this error should not be reported here).
If the installation fails after installation, refer to the error prompt for additional --override
parameter reinstallation.
Test
Enter the directory where Samples (default is ~/nvidia_cuda-9.0_samples), run the command (it takes a long time)
make
(If you don't want to wait too long you can go to the subdirectory and make some sample programs separately)
If the compilation is successful (there may be warning), you can go to the bin directory to run the program. When all of the above are successful, CUDA installation is successful.
Installing CUDNN 7.0
Still download CUDNN 7.0 from Nvidia official website, note that you need to register for NVIDIA account to download.
All of its packages are then installed normally (the. deb package is used by the author)
sudo dpkg -i libcudnn7_7.0.4.31-1+cuda9.0_amd64.deb libcudnn7-dev_7.0.4.31-1+cuda9.0_amd64.deb libcudnn7-doc_7.0.4.31-1+cuda9.0_amd64.deb
Installing TensorFlow 1.8
Install using PIP. If no PIP is installed, first install PIP:
sudo apt-get install python3-pip#若Python2则为#sudo apt-get install python-pip
After installing TensorFlow:
Because the official PIP download speed is slow, you can refer to the online method to modify the PIP source to the domestic mirror, such as Tsinghua University Tuna Mirror
sudo pip3 install tf-nightly-gpu
After the installation is complete, run the TF sample program to check if the TensorFlow is running smoothly.
The last Obsessive compulsive disorder.
After the above steps have been completed, the default GCC version can be changed back to 7.3, the author measured, should not affect the normal use of tensorflow.
Command:
cd /usr/binsudo rm gccsudo ln -s gcc-7 gccsudo rm g++sudo ln -s g++-7 g++
Installation of Cuda 9.0, cuDNN7.0 and TensorFlow 1.8 on Ubuntu 18.04