In this article, I will record the process of installing CuPy to run the GPU on Ubuntu as a memorandum.
Install NVIDIA driver on Ubuntu 20.04
Install CUDA Toolkit 11.1.
Install CuPy 11.1
OS: Ubuntu 20.04
GPU: RTX 2060 SUPER
CPU: Ryzen 3600
What I want to do is create a virtual environment using poetry and install various things in it, but I will omit it here.
Find the recommended driver with the following command.
ubuntu-drivers devices
You can install the recommended drivers from Additional Software and Update Drivers.
Alternatively, use the following command to add the NVIDIA PPA repository and install the driver.
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-driver-xxx
(Comment: Maybe this is the opposite.)
Once the driver is installed, you can check it with the following command.
nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.27.04 Driver Version: 460.27.04 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce RTX 206... On | 00000000:06:00.0 On | N/A |
| 29% 31C P3 39W / 175W | 1114MiB / 7979MiB | 19% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1104 G /usr/lib/xorg/Xorg 101MiB |
| 0 N/A N/A 3110 G /usr/lib/xorg/Xorg 586MiB |
| 0 N/A N/A 3271 G /usr/bin/gnome-shell 134MiB |
| 0 N/A N/A 4748 G ...AAAAAAAA== --shared-files 212MiB |
+-----------------------------------------------------------------------------+
(Comment: If you can't, reboot.)
The CUDA Toolkit and CuPy need (should) match versions, so install the version of CUDA Toolkit you need. This time I want to install CuPy 11.1 which is the latest at the moment (2021/1/8), so install 11.1 of CUDA Toolkit accordingly (the latest version at this point is 11.2).
(Comment: CUDA Version: 11.2 is displayed in the upper right of the command display, but it seems that this is the version that can be inserted)
Past versions can be found in the CUDA Toolkit Archive (https://developer.nvidia.com/cuda-toolkit-archive). CUDA Toolkit 11.1.1 -> Linux -> x86_64 -> Ubuntu -> 20.04 -> runfile (local) Proceed in the order of.
Follow the command shown below to install.
wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
sudo sh cuda_11.1.1_455.32.00_linux.run
Now go to Continue-> accept. In CUDA Installer, uncheck Driver (you can remove it with the enter key). After removing it, proceed to Install.
(Comment: I get an error if I install the Driver.)
Refer to Official Site and install with the following command in your own virtual environment.
pip install cupy-cuda111
As a result of various trials and errors, I feel that this method was the easiest.
Recommended Posts