ウェブサイト検索

LinuxでCUDAコアの数を取得する方法


この記事では、LinuxでCUDAコアの数を取得する方法について学びます。テキストの対象として、NVIDIA GeForce RTX 3080のCUDAコアの数を取得します。

このチュートリアルでは、あなたは学びます:

  • NVIDIAドライバーを使用してCUDAコアの数を取得する方法
  • NVIDIA CUDAツールキットを使用してCUDAコアの数を取得する方法

NVIDIA RTX 3080のCUDAコア数

ソフトウェアの要件と使用される規約

LinuxでNVIDIAドライバーを使用してCUDAコアの数を取得する方法

  1. 最初のステップは、NVIDIAグラフィックカードに適切なドライバーをインストールすることです。そのために、私たちのNVIDIAドライバーインストールガイドのいずれかを参照してください。
  2. 準備が整ったら、次のコマンドオプションを使用して nvidia-settings コマンドを実行してください。例えば、これは私たちのNVIDIA RTX 3080 GPUのCUDAコアの数です:

    nvidia-settings -q CUDACores -t
    8704
    8704
    


LinuxでNVIDIAドライバーを使用してCUDAコアの数を取得する方法

    1. NVIDIA CUDAツールキットのインストールを始めましょう。以下は一般的な64ビットLinuxディストリビューションにおけるCUDAツールキットのインストール例です:
      UBUNTU 20.04:

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

      DEBIAN 10:

      apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/7fa2af80.pub
      add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/ /"
      add-apt-repository contrib
      apt-get update
      apt-get -y install cuda
      

      RHEL 8/CENTOS 8:

      sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo
      sudo dnf clean all
      sudo dnf -y module install nvidia-driver:latest-dkms
      sudo dnf -y install cuda
      
    2. CUDAのインストールガイドについては、CUDAダウンロードをご覧ください。

    3. CUDAツールキットのインストールの一部として、そのdeviceQueryディレクトリを見つけてください。

      locate deviceQuery
      

      上記のコマンドは、以下のような出力を返すべきです:

      locate deviceQuery
      /usr/local/cuda-11.4/extras/demo_suite/deviceQuery
      /usr/local/cuda-11.4/samples/1_Utilities/deviceQuery
      /usr/local/cuda-11.4/samples/1_Utilities/deviceQuery/Makefile
      /usr/local/cuda-11.4/samples/1_Utilities/deviceQuery/NsightEclipse.xml
      /usr/local/cuda-11.4/samples/1_Utilities/deviceQuery/deviceQuery.cpp
      ...
      


  1. deviceQuery のソースコードをコンパイルします:

    cd /usr/local/cuda-11.4/samples/1_Utilities/deviceQuery
    make
    
  2. 新しくコンパイルされたバイナリを実行して、あなたのNVIDIA GPUのCUDAコア数を取得します。:

    ./deviceQuery 
    ./deviceQuery Starting...
    
     CUDA Device Query (Runtime API) version (CUDART static linking)
    
    Detected 1 CUDA Capable device(s)
    
    Device 0: "NVIDIA GeForce RTX 3080"
      CUDA Driver Version / Runtime Version          11.4 / 11.4
      CUDA Capability Major/Minor version number:    8.6
      Total amount of global memory:                 10015 MBytes (10501423104 bytes)
      (068) Multiprocessors, (128) CUDA Cores/MP:    8704 CUDA Cores
      GPU Max Clock rate:                            1800 MHz (1.80 GHz)
      Memory Clock rate:                             9501 Mhz
      Memory Bus Width:                              320-bit
      L2 Cache Size:                                 5242880 bytes
      Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
      Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
      Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
      Total amount of constant memory:               65536 bytes
      Total amount of shared memory per block:       49152 bytes
      Total shared memory per multiprocessor:        102400 bytes
      Total number of registers available per block: 65536
      Warp size:                                     32
      Maximum number of threads per multiprocessor:  1536
      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:            Yes
      Supports Cooperative Kernel Launch:            Yes
      Supports MultiDevice Co-op Kernel Launch:      Yes
      Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
      Compute Mode:
         < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
    
    deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.4, CUDA Runtime Version = 11.4, NumDevs = 1
    Result = PASS
    

関連記事: