Tesla K20cを搭載したCentOS 6.4(64bit版)PCへCUDA5をインストールする手順について記載します。
主なHardware Specは以下のとおりです。
ETSK20-5GERにはディスプレイ出力端子(D-SUB,DVI,HDMIなど)が無いため
UEFIの設定でPrimary DisplayをOn Boardに設定し、ディスプレイはM/B上の
出力端子に接続しています。
以下のような設定でCentOS 6.4(64bit版)インストールをしています。
本稿では個別のパッケージのカスタマイズ設定は行っていません。
またFirewall、SELinuxは共にDisableに設定しています。
CentOS 6.4(64bit版)インストール後の設定について記載します。
インストール直後のKernelバージョンは以下のとおりです。
$ uname -a Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
yum コマンドでアップデートを実行します。
# yum update
アップデート完了後再起動を実行しアップデートしたKernelで起動することを確認します。
# reboot
再起動後のKernelバージョンは以下のとおりです。
$ uname -a Linux localhost.localdomain 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
beatユーザを作成し、sudoにbeatユーザを追加します。
# useradd beat # passwd beat
# /usr/sbin/visudo ...<略> ## user MACHINE=COMMANDS ## ## The COMMANDS section may have other options added to it. ## ## Allow root to run any commands anywhere root ALL=(ALL) ALL beat ALL=(ALL) ALL
CUDAのインストールには直接関係はありませんが、作業をしやすくするため
ntpdとopensshをインストールします。
ntpdをインストールします。
# yum install ntp
ntpサーバを追加します。
# vi /etc/ntp/step-tickers # List of servers used for initial synchronization. ntp.nict.jp ntp.jst.mfeed.ad.jp ntp.ring.gr.jp
ntpdを起動します。
# /etc/init.d/ntpd start
ntpdをサービスに追加します。
# chkconfig --level 3 ntpd on # chkconfig --level 5 ntpd on
opensshをインストールします。
既にインストールされている場合はこの手順はとばしてください。
# yum install openssh
/etc/ssh/sshd_config内のPermitRootLoginと
PermitEmptyPasswordsをnoに設定します。
# vi /etc/ssh/sshd_config ... <略> # Authentication: #LoginGraceTime 2m PermitRootLogin no #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 ... <略> # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes PermitEmptyPasswords no PasswordAuthentication yes ...
sshdを起動します。
# /etc/init.d/sshd start
sshdをサービスに追加します。
# chkconfig --level 5 sshd on # chkconfig --level 3 sshd on
Tesla K20cドライバインストールについて記載します。
Tesla K20cドライバインストールのためにパッケージの追加、設定を行います。
開発用パッケージ、ライブラリ群(Development tools)をインストールします。
# yum groupinstall 'Development tools'
Tesla K20cのドライバ、CUDA5のインストール時にXが起動していると
エラーが起こるため、runlevel 3に変更し再起動を行います。
# vi /etc/inittab ...<略> # Default runlevel. The runlevels used are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: # reboot
再起動後、以下のURLよりNVIDIA-Linux-x86_64-319.23.runをダウンロードします。
http://www.nvidia.co.jp/object/linux-display-amd64-319.23-driver-jp.html
NVIDIA-Linux-x86_64-319.23.runを実行し、ライセンスに同意後インストールが完了します。
インストール完了後/proc/driver/nvidia/にversionファイルが作成されます。(注1)
# chmod +x NVIDIA-Linux-x86_64-319.23.run # ./NVIDIA-Linux-x86_64-319.23.run # cat /proc/driver/nvidia/version NVRM version: NVIDIA UNIX x86_64 Kernel Module 304.54 Sat Sep 29 00:05:49 PDT 2012 GCC version: gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
注1: kernelをupdateし再起動後は、再度ドライバをビルドする必要があります。
これは再起動後nvidia driverが読み込まれず、下記のCUDA5 Samplesが実行されないためです。
参考までに更新後のkernel versionと /proc/driver/nvidia/versionを記載します。
# uname -a Linux tesla.beatcraft.com 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 17:19:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux # cat /proc/driver/nvidia/version NVRM version: NVIDIA UNIX x86_64 Kernel Module 319.23 Thu May 16 19:36:02 PDT 2013 GCC version: gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
以下のURLに記載のあるように起動時ドライバを読み込むためのファイル(/etc/init.d/nvidia)を作成し、
runlevel3,5の起動時に実行するよう設定します。
http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#install-cuda-software
# vi /etc/init.d/nvidia
#!/bin/bash
/sbin/modprobe nvidia
if [ "$?" -eq 0 ]; then
# Count the number of NVIDIA controllers found.
NVDEVS=`lspci | grep -i NVIDIA`
N3D=`echo "$NVDEVS" | grep "3D controller" | wc -l`
NVGA=`echo "$NVDEVS" | grep "VGA compatible controller" | wc -l`
N=`expr $N3D + $NVGA - 1`
for i in `seq 0 $N`; do
mknod -m 666 /dev/nvidia$i c 195 $i
done
mknod -m 666 /dev/nvidiactl c 195 255
else
exit 1
fi
# cd /etc/rc5.d/
# ln -s S99nvidia ../init.d/nvidia
# cd /etc/rc3.d/
# ln -s S99nvidia ../init.d/nvidia
CUDA5のインストールとCUDA5のSamplesについて記載します。
CentOS6 64bit版CUDA(cuda_5.0.35_linux_64_rhel6.x-1.run)を以下のURLから
ダウンロードします。
https://developer.nvidia.com/cuda-downloads
CUDA5のSampleインストール時にPATHが見つからずSampleがインストールされないのを防ぐため、
.bashrcに予めPATHを追加します。
$ cd /home/beat
$ vi .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
export PATH=/usr/local/cuda-5.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib64:/usr/local/cuda-5.0/lib:$LD_LIBRARY_PATH
# source .bashrc
Samplesのビルドで必要な以下のパッケージを予めインストールします。
# yum install freeglut-devel.x86_64 libXi-devel.x86_64 mpich2-devel.x86_64 libXmu-devel.x86_64
cuda_5.0.35_linux_64_rhel6.x-1.run を実行します。
インストール先ディレクトリはデフォルトの/usr/local/cuda-5.0を指定します。
# chmod +x cuda_5.0.35_linux_64_rhel6.x-1.run # ./cuda_5.0.35_linux_64_rhel6.x-1.run
Samplesはデフォルトで/usr/local/cuda-5.0/samplesと/root/NVIDIA_CUDA-5.0_Samplesに
インストールされます。
rootユーザでビルドできるようにld.so.conf.d/cuda.confを追加しldconfigを実行します。
# cat /etc/ld.so.conf.d/cuda.conf /usr/local/cuda-5.0/lib /usr/local/cuda-5.0/lib64 # ldconfig
NVIDIA_CUDA-5.0_Samplesをbeatユーザでビルド、実行できるようにします。
/root/NVIDIA_CUDA-5.0_Samplesからコピーし、オーナーをbeatに変更しmakeを実行します。
# cp -afr /root/NVIDIA_CUDA-5.0_Samples /home/beat/. # cd /home/beat # chown -R beat.beat NVIDIA_CUDA-5.0_Samples $ cd ~/NVIDIA_CUDA-5.0_Samples $ make
ビルド完了後 NVIDIA_CUDA-5.0_Samples/bin/linux/release/に移動し、
NVIDIA CUDA Getting Started Guide for Linuxのページ内Running the Binariesに
記載されているdeviceQuery、bandwidthTestを実行します。
deviceQuery、bandwidthTest共にTesla K20cを用いていることが確認できます。
http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#running-binaries
$ cd ~/NVIDIA_CUDA-5.0_Samples/bin/linux/release/
$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "Tesla K20c"
CUDA Driver Version / Runtime Version 5.0 / 5.0
CUDA Capability Major/Minor version number: 3.5
Total amount of global memory: 4800 MBytes (5032706048 bytes)
(13) Multiprocessors x (192) CUDA Cores/MP: 2496 CUDA Cores
GPU Clock rate: 706 MHz (0.71 GHz)
Memory Clock rate: 2600 Mhz
Memory Bus Width: 320-bit
L2 Cache Size: 1310720 bytes
Max Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536,65536), 3D=(4096,4096,4096)
Max Layered Texture Size (dim) x layers 1D=(16384) x 2048, 2D=(16384,16384) x 2048
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 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
Maximum sizes of each dimension of a block: 1024 x 1024 x 64
Maximum sizes of each dimension of a grid: 2147483647 x 65535 x 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: No
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Enabled
Device supports Unified Addressing (UVA): Yes
Device PCI Bus ID / PCI location ID: 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 5.0, CUDA Runtime Version = 5.0, NumDevs = 1, Device0 = Tesla K20c
$ ./bandwidthTest
[CUDA Bandwidth Test] - Starting...
Running on...
Device 0: Tesla K20c
Quick Mode
Host to Device Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 6431.7
Device to Host Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 6396.1
Device to Device Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 143752.5
deviceQuery、bandwidthTest同様上記手順でビルド済みCUDA Samples内の
simpleMultiCopyとcdpAdvancedQuicksortの実行結果を記載します。
CUDA Samplesについては以下のURLを参照してください。
http://docs.nvidia.com/cuda/cuda-samples/index.html
simpleMultiCopyはデバイスとホストシステム間のデータコピーのスループット、
実行時間を測定するCUDA Sampleです。
cdpAdvancedQuicksortはCUDAのDynamic Parallelismを使用したクイックソートのCUDA Sampleです。
またcdpAdvancedQuicksortはCapability 3.5以上のデバイスが必要です。
CUDA Dynamic Parallelismについては以下のURLを参照してください。
http://www.nvidia.co.jp/object/how-tesla-k20-speeds-up-quicksort-a-familiar-comp-sci-code-jp.html
$ ./simpleMultiCopy
[simpleMultiCopy] - Starting...
> Using CUDA device [0]: Tesla K20c
[Tesla K20c] has 13 MP(s) x 192 (Cores/MP) = 2496 (Cores)
> Device name: Tesla K20c
> CUDA Capability 3.5 hardware with 13 multi-processors
> scale_factor = 1.00
> array_size = 4194304
Relevant properties of this CUDA device
(X) Can overlap one CPU<>GPU data transfer with GPU kernel execution (device property "deviceOverlap")
(X) Can overlap two CPU<>GPU data transfers with GPU kernel execution
(Compute Capability >= 2.0 AND (Tesla product OR Quadro 4000/5000/6000/K5000)
Measured timings (throughput):
Memcpy host to device : 2.510752 ms (6.682148 GB/s)
Memcpy device to host : 2.506624 ms (6.693152 GB/s)
Kernel : 0.502624 ms (333.792593 GB/s)
Theoretical limits for speedup gained from overlapped data transfers:
No overlap at all (transfer-kernel-transfer): 5.520000 ms
Compute can overlap with one transfer: 5.017376 ms
Compute can overlap with both data transfers: 2.510752 ms
Average measured timings over 10 repetitions:
Avg. time when execution fully serialized : 5.544925 ms
Avg. time when overlapped using 4 streams : 2.971430 ms
Avg. speedup gained (serialized - overlapped) : 2.573494 ms
Measured throughput:
Fully serialized execution : 6.051377 GB/s
Overlapped using 4 streams : 11.292350 GB/s
$ ./cdpAdvancedQuicksort
Running on GPU 0 (Tesla K20c)
Running qsort on 5000 elements with seed 100, on Tesla K20c
cdp_quicksort PASSED
Sorted 5000 elems in 0.988 ms (5.062 Melems/sec)
設定完了後のHDDの使用容量は以下のとおりです。
# df -h
Filesystem Size Used Avail Use% マウント位置
/dev/mapper/vg_beattesla-lv_root
50G 4.3G 45G 9% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/sda1 485M 66M 394M 15% /boot
/dev/mapper/vg_beattesla-lv_home
852G 1.4G 808G 1% /home
2013/05/31 初稿掲載
2013/06/01 文言修正
2013/06/07 CUDA5 Samplesのビルドと実行 へCUDA Samples実行例を追記
2013/09/26 項目タイトル「Tesla K20cドライバのダウンロード」を「Tesla K20cドライバのダウンロードとインストール」に変更、注1を追記