August 7, 2020

[Note] CUDA on Ubuntu 20.04

Install Options

A couple of ways to install CUDA:

  1. get everything from NVIDIA CUDA site
  2. apt-get
  3. docker

 

For the latest CUDA version,  do method #1.  For easier way, #2.  I chose to do #2.  But after went through it, I'm not sure if it's really easier. 

And #2 method, the CUDA version is 10.1.  I haven't tried docker method.

 

Install

Checking driver version:

$ nvidia-smi


Fri Aug  7 18:35:38 2020      
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.100      Driver Version: 440.100      CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0   Quadro P2000        Off  | 00000000:09:00.0  On |                  N/A |
| 53%   47C    P8     7W /  75W |    663MiB /  5057MiB |     17%      Default |
+-------------------------------+----------------------+----------------------+
...


Install packages using apt-get

$ sudo apt-get install build-essentials nvidia-cuda-toolkit

Check nvcc version:

$ nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243


Install cudnn

  1. Download cudnn, https://developer.nvidia.com/cudnn
  2. uncompress
  3. sudo cp cuda/include/cudnn.h /usr/lib/cuda/include/
    sudo cp cuda/lib64/libcudnn* /usr/lib/cuda/lib64/
    sudo chmod a+r /usr/lib/cuda/include/cudnn.h /usr/lib/cuda/lib64/libcudnn*


Install sample codes

Using apt-get, it doesn't come with sample codes.  For installing Kinect2 (will be on another posting), the sample is needed.  Install only if you need it.

Download from github, https://github.com/NVIDIA/cuda-samples/tree/10.1.2 

And store it anywhere you want.  Note that some other dependent code may look for it in a certain path, such as /usr/local/cuda-X-Y...


A couple more things to do:

[1] 

nvcc is installed in /usr/bin/  -- examples and some programs I use (sorry didn't write it down and forgot what it was) looks for it in /usr/local/cuda/bin.  Create a sym link there.

[2] vi .vashrc

export LD_LIBRARY_PATH=/usr/lib/cuda/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib/cuda/include:$LD_LIBRARY_PATH


Reference

 

CUDA Samples

  1. https://docs.nvidia.com/cuda/cuda-samples/index.html
  2. https://github.com/NVIDIA/cuda-samples/tree/10.1.2
  3. https://www.pugetsystems.com/labs/hpc/How-To-Install-CUDA-10-together-with-9-2-on-Ubuntu-18-04-with-support-for-NVIDIA-20XX-Turing-GPUs-1236/#step-6-test-cuda-by-building-the-samples-from-source-for-both-cuda-92-and-cuda-100


Nvidia Docker

 

No comments:

Post a Comment