のんびりしているエンジニアの日記

ソフトウェアなどのエンジニア的な何かを書きます。

Ubuntu14.04 ServerでCUDA 6.5.14の環境を整える

Sponsored Links

皆さんこんにちは
お元気ですか。私は元気です。

さて、今日はUbuntu 14.04 ServerでCUDAの環境を整えようと思います。
何やらapt-getを使う方法がweb上では沢山見受けられますが、今回はrunを使ってインストールしてみます。

環境

OS:Ubuntu 14.04 Server LTS
CPU:Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
GPU:GeForce GTX 970

sudo apt-get install build-essential

Driverについては別のversionを利用したいので、extractを使ってDriver ,Tool kit,Sampleを分離します。

wget http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_linux_64.run
sudo a+x ./cuda_6.5.14_linux_64.run
./cuda_6.5.14_linux_64.run -extract=/home/user/ndivia_installers

nouveauに邪魔されておそらく動作しないと思います。インストールできたら幸せです。下手にやるとこんなメッセージも出ます。

Unable to load the kernel module 'nvidia.ko'.  This happens most frequently when this kernel module was built against the wrong or
         improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if a driver
         such as rivafb, nvidiafb, or nouveau is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics
         device(s), or no NVIDIA GPU installed in this system is supported by this NVIDIA Linux graphics driver release.

         Please see the log entries 'Kernel module load error' and 'Kernel messages' at the end of the file '/var/log/nvidia-installer.log'
         for more information.

ということでこのnouveauを無効化します。

nouveauの無効化

まずは、ファイルを編集します。

vim /etc/modprobe.d/blacklist-nouveau.conf

以下の文字を記載してください。

blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

次にoptionを追加

echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf

更新する

update-initramfs -u
reboot

Install

cd nvidia_installers
sudo ./cuda-linux64-rel-6.5.14-18749181.run
sudo ./cuda-samples-linux-6.5.14-18745345.run
sudo ./NVIDIA-Linux-x86_64-340.29.run

※ドライバが新しいものが必要な場合は公式から取得します。
NVIDIAドライバダウンロードのページから取得してください。
実行方法は同じです。

Sample

cd /usr/local/cuda/samples/1_Utilities/deviceQuery
make
./deviceQuery