Install NVIDIA-driver (GeForce RTX 2070 SUPER), cuda 10.1, cudnn 7.6 on Ubuntu 18.04.3 LTS + python environment construction

Introduction

You will be setting up the GPU, and I will keep the procedure as a memorandum. In this article, we have installed ** NVIDIA-driver, cuda, cudnn ** and created a Python virtual environment using ** pyenv, virtualenv **. I hope it will be helpful as much as possible.

environment

1. Before installing NVIDIA-driver

Install vim (because I personally want to use vim)
$ sudo apt update
$ sudo apt install vim

I want to use jj with vim, so edit ~ / .vimrc. (Temporarily I will only do this setting.)

~/.vimrc


set number
inoremap<silent> jj <ESC>

(1) Disabling Nouveau

First, disable Nouveau. When it comes to Nvidia graphics cards, a driver called Nouveau is set by default, so add Nouveau to the blacklist.

Check if Nouveau is used
$ lsmod | grep -i nouveau
Creating a blacklist
$ sudo vim /etc/modprobe.d/blacklist-nouveau.conf

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


blacklist nouveau
options nouveau modeset=0
Execute the following command and confirm that nouveau is disabled

OK if the display resolution is low

$ sudo update-initramfs -u
$ sudo reboot 

(2) Fixing the kernel

If you do not fix the kernel version of the nvidia driver, it seems that the dependency with the driver may be broken when upgrading. So, fix the kernel.

Install aptitude
$ sudo apt install aptitude

aptitude: A text-based interface to the Debian GNU / Linux package system that allows you to view a list of packages and perform package management tasks such as installing, updating, and removing packages.

Check kernel version
$ aptitude show linux-generic
Write the contents confirmed above to the following file (rewrite only the version)
$ cd /etc/apt/preferences.d
$ sudo vim linux-kernel.pref

.linux-kernel.pref


Package: linux-generic
Pin: version 4.15.0.64.66
Pin-Priority: 1001

Package: linux-headers-generic
Pin: version 4.15.0.64.66
Pin-Priority: 1001

Package: linux-image-generic
Pin: version 4.15.0.64.66
Pin-Priority: 1001

That's all for fixing the kernel.

2. Install NVIDIA driver

Check if nouveau is disabled
$ lsmod | grep -i nouveau

If nothing is displayed, it can be disabled

Install all the tools required for development such as gcc and make
$ sudo apt install build-essential
Add repository
$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt update
Shows installable devices
$ ubuntu-drivers devices
Select the driver you want to install and install
$ sudo apt install nvidia-driver-430
$ sudo reboot
Check if the driver is installed
$ nvidia-smi

OK if the usage status of GPU etc. is displayed

Another way to install NVIDIA-driver

I wrote an article before, so please refer to that. I installed the NVIDIA driver on Ubuntu 17.10.

3. Install cuda

Please download cuda from here (https://developer.nvidia.com/cuda-toolkit-archive). Be sure to check the version of cuda and driver.

cuda installation
$ sudo apt update
$ sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
$ sudo apt-key add /var/cuda-repo-10-1-local-10.1.105-418.39/7fa2af80.pub 
$ sudo apt update
$ sudo apt install cuda-10-1
Edit ~ / .bashrc (setting environment variables)

~/.bashrc


export PATH="/usr/local/cuda-10.1/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH"
Pass through PATH
$ source ~/.bashrc
Version confirmation
$ nvcc -V
$ nvidia-smi

4. Install cudnn

Please download the cudnn installation file from here (https://developer.nvidia.com/rdp/cudnn-download). You will need to register for an account.

installation of cudnn
$ tar xvf cudnn-10.1-linux-x64-v7.6.5.32.tgz
$ sudo cp -a cuda/include/cudnn.h /usr/local/cuda/include/
$ sudo cp -a cuda/lib64/libcudnn* /usr/local/cuda/lib64/
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* 
$ sudo reboot
Test if cudnn was installed
$ sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.1_amd64.deb
$ cp -r /usr/src/cudnn_samples_v7/ $HOME
$ cd $HOME/cudnn_samples_v7/mnistCUDNN
$ make clean && make
$ ./mnistCUDNN

OK if Test passed! Is displayed

cudnn version check command

$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

5. Python environment construction

I got a dependency error so I repaired it
$ sudo apt --fix-broken install
Install required packages for Python
$ sudo apt install git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev zlib1g-dev

(1) Installation of pyenv

** pyenv **: A command line tool for Python version control that makes it easy to install and switch between multiple versions of Python.

$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc 
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc 
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$ source ~/.bashrc
List of installable packages
$ pyenv install -l
Python installation
$ pyenv install 3.6.5
Check the installed version
$ pyenv versions
Version switching
$ pyenv global 3.6.5

(2) virtualenv

** virtualenv **: Software that can create a separate Python virtual environment in one system. You can easily create a virtual environment with commands.

Install virtualenv
$ pip install virtualenv
Version confirmation
$ virtualenv --version
Create virtual environment
$ virtualenv (PJ name) --no-site-packages
Enable virtual environment
$ . (PJ name)/bin/activate
Disable virtual environment
$ deactivate

At the end

I installed from Ubuntu this time, but the installation screen did not appear at first. The following settings were required on the BIOS screen.

--Secure Boot: os type UEFI mode ⇒ non-UEFI mode --CSM: Start CSM ⇒ Enabled

It took a while, but it was a good experience to set up this time because I gained some knowledge.

Recommended Posts

Install NVIDIA-driver (GeForce RTX 2070 SUPER), cuda 10.1, cudnn 7.6 on Ubuntu 18.04.3 LTS + python environment construction
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
OpenCV3 & Python3 environment construction on Ubuntu
Steps to install Python environment on Ubuntu
Install pyenv and Python 3.6.8 on Ubuntu 18.04 LTS
Install python package in personal environment on Ubuntu
Install the latest Cuda + CuDNN on Ubuntu 18.04 @ Spring 2020
Install Python 3.3 on Ubuntu 12.04
Install OpenCV on Ubuntu + python
Install Python 3.8 on Ubuntu 18.04 (OS standard)
Python environment construction memo on Windows 10
Python 3.4 pyvenv fails on Ubuntu 14.04 LTS
Prepare Python development environment on Ubuntu
Anaconda python environment construction on Windows 10
Building a Python environment on Ubuntu
Install CUDA 8.0 and Chainer on Ubuntu 16.04
Install Python 3.8 on Ubuntu 20.04 (OS standard)
Install python2.7 on windows 32bit environment
Python environment construction memo on Mac
Python development environment construction on macOS
Environment construction of python3.8 on mac
Install Python 3.9 on Ubuntu 20.04 (OS standard?)
Install Python development environment on Windows 10
Install confluent-kafka for Python on Ubuntu
Install Python 2.7 on Ubuntu 20.04 (OS standard?)
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Environment construction of "Tello_Video" on Ubuntu
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
When creating an environment that uses python django on Ubuntu 12.04 LTS
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Build Python3 and OpenCV environment on Ubuntu 18.04
Created Ubuntu, Python, OpenCV environment on Docker
Environment construction procedure: Ubuntu + Apache2 + Python + Pyramid
[Note] Python environment construction on rental server "CORESERVER"
Ubuntu18.04.05 Creating a python virtual environment in LTS
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
[Procedure memo] Install Python3 + OpenSSL locally on Ubuntu
How to run MeCab on Ubuntu 18.04 LTS Python
[0] TensorFlow-GPU environment construction built with Anaconda on Ubuntu
[Venv] Create a python virtual environment on Ubuntu
Python 3.x environment construction by Pyenv (CentOS, Ubuntu)
Install MongoDB on Ubuntu 16.04 and operate via python
Install Ubuntu 20.04 LTS (Server) 64bit version on RaspberryPi3B +
Python environment construction
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
Install the latest version of CMake on Ubuntu 18.04.4 LTS
Install Python venv --VSCode --GitHub integration environment on Mac
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
I made a Python3 environment on Ubuntu with direnv.
Install Python environment on local PC (pyenv, venv on Mac)
Install Bash on Ubuntu on Windows, Ruby, Python, Jupyter, etc.
Install python on WSL
Install Python on Pidora.
python windows environment construction
homebrew python environment construction
Install Python on Mac