Tensorflow 2.0.0 has been released and integrated with keras, making it even more convenient. Therefore, I will write the procedure from installing the GPU driver to installing CUDA and cuDNN, and installing Tensorflow 2.0.0-gpu, which are necessary to install the GPU version of Tensorflow 2.0.0 on Ubuntu 18.04 LTS.
OS:Ubuntu 18.04 LTS GPU:nvidia Geforce GTX1660
**-Update package information ** Get the package name, version, and dependencies from the package repository.
$ sudo apt update
** ・ Package update ** Just in case, update the package.
$ sudo apt upgrade
**-Display a list of available drivers **
$ ubuntu-drivers devices
The following results were displayed on the GTX 1660.
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00002184sv00001462sd00008D91bc03sc00i00
vendor : NVIDIA Corporation
driver : nvidia-driver-435 - distro non-free recommended
driver : nvidia-driver-430 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
Install the recommended driver, nvidia-driver-435.
**-Driver installation **
$ sudo apt install nvidia-driver-435
·Reboot
$ sudo reboot
Activate the installed driver by rebooting.
Install CUDA-10.0 which is compatible with Tensorflow 2.0.0.
**-Download CUDA Toolkit ** Download the .run file for CUDA Toolkit 10.0 from the nvidia page below. CUDA Toolkit 10.0 Archive https://developer.nvidia.com/cuda-10.0-download-archive **-Installing CUDA Toolkit ** To install CUDA, you need to download and install the Base Installer. Since there is also a patch this time, after downloading the Base Installer and Patch, move to the directory where the Base Installer and Patch are saved.
$cd saved directory
First, run the Base Installer.
/Saved directory$ sudo sh cuda_10.0.130_410.48_linux.run
Press the D key to proceed and answer the question. This time, the driver is installed first, so set the driver installation to no. If you need a CUDA sample, answer yes to the last question.
-----------------
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48?
(y)es/(n)o/(q)uit: n
Install the CUDA 10.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-10.0 ]: /usr/local/cuda-10.0
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 10.0 Samples?
(y)es/(n)o/(q)uit: n
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-10.0
Samples: Not Selected
Then install Patch.
/\ Saved directory$ sudo sh cuda_10.0.130.1_linux.run
As before, press the D key to proceed and answer the question.
Do you accept the previously read EULA?
accept/decline/quit: accept
Enter CUDA Toolkit installation directory
[ default is /usr/local/cuda-10.0 ]: /usr/local/cuda-10.0
Installation complete!
Installation directory: /usr/local/cuda-10.0
** ・ Pass through CUDA's PATH ** Enter the following command.
$ echo -e "\n## CUDA and cuDNN PATHS" >> ~/.bashrc
$ echo "export PATH=/usr/local/cuda-10.0/bin:${PATH}" >> ~/.bashrc
$ echo "export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:${LD_LIBRARY_PATH}" >> ~/.bashrc
$ source ~/.bashrc
** ・ Confirmation of CUDA installation ** Check if CUDA of the following command is installed correctly.
$ nvcc -V
result
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
You can confirm that CUDA 10.0 has been installed.
Install cuDNN7.6 which is compatible with Tensorflow 2.0.0. ** ・ Installation of cuDNN ** Download the cuDNN7.6 .deb file from the nvidia page below. Membership registration is required to download. Download cuDNN v7.6.0 (May 20, 2019), for CUDA 10.0 https://developer.nvidia.com/rdp/cudnn-archive After downloading both the cuDNN Runtime Library for Ubuntu18.04 (Deb) and the cuDNN Developer Library for Ubuntu18.04 (Deb), move to the saved directory.
$cd saved directory
First install the runtime library.
/Saved directory$ sudo dpkg -i libcudnn7_7.6.0.64-1+cuda10.0_amd64.deb
Then install the developer library.
/Saved directory$ sudo dpkg -i libcudnn7-dev_7.6.0.64-1+cuda10.0_amd64.deb
** ・ Confirm cuDNN installation ** Enter the following command
$ cat /usr/include/cudnn.h | grep CUDNN_MAJOR -A 2
result
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 6
#define CUDNN_PATCHLEVEL 0
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
#include "driver_types.h"
If you see the above, cuDNN is installed normally.
Install pip to install Tensorflow. If you already have the latest version of pip installed, you can skip the curl and pip installations. **-Install curl command ** Install the curl command that allows you to specify a URL and install files on the web.
$ sudo apt install curl
** ・ Install pip ** Install the Python package management tool pip. If you have installed Ubuntu18.04LTS with the minimum configuration, you do not need to install pip3 because Python2 system is not installed. Pip needs to be the latest version to install Tensorflow 2.0.0, but if the Python 2 environment coexists with the Python 3 environment, an error occurs after updating pip 3 installed with apt with pip 3. Therefore, it is easier to install Tensorflow in a Python 3 only environment. Download the Python code to install pip with the following command and run the program.
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ sudo python3 get-pip.py
This completes the installation of pip. You can check the version of pip with the command below.
$ pip -V
pip 19.3.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
If the version of pip is less than 19.0, enter the following command.
$ pip install --upgrade pip
**-Upgrade setuptools ** Upgrade setuptools with the command below.
$ pip install setuptools --upgrade
**-Tensorflow 2.0.0-GPU installation ** Tensorflow 2.0.0-Install GPU. Enter the following command.
$ pip install tensorflow-gpu==2.0.0
This completes the installation of tensorflow-gpu == 2.0.0.
**Thank you for your hard work! !! Send us a fun Tensorflow 2.0.0-GPU life! ** **
Recommended Posts