Setup work record of tensorflow, CUDA, cuDNN on Ubuntu 20.04 cuDNN 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

cuDNN setup

Download site: https://developer.nvidia.com/cudnn Nvidia account registration is required in advance. You can select the version from the archive of the download site. Screenshot from 2020-11-10 20-11-53

1. Selection of cuDNN 7.6

Screenshot from 2020-11-10 20-19-43

2. Setup from tar file

Refer to Official guide and execute it sequentially. Screenshot from 2020-11-10 20-31-31

2.1. Decompression

$ tar -zxvf cudnn-10.1-linux-x64-v7.6.5.32.tgz

2.2. Copy cudnn to pre-installed cuda

Copy cudnn to either cuda / or cuda- <version> /. The official documentation says cuda /, but it seems that cuda- <version> / and cuda / are linked, and copying to cuda- <version> / worked fine.

# cuda-<version>/When copying to
$ sudo cp cuda/include/cudnn*.h /usr/local/cuda-<version>/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda-<version>/lib64
$ sudo chmod a+r /usr/local/cuda-<version>/include/cudnn*.h /usr/local/cuda-<version>/lib64/libcudnn*

# cuda/When copying to
$ 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 /usr/local/cuda/lib64/libcudnn*

Please put the version of CUDA you put in <version>.

When changing the version of cuda and cudnn due to the change of the version of tensorflow

Install the desired version of cuda and change or add the cuda path

Install CUDA in advance. Please refer to CUDA Setup.

If you add it, it will automatically select the PATH of the optimum CUDA version and execute it.

Reference: https://qiita.com/takeajioka/items/8737fab5cffbe0118fea

In fact, there are many ways to do it. Change the path described in ~ / .bashrc.

Example

<Before change 10.1>
export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
<After change 11.0>
export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

cudnn changes

When copying cudnn to cuda- <version> /

If you switch the version of cuda loaded on your pc, it will automatically switch to the version of cudnn that is copied to the changed cuda. (I haven't done it yet)

When copying cudnn to cuda /

/usr/local/cuda/include  
/usr/local/cuda/lib64  

Since the old cudnn is included in, delete it and copy the newly downloaded version of cudnn in the same way.

$ sudo rm /usr/local/cuda/include/cudnn*.h
$ sudo rm /usr/local/cuda/lib64/libcudnn*

If you copy it to cuda /, you will be required to delete it when you change cuda, so it may be more convenient to copy it to cuda- <version> and change it for each cuda.

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
NVIDIA-driver (GeForce RTX 2070 SUPER), cuda 10.0, cudnn 7.4.2 settings on Ubuntu 18.04.5 LTS (tensorflow-gpu: 2.0.0 version)
[2020 edition] Summary of introductory articles on Struts2
Check when nvidia-smi on Ubuntu doesn't work
Headless install of Ubuntu 20.10 on Raspberry Pi
Ubuntu 20.04 RTX 3090 cuda cuDNN driver installation memo