Setup work record of tensorflow, CUDA, cuDNN on Ubuntu 20.04 CUDA edition

Content of this article

I recorded the work when CUDA and cuDNN corresponding to the version of tensorflow were installed locally for machine learning with tensorflow.

This article has set up CUDA 10.1 and cuDNN 7.6 to use tensorflow 2.3.0.

environment

Ubuntu 20.04

Reference site

https://codelabo.com/posts/20200229081221
https://medium.com/@exesse/cuda-10-1-installation-on-ubuntu-18-04-lts-d04f89287130

Structure of this article

--1: NDIVIA driver installation -2: CUDA Setup --3: cuDNN Setup

CUDA setup

1 Advance preparation

Find out what CUDA, cuDNN version you need for the version of tensorfow you want to use. You can check it on tensorfow's Official Site. スクリーンショット 2020-11-10 20 06 07

2 Download the CUDA installer

Installing CUDA is actually installing the CUDA toolkit. Don't confuse CUDA with CUDA toolkit.

Only the latest version of cuda can be downloaded from the regular download on the official website, so download it from the archive.

You can choose the version you want to download at NVIDIA CUDA Archived Documentation. Click here for documentation for each version (https://docs.nvidia.com/cuda/archive/)

Screenshot from 2020-11-08 21-42-04

Select the desired CUDA from Archived Releases

CUDA 10.1

Execute the wget command that has been checked in the above selection items in the terminal.

wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run

3 Run the installer

In the official documentation Quick start guide before running the installer Since the necessary work is listed, execute it sequentially. スクリーンショット 2020-11-11 10 45 54

3.1. Disabling the Nouveau driver

--Confirmation command

#Check if nouveau is loaded(If nothing comes out, you may not have to do the invalidation work)
$ lsmod | grep nouveau

Change work to invalidation

in etc / modprobe.d / blacklist-nouveau.conf

blacklist nouveau  
options nouveau modeset=0  

To describe and adapt.

$ cd /etc/modprobe.d
$ sudo touch blacklist-nouveau.conf
$ sudo chmod 777 blacklist-nouveau.conf
$ echo blacklist nouveau > blacklist-nouveau.conf
$ echo options nouveau modeset=0 >> blacklist-nouveau.conf

$ cat blacklist-nouveau.conf #Check the contents

Regenerate kernel initramfs

sudo update-initramfs -u

3.2 Add "3", "nomodest" to kernel parameter to temporarily set runlevel to 3 and restart

About runlevel

--3 Multi-user mode (text login) --5 Multi-user mode (graphical login)

Check the current runlevel

$ runtime
N 5

--Change to level 3

$ systemctl set-default multi-user.target

--Change to level 5

$ systemctl set-default graphical.target

procedure

1 At startup, immediately press Shift to display the grub menu

If it doesn't appear even if you shift it, you should set it to display the grub menu every time you start it. grub menu How to put out: https://qiita.com/ricrowl/items/1d038d6b4412feedb25e

2 * Click "E" when there is a point at Ubuntu.

IMG_6926

3 Write "3" and "nomodeset" after quiete splash on the linux line displayed next, and ctr + X

IMG_6934

runlevel 3 means don't start the Xserver, nomodeset blocks the loading of nouveau modules This is to allow the nvidia modules to be loaded after the build.

3.3 Create an xorg.conf file that uses an NVIDIA GPU for display

$ sudo nvidia-xconfig

When I restarted after doing this, the HDMI signal from the motherboard disappeared. Deal with it by connecting to other video ports on the GPU. I haven't investigated the meaning of this command, so I need to investigate it later.

3.4 Downgrade the gcc version.

Existing gcc version 9.3 is supported, so the latest gcc version will cause an error running .run

udo apt -y install gcc-8 g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8

Reference: https://askubuntu.com/questions/1236188/error-unsupported-compiler-version-9-3-0-when-installing-cuda-on-20-04 The tensorflow documentation recommends gcc 7.3.1, but I could run it with gcc 8.

3.5 Run the run file

sudo sh cuda_10.1.243_418.87.00_linux.run #--silent

When running .run, you have the option to install the versino.418 driver as well. If you execute it with the --silent option of the Quick Start guide, the driver for versino.418 will be installed automatically, so an error will occur due to a conflict with the driver you installed earlier. Execute without any options.

3.6 PATH on CUDA

echo -e "\n## CUDA and cuDNN paths"  >> ~/.bashrc
echo 'export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashr
source ~/.bashrc

3.7. Confirmation of CUDA

nvcc -V

Recommended Posts

Setup work record of tensorflow, CUDA, cuDNN on Ubuntu 20.04 cuDNN edition
Setup work record of tensorflow, CUDA, cuDNN on Ubuntu 20.04 CUDA edition
Record video on ubuntu18.04 LTS
Results of trying to use NVENC (CUDA) with Ubuntu 18.04 on WSL2
[2020 edition] Summary of introductory articles on Struts2
Check when nvidia-smi on Ubuntu doesn't work
Ubuntu 20.04 RTX 3090 cuda cuDNN driver installation memo