LoginSignup
1
2

More than 1 year has passed since last update.

Azure Virtual Machine でGPU使ってみる備忘録

Last updated at Posted at 2021-07-24

概要

Azure のVirtual Machine で割とハイスペックのGPUを使ってみたかったので、
設定など試してみた。

GPUスペック

A100 だと月額300万円くらいかかるみたいです。
V100 だと月額30万円くらい。
ケチってK80 とかだと5万円くらいだけどあまり旨味がない気も。。

https://qiita.com/Never_/items/3dfcc8cf5c2765832c74
このあたりを見るに、単純にpython使ってデータ扱うならgoogle colab proが明らかにお得とおもわれ。。

C++ cuda とかを触りたい時はcolabだと難しい??

試したもの

V100を試してみました。
月額30万円で1時間約500円程度です。
(そこそこのプレッシャーを感じながら開発できますね、、)

使用したインスタンスタイプとスペックは以下の通り。

サイズ   vCPU    メモリ:GiB   一時ストレージ (SSD) GiB GPU GPU メモリ: GiB  最大データ ディスク数 キャッシュが無効な場合の最大ディスク スループット: IOPS/MBps    最大 NIC 数
Standard_NC6s_v3    6   112 736 1   16  12  20000/200   4

nvidia-smi をするまで

ここをフォローしましょう。
https://docs.microsoft.com/ja-jp/azure/virtual-machines/linux/n-series-driver-setup

叩くコマンドはこの通り。

setup_gpu.sh
CUDA_REPO_PKG=cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
wget -O /tmp/${CUDA_REPO_PKG} https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/${CUDA_REPO_PKG}

sudo dpkg -i /tmp/${CUDA_REPO_PKG}
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
rm -f /tmp/${CUDA_REPO_PKG}

sudo apt-get update
sudo apt-get install cuda-drivers

このあと、

sudo apt-get install cuda

これで

nvidia-smi

にて

Sat Jul 24 07:41:37 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.57.02    Driver Version: 470.57.02    CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla V100-PCIE...  Off  | 00000001:00:00.0 Off |                    0 |
| N/A   30C    P0    36W / 250W |      0MiB / 16160MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

となりました。

おまけ

CMake install

cmake のバージョンを指定してインストールするのにいつもググっている気がするので残しておきます。

openssl が依存関係です。

以下、ワンライナーインストール。

get_cmake.sh
sudo apt-get update
sudo apt-get install -y libssl-dev
export CMAKE_VERSION=3.17.1
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && tar -zxvf ./cmake-${CMAKE_VERSION}.tar.gz && \
    cd cmake-${CMAKE_VERSION} && \
    ./bootstrap && make -j4 && sudo make install

profiler の設定

sudo apt-get install google-perftools libgoogle-perftools-dev kcachegrind

gmp の設定

Stable なバージョンのワンライナーインストール、決めましょう。

get_gmp.sh
sudo apt-get update
sudo apt-get install g++ m4 zlib1g-dev make p7zip -y
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz
tar -xvf gmp-6.1.2.tar.xz
cd gmp-6.1.2
sudo ./configure --enable-cxx
sudo make -j4
sudo make install

boost の設定

sudo apt-get install libboost-all-dev -y

No CMAKE_CUDA_COMPILER could be found. への対応

cmake するときに以下のオプションを付与。

-DCMAKE_CUDA_COMPILER=/usr/local/cuda-11.4/bin/nvcc
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2