ubuntuでCudaを使うまでの準備とchainerを使って GPUに何かを処理させるまでの流れ。

1. Azureにubuntu 16.04LTSをインストール

point

  1. market placeからubuntuを選択、Canonicalのものがおすすめ。

image

サイズの選択:NVシリーズ
image

  1. ssh login

  2. Prerequisite :
    3.1 Driver package installation

#!/usr/bin/env bash

export LC_ALL=C

# Drver installation
wget http://us.download.nvidia.com/tesla/384.81/nvidia-diag-driver-local-repo-ubuntu1604-384.81_1.0-1_amd64.deb
sudo dpkg -i nvidia-diag-driver-local-repo-ubuntu1604-384.81_1.0-1_amd64.deb
sudo apt-key add /var/nvidia-diag-driver-local-repo-384.81/7fa2af80.pub

# module blacklisted
sudo -i
echo -e "blacklist nouveau\noptions nouveau modeset=0\nalias nouveau off" > /etc/modprobe.d/blacklist-nouveau.conf

sudo update-initramfs -u && reboot
#!/usr/bin/env bash
# python installation
sudo apt update
sudo apt -y upgrade
sudo apt -y install python3 python3-pip
echo "alias python=python3" >> ~/.bashrc
echo "alias pip=pip3" >> ~/.bashrc
sudo rm 

# cuda installation
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt update
sudo apt -y upgrade
sudo apt install -y ocl-icd-libopencl1 cuda-drivers nvidia-cuda-toolkit cmake
sudo update-initramfs -u && sudo reboot

Availability check

while :; do nc -z -v -n 52.187.66.133 22; sleep 0.5 ; done

PCI hardware check

lspci -vvv

image

nvidia device check, required nvidia-cuda-toolkit

nvidia-smi

image

nvcc -V

Cuda test

sudo apt -y install cuda-samples-9-0
 cd /usr/local/cuda-9.0/samples/
sudo make #長時間かかるから覚悟
>>> WARNING - simpleGLES_EGLOutput is not supported on Linux x86_64 - waiving sample <<<
>>> WARNING - egl.h not found, please install egl.h <<<
>>> WARNING - eglext.h not found, please install eglext.h <<<
>>> WARNING - gl31.h not found, please install gl31.h <<<

30分くらい?

Cuda benchmark

image

OpenCL benchmark

information

- Cuda Software
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=debnetwork

http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb

- Driver
http://www.nvidia.com/Download/index.aspx?lang=en-us
http://us.download.nvidia.com/tesla/384.81/nvidia-diag-driver-local-repo-ubuntu1604-384.81_1.0-1_amd64.deb

Reference

<img src=”https://user-images.githubusercontent.com/406525/31165794-58f15bb4-a927-11e7-8d88-fb35438778dc.png” width=250>

image