Install CUDA 8.0 and Chainer on Ubuntu 16.04

There is a way to manage the CUDA Toolkit by using nvidia-docker, but this time I installed the CUDA Toolkit directly without using it.

environment

What to prepare

  1. CUDA toolkit
  2. cuDNN
  3. Driver (Select appropriately according to your environment)

I used runfile (cuda_8.0.44_linux.run) to install the CUDA Toolkit. cuda-toolkit.png

Installation procedure

1. Install the driver

If Secure Boot is enabled, disable it beforehand. Go to tty1 with Ctrl + Alt + F1 and install the nvidia-smi command and driver. On the way, you will be asked if you want to rewrite the X11 settings. If you rewrite it, the screen will not be displayed, so we recommend that you do not rewrite it. Please reboot once after the installation is completed.

sudo service lightdm stop  #Drop X11
sudo ./NVIDIA-Linux-x86_64-<version>.run  # nvidia-The smi command should be installed
sudo reboot

If the output of the nvidia-smi command looks like this, the GPU has been detected.

$nvidia-smi                           
Mon Aug 15 15:31:22 2016       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 361.77                 Driver Version: 361.77                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce 940M        Off  | 0000:01:00.0     Off |                  N/A |
| N/A   59C    P0    N/A /  N/A |    254MiB /  2003MiB |      8%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0      4105    G   /usr/lib/xorg/Xorg                             165MiB |
|    0      4988    G   fcitx-qimpanel                                   7MiB |
|    0      5310    G   ...ves-passed-by-fd --v8-snapshot-passed-by-    67MiB |
|    0      5598    G   ...DocWrittenScriptsInMainFrame --force-fiel    13MiB |
+-----------------------------------------------------------------------------+

If it is unstable, install the driver with ʻapt-get` and it may work. However, we do not recommend it because the system will try to run X11 on the GPU and the X11 will be unstable.

sudo apt-get install nvidia-361
sudo reboot

2. Install the CUDA toolkit

Run the following command on tty1. __Note: You will be asked if you want to install the driver when you run runfile, but do not install it here. __

sudo service lightdm stop
sudo ./cuda_8.0.44_linux.run --override  #Caution:Do not install the driver here

In Ubuntu 16.04, the version of gcc seems to be different from the one recommended by CUDA, but I forcibly installed the Toolkit with the --override option. If the installation is successful, / usr / local / cuda-8.0 should exist.

If you're having trouble running Chainer, install gcc 5.2 and try again

sudo service lightdm stop
sudo ./cuda_8.0.44_linux.run  #Caution:The driver is not installed here. gcc5.Install 2 in advance.

Please.

3. Install cuDNN

Expand cuDNN and copy the file.

tar xvf cudnn-8.0-linux-x64-v5.1.tgz
sudo cp cuda/include/* /usr/local/cuda-8.0/include
sudo cp cuda/lib64/* /usr/local/cuda-8.0/lib64

Add this to .bashrc and source ~ / .bashrc.

export CUDA_PATH=/usr/local/cuda-8.0
export PATH=$CUDA_PATH/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_PATH/lib64:$LD_LIBRARY_PATH

export CPATH=$CUDA_PATH/include:$CPATH
export LIBRARY_PATH=$CUDA_PATH/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_PATH/lib64:$LD_LIBRARY_PATH

4. Install Chainer

It is usually put in with pip3.

sudo pip3 install chainer

5. Operation check

If ʻimport cupy` passes, it is successful.

$python3
>>> import cupy

The MNIST sample included in the Chainer source code also works.

git clone [email protected]:pfnet/chainer.git
cd chainer/examples/mnist     
python3 train_mnist.py --gpu=0

6. About kernel update

Drivers will no longer be accessible once the kernel is updated. If a new kernel is installed, please install the driver 1 again.

Recommended Posts

Install CUDA 8.0 and Chainer on Ubuntu 16.04
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
Install Mecab and mecab-python3 on Ubuntu 14.04
Install fabric on Ubuntu and try
Install Puppet Master and Client on Ubuntu 16.04
Install pyenv and Python 3.6.8 on Ubuntu 18.04 LTS
Install TensorFlow on Ubuntu
Install PySide2 on Ubuntu
Install JModelica on Ubuntu
Install Python 3.3 on Ubuntu 12.04
Install Chainer 1.5.0 on Windows
Install Theano on Ubuntu 12.04
Install angr on Ubuntu 18.04
Install Chainer on CentOS 6.7
Install pip / pip3 on Ubuntu
Install the latest Cuda + CuDNN on Ubuntu 18.04 @ Spring 2020
Install MongoDB on Ubuntu 16.04 and operate via python
Install GoLand IDE on Ubuntu
Install OpenCV on Ubuntu + python
Install Chainer 1.6 (GPU) on Windows 7.
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
[Python] [Chainer] [Windows] Install Chainer on Windows
Install Apache 2.4 on Ubuntu 19.10 Eoan Ermine and run CGI
Install Python 3.8 on Ubuntu 18.04 (OS standard)
Install Caffe on Ubuntu 14.04 (CPU mode)
Install Python 3.8 on Ubuntu 20.04 (OS standard)
Build and install OpenCV on Windows
Install CUDA on Linux Mint Mate 20
Install python3 and scientific calculation library on Ubuntu (virtualenv + pip)
How to install CUDA and nvidia-driver
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?)
How to install Go on Ubuntu
ROS study # 1 Install ros-noetic on ubuntu 20.04
Install easy_install and pip on windows
Build a Chainer environment using CUDA and cuDNN on a p2 instance
Install Ubuntu 18.04 on MacBook Pro Touchbar model and connect to WIFI
Install wsl2 and master linux on windows
Python virtual environment and packages on Ubuntu
Steps to install Python environment on Ubuntu
Install and launch k3s on Manjaro Linux
Install and Configure TigerVNC server on Linux
Mount and format Disk on Ubuntu on GCP.
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
How to install php7.4 on Linux (Ubuntu)
Install pyenv and rbenv on CentOS system-wide
Shebang on Ubuntu 20.04
Description and summary of what you need to install Chainer on Mac
YOLO on Chainer
Manage Django images and static assets on Ubuntu
Install matplotlib and display graph on Jupyter Notebook
I can't install Dask with pip on Ubuntu
Install and run Python3.5 + NumPy + SciPy on Windows 10
Install python package in personal environment on Ubuntu
[Procedure memo] Install Python3 + OpenSSL locally on Ubuntu