見出し画像

Ubuntu 20.04にCUDA 11.2をインストールしたい

Ubuntu 20.04 LTS 日本語 Remixをインストールした後、CUDA dowonloadサイトで、Linux -> x86_64 -> Ubuntu -> 20.04 -> deb (network)をクリックすると、インストールのコマンド列が表示される。今回は、以下のように表示された。

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda

これらコマンドを実行した後、追加のパッケージをインストールする。

sudo apt -y install freeglut3 freeglut3-dev libegl-dev libfreeimage-dev libfreeimage3 libgles2-mesa-dev libglfw3-dev libglu1-mesa libglu1-mesa-dev libxi-dev libxmu-dev mesa-common-dev

CUDAのインストールは以上で完了。

動作確認のために、/usr/local/cuda/samplesにあるCUDAのサンプルプログラムをコピーしてビルドする。ビルドの実時間は、AMD Ryzen 7 2700Xで約10分かかった。

$ cp -a /usr/local/cuda/samples .
$ cd samples
$ make

simpleMPIがビルドできなかった。OpenMPIのコンパイラはないので、しかたない。

WARNING - No MPI compiler found.
CUDA Sample "simpleMPI" cannot be built without an MPI Compiler.
This will be a dry-run of the Makefile.
For more information on how to set up your environment to build and run this
sample, please refer the CUDA Samples documentation and release notesび

deviceQueryコマンドの結果は以下のとおり。このPCには、GeForce GTX TITAN XとGeForce GT710の二枚が刺さっている。

./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 2 CUDA Capable device(s)
Device 0: "GeForce GTX TITAN X"
 CUDA Driver Version / Runtime Version          11.2 / 11.2
 CUDA Capability Major/Minor version number:    5.2
 Total amount of global memory:                 12212 MBytes (12804685824 bytes)
 (24) Multiprocessors, (128) CUDA Cores/MP:     3072 CUDA Cores
 GPU Max Clock rate:                            1076 MHz (1.08 GHz)
 Memory Clock rate:                             3505 Mhz
 Memory Bus Width:                              384-bit
 L2 Cache Size:                                 3145728 bytes
 Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
 Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
 Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
 Total amount of constant memory:               65536 bytes
 Total amount of shared memory per block:       49152 bytes
 Total shared memory per multiprocessor:        98304 bytes
 Total number of registers available per block: 65536
 Warp size:                                     32
 Maximum number of threads per multiprocessor:  2048
 Maximum number of threads per block:           1024
 Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
 Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
 Maximum memory pitch:                          2147483647 bytes
 Texture alignment:                             512 bytes
 Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
 Run time limit on kernels:                     Yes
 Integrated GPU sharing Host Memory:            No
 Support host page-locked memory mapping:       Yes
 Alignment requirement for Surfaces:            Yes
 Device has ECC support:                        Disabled
 Device supports Unified Addressing (UVA):      Yes
 Device supports Managed Memory:                Yes
 Device supports Compute Preemption:            No
 Supports Cooperative Kernel Launch:            No
 Supports MultiDevice Co-op Kernel Launch:      No
 Device PCI Domain ID / Bus ID / location ID:   0 / 8 / 0
 Compute Mode:
    < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
Device 1: "GeForce GT 710"
 CUDA Driver Version / Runtime Version          11.2 / 11.2
 CUDA Capability Major/Minor version number:    3.5
 Total amount of global memory:                 981 MBytes (1028980736 bytes)
 ( 1) Multiprocessors, (192) CUDA Cores/MP:     192 CUDA Cores
 GPU Max Clock rate:                            954 MHz (0.95 GHz)
 Memory Clock rate:                             800 Mhz
 Memory Bus Width:                              64-bit
 L2 Cache Size:                                 524288 bytes
 Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
 Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
 Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
 Total amount of constant memory:               65536 bytes
 Total amount of shared memory per block:       49152 bytes
 Total shared memory per multiprocessor:        49152 bytes
 Total number of registers available per block: 65536
 Warp size:                                     32
 Maximum number of threads per multiprocessor:  2048
 Maximum number of threads per block:           1024
 Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
 Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
 Maximum memory pitch:                          2147483647 bytes
 Texture alignment:                             512 bytes
 Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
 Run time limit on kernels:                     Yes
 Integrated GPU sharing Host Memory:            No
 Support host page-locked memory mapping:       Yes
 Alignment requirement for Surfaces:            Yes
 Device has ECC support:                        Disabled
 Device supports Unified Addressing (UVA):      Yes
 Device supports Managed Memory:                Yes
 Device supports Compute Preemption:            No
 Supports Cooperative Kernel Launch:            No
 Supports MultiDevice Co-op Kernel Launch:      No
 Device PCI Domain ID / Bus ID / location ID:   0 / 6 / 0
 Compute Mode:
    < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
> Peer access from GeForce GTX TITAN X (GPU0) -> GeForce GT 710 (GPU1) : No
> Peer access from GeForce GT 710 (GPU1) -> GeForce GTX TITAN X (GPU0) : No
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.2, CUDA Runtime Version = 11.2, NumDevs = 2
Result = PASS