ASAP Top

CUDAのセットアップ (CentOS編)

Nvidia Driverのダウンロード

NVIDIAドライバページから、 マシンに搭載されているGPUに対応するドライバをダウンロードする。

Nvidia DriverはCUDA Toolkitにも同梱されているため、基本インストールしなくても良い。 ただし、新しいGPUで古いCUDA Toolkitを使うなど特殊なことをやる場合、 Nvidia Driverを個別にインストールする必要がある。

nvidia_driver_download.png
  • GeForce GTX780Ti (2015/11/17現在)
    $ wget http://jp.download.nvidia.com/XFree86/Linux-x86_64/352.63/NVIDIA-Linux-x86_64-352.63.run
  • GeForce GTX660
    $ wget http://jp.download.nvidia.com/XFree86/Linux-x86_64/331.67/NVIDIA-Linux-x86_64-331.67.run

CUDA Toolkitのダウンロード

以下のリンクからインストールしたいOSに適したCUDAをダウンロードする。

ふんが研の標準的な環境はCentOS(RHEL系のOS)なので、 そのインストール実行ファイル(RUN)をダウンロードすれば良い。

cuda_download.png

Nvidia Driverのインストール

startxを立ち上げているとNvidia Driverをインストールできないので注意。

CUDAをインストールするにはrootになる必要がある。

$ su -

kernel-devel(kernel-source)実装の確認

Nvidia Driverをインストールする場合、kernelの一部のモジュールを再構築する必要がある。 この再構築はNvidia Driverが勝手に行うため、予めkernel-sourceを用意しなければならない。

# yum install kernel-devel

Nvidia Driverのインストール

CUDA Toolkitと合わせてインストールする場合、ここは飛ばしてください。

インストールした(されていた)kernel-sourceを指定して、Nvidia Driverをインストールする。 (kernel-souceの指定はしなくても大丈夫。たぶん)

# sh <NvidiaDriverInstaller>.run --kernel-souce-path /usr/src/kernels/2.6.32-431.29.2.el6.x86_64

実行すると、次のように対話形式で進んでいく。

  • Accept を選択。
    Verifying archive integrity... OK
    Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 260.19.26..........
    
     Please read the following LICENSE and then select either "Accept" to accept the license 
     and continue with the installation, or  select "Do Not Accept" to abort the installation.
    
                          Accept                     Do Not Accept
    
  • 古いドライバーバージョンが実装されている場合次のようになる。古いのを削除するため、Yesを選択。
    (中略)
     There appears to already be a driver installed on your system (version:270.41.19).
     As part of installing this driver (version:  285.05.33), the existing driver will be
     uninstalled.  Are you sure you want to continue? ('no' will abort installation)
    
                          Yes           No
  • Yesを選択。その後、warning メッセージを出してから、エラーを無視して次に進む。
    Install NVIDIA's 32-bit compatibility OpenGL libraries?
    
                          Yes           No
    
    ERROR: File '/usr/lib64/xorg/modules/extensions/libglx.so' is not a symbolic link.
  • OKを選択。
     WARNING: Your driver installation has been altered since it was initially installed;
     this may happen, for example, if you have since installed the NVIDIA driver through 
     a mechanism other than nvidia-installer (such as your distribution's native package 
     management system).  nvidia-installer will attempt to uninstall as best it can. 
     Please see the file '/var/log/nvidia-installer.log' for details.
    
                                       OK
    
  • Yesを選択。
    Would you like to run the nvidia-xconfig utility to automatically update your 
    X configuration file so that the NVIDIA X driver will be used when you restart X?  
    Any pre-existing X configuration file will be backed up.
                  
                          Yes           No
  • OKを選択して完了。
    Your X configuration file has been successfully updated.  Installation of 
    the NVIDIA Accelerated Graphics Driver for Linux-x86_64 (version: 285.05.33) is now complete.
    
                                  OK 

Nouveau kernel driverのせいで、Nvidia Driverがインストールできない場合

インストール中にこんなエラーがでてくるときの対処法。

ERROR: The Nouveau kernel driver is currently in use by your system.
        This driver is incompatible with the NVIDIA driver, and
         must be disabled before proceeding.  Please consult the NVIDIA driver
         README and your Linux distribution's documentation for details 
         on how to correctly disable the Nouveau kernel driver.
         
         For some distributions, Nouveau can be disabled by adding a file 
         in the modprobe configuration directory.  Would you like
         nvidia-installer to attempt to create this modprobe file for you?

                                                          Yes           No
  The modprobe configuration file to disable Nouveau, 
  /etc/modprobe.d/nvidia-installer-disable-nouveau.conf, has been written.  
  For   some distributions, this may be sufficient to disable Nouveau; other 
  distributions may require modification of the initial   ramdisk.  
  Please reboot your system and attempt NVIDIA driver installation again.  
  Note if you later wish to reenable Nouveau, you will need to delete 
  the file /etc/modprobe.d/nvidia-installer-disable-nouveau.conf.

                                                                 OK
 ERROR: Installation has failed.  Please see the file '/var/log/nvidia-installer.log' 
        for details.  You may find suggestions on fixing installation problems 
        in the README available on the Linux driver download page at www.nvidia.com.

                                                                 OK
  1. nouveau driverをブラックリスト化する。 /etc/modprobe.d/nvidia-installer-disable-nouveau.confを開き、以下を行を挿入する。 すでに、nvidia-installerによって作成されている場合もある。
    blacklist nouveau 
    options nouveau modeset=0 
  2. /etc/grub/confファイルを開き、kernel 行に rdblacklist=nouveau オプションを追加する。
    kernel /boot/vmlinuz-2.6.32-71.29.1.el6.x86_64 ro (続く)
    root=UUID=0ab095d2-83b6-411c-a245-035623352cd4 rd_NO_LUKS rd_NO_LVM (続く)
    rd_NO_MD rd_NO_DM LANG=ja_JP.UTF-8 KEYBOARDTYPE=pc KEYTABLE=jp106 (続く)
    crashkernel=auto rhgb rdblacklist=nouveau quiet
  3. rebootする。

CUDA Toolkitのインストール

CUDAを対話形式でインストール

# sh <CudaInstaller>.run

... ライセンスとかの説明を[retun]や[space]で飛ばす

Do you accept the previously read EULA? (accept/decline/quit): [accept]
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 xxx.xx? ((y)es/(n)o/(q)uit): [yes/no] #注意1
Install the CUDA x.x Toolkit? ((y)es/(n)o/(q)uit): [yes]
Enter Toolkit Location [ default is /usr/local/cuda-x.x ]: [/usr/local/cuda/x.x] #注意2
Install the CUDA x.x Samples? ((y)es/(n)o/(q)uit): [yes]
Enter CUDA Samples Location [ default is /usr/local/cuda/x.x/samples ]: [return]

... なんかエラーがでたら、/tmp/cuda_install_xxxxx.logを確認
  • #注意1: NVIDIA Driverを未インストールならyes、インストール済みならNo。基本yesでOK
  • #注意2: ふんが研の環境ではCUDAのパスを"/usr/local/cuda/x.x"(x.xはCUDAのバージョン)とする。

CUDAをコマンドラインオプションを付けてインストール

CUDAインストーラのオプションは以下の通り。

Options:
   -help               : Print help message
   -driver             : Install NVIDIA Display Driver
   -uninstall          : Uninstall NVIDIA Display Driver
   -toolkit            : Install CUDA x.x Toolkit
   -toolkitpath=<PATH> : Specify path for CUDA location (default: /usr/local/cuda-x.x)
   -samples            : Install CUDA x.x Samples
   -samplespath=<PATH> : Specify path for Samples location (default: /usr/local/cuda-x.x/samples)
   -silent             : Run in silent mode. Implies acceptance of the EULA
   -verbose            : Run in verbose mode
   -extract=<PATH>     : Extract individual installers from the .run file to PATH
   -optimus            : Install driver support for Optimus
   -override           : Overrides the installation checks (compiler, lib, etc)

次のようにオプションを付けて実行。x.xはCUDAのバージョン。

# sh <CudaInstaller>.run \
    -silent \
    -driver \
    -toolkit \
    -toolkitpath=/usr/local/cuda/x.x \
    -samples \
    -samplespath=/usr/local/cuda/x.x/samples

デフォルトのCUDAパスにリンクをはる

他所から拾ってきたソースコードをMakeファイルでコンパイルするときに、 NVIDIAが想定するデフォルトのCUDAパスにリンクがあると何かと便利。

# ln -s /usr/local/cuda/x.x /usr/local/cuda-x.x    # x.xはCUDAのバージョン

CUDAの環境設定

CUDAのパスやらを書いたスクリプトファイルを回す。 スクリプトファイルの例を1つ挙げる。

$ source ./setup_cuda.sh [x.x: CUDAのバージョン]

参考文献

written by mits(2014-12-06)


添付ファイル: filecuda_download.png 109件 [詳細] filenvidia_driver_download.png 140件 [詳細] fileCUDA_2_Quickstart_Guide.pdf 167件 [詳細] filesetup_cuda.sh 154件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2019-08-29 (木) 00:03:47