Install the latest Cuda + CuDNN on Ubuntu 18.04 @ Spring 2020

Introduction

Last year, I wrote an article "Installing the latest cuda + cudnn + cupy on Ubuntu 18.04 @ Spring 2019", but this year also Google Colaboratory wasn't enough, so we built an environment to use a full-fledged GPU server.

Keep a memorandum of work at that time.

Thing you want to do

--Create an environment where you can use Tensorflow 2.2 with ubuntu. ~~ (Chainer has stopped updating, so it can't be helped) ~~ --Installation target is Ubuntu 18.04. ~~ (It seems that cuda doesn't support 20.04 yet, so it can't be helped) ~~

Please refer to GPU support of Tensorflown. Please note that you can follow the same procedure for other libraries.

Installation environment

Machine: GCP Computer Engine (Google-provided cloud virtual machine) CPU, memory: n1-standard-2 (vCPU x 2, memory 7.5 GB) OS: Ubuntu 18.04 GPU: NVIDIA Tesla K80

Actual procedure

Pay attention to the version of cuda, driver and various libraries. Of course, if they aren't compatible, you'll get an error. At the time of posting, the following commands were executed, but please specify the required version and DL.


#cuda related installation
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.2.89-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo dpkg -i cuda-repo-ubuntu1804_10.2.89-1_amd64.deb
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt-get update

#Driver installation
sudo apt-get install --no-install-recommends nvidia-driver-430

#Added cuda related path.Write to a configuration file such as bashrc
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Reboot once at this point. After rebooting, hit nvidia-smi to see if it works properly


#Installation of other libraries used in tensorflow
sudo apt-get install --no-install-recommends cuda-10-2 libcudnn7 libcudnn7-dev
sudo apt-get install --no-install-recommends libnvinfer6 libnvinfer-dev libnvinfer-plugin6

#Install tensorflow
pip install tensorflow

Operation check

import tensorflow as tf
tf.__version__
> '2.2.0'


from tensorflow.python.client import device_lib
device_lib.list_local_devices()

> '''
[name: "/device:CPU:0"
 device_type: "CPU"
 memory_limit: 268435456
 locality {
 }
 incarnation: 3998521659132627640,
 name: "/device:XLA_CPU:0"
 device_type: "XLA_CPU"
 memory_limit: 17179869184
 locality {
 }
 incarnation: 4355352578664011114
 physical_device_desc: "device: XLA_CPU device",
 name: "/device:XLA_GPU:0"
 device_type: "XLA_GPU"
 memory_limit: 17179869184
 locality {
 }
 incarnation: 5803845507802816222
 physical_device_desc: "device: XLA_GPU device"]
'''

GPU recognized in Tensorflow. the end

Digression

Actually, GCP has a setup for GPU prepared by Google, and if you use it when creating a virtual machine, you do not need to go through the above troublesome steps. It has become a convenient world ~

Recommended Posts

Install the latest Cuda + CuDNN on Ubuntu 18.04 @ Spring 2020
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
Install CUDA 8.0 and Chainer on Ubuntu 16.04
Install TensorFlow on Ubuntu
Use the latest version of PyCharm on Ubuntu
Install JModelica on Ubuntu
Install Python 3.3 on Ubuntu 12.04
Install Theano on Ubuntu 12.04
Install angr on Ubuntu 18.04
Install pip / pip3 on Ubuntu
Install NVIDIA-driver (GeForce RTX 2070 SUPER), cuda 10.1, cudnn 7.6 on Ubuntu 18.04.3 LTS + python environment construction
Steps to install the latest Python on your Mac
Install the JDK on Linux
Install OpenCV on Ubuntu + python
wsl Install PostgreSQL on Ubuntu 18.04
[ROS] Install ROS (melodic) on Ubuntu (18.04)
Install Caffe on Ubuntu 14.04 (GPU)
Install Docker on WSL Ubuntu 18.04
Notes on the version of CUDA, cuDNN where tensorflow-gpu worked
Set up AWS (Ubuntu 14.04) for Deep Learning (install CUDA, cuDNN)
Install the latest version of Git on your Linux server
Install Caffe on Ubuntu 14.04 (CPU mode)
Install Mecab and mecab-python3 on Ubuntu 14.04
Install and run dropbox on Ubuntu 20.04
Install OpenCV and Chainer on Ubuntu
Install Python 3.8 on Ubuntu 20.04 (OS standard)
Install fabric on Ubuntu and try
Install Python 3.9 on Ubuntu 20.04 (OS standard?)
Install confluent-kafka for Python on Ubuntu
Install Python 2.7 on Ubuntu 20.04 (OS standard?)
Notes on installing Ubuntu 18.04 on the XPS 15 7590
How to install Go on Ubuntu
ROS study # 1 Install ros-noetic on ubuntu 20.04
The easiest way to get Chainer v1.5 + CUDA + cuDNN on Windows
Install the latest version of Apache httpd 2.4 from source on Cent OS 8
Steps to install Python environment on Ubuntu
Install Pleasant on Ubuntu 20.04 (.NetCore3.1 / PostgreSQL version)
Install ubuntu on 32bit UEFI Ultra Notebook
Install Caffe running 3D-CNN on clean Ubuntu 14.04
Install Puppet Master and Client on Ubuntu 16.04
How to install php7.4 on Linux (Ubuntu)
Install pyenv and Python 3.6.8 on Ubuntu 18.04 LTS
Compiling the Linux kernel (Linux 5.x on Ubuntu 20.04)
[Latest] How to build Java environment on Ubuntu
Install python package in personal environment on Ubuntu
[Procedure memo] Install Python3 + OpenSSL locally on Ubuntu
[Note] Install wxPython 3.x on Linux Mint (Ubuntu)
At the time of python update on ubuntu
Change the resolution of Ubuntu running on VirtualBox
Install MongoDB on Ubuntu 16.04 and operate via python
Install Ubuntu 20.04 LTS (Server) 64bit version on RaspberryPi3B +
Install the machine learning library TensorFlow on fedora23
Shebang on Ubuntu 20.04
Install Apache Tomcat 9 on Ubuntu 19.10 Eoan Ermine Hello World
Install the 3rd party python library on Cinema 4D
I got a UnicodeDecodeError when pip install on ubuntu
Install the latest stable Python with pyenv (both 2 and 3)
Install Ubuntu 20.04 with GUI and prepare the development environment
Install the latest Python from pyenv installed with homebrew
Let's Deep Learning on Windows! (VS2013 + caffe + CUDA7.5 + cudnn5.1)
Install django on python + anaconda and start the server