LoginSignup
3
6

More than 5 years have passed since last update.

AWS上でnvidia-dockerを使った機械学習環境を作る備忘録

Posted at

私はDockerをよく使い、個人としてのソースコードの管理をCodeCommitで行っています。
仕事で利用するPCはGPUを搭載していないため、AWS上にGPUリソースが使える環境を使って学習させています。

どのように環境作成したかを忘れないための私による私のための記事です。

環境

  • rootユーザーで実行
  • AMI(Deep Learning Base AMI (Ubuntu) Version 3.0 (ami-de1476b8))
  • 利用するAWSサービス
    • IAM
    • CodeCommit
  • docker
    • nvidia-docker2
    • docker-compose(1.19.0-rc3)

機械学習関連の環境作成

リポジトリ設定

apt-get -y install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

apt-get update

dockerインストール

apt-get -y install docker-ce

docker-composeのインストール

curl -L https://github.com/docker/compose/releases/download/1.19.0-rc3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

nvidia-docker2のインストール

curl -L https://nvidia.github.io/nvidia-docker/gpgkey |apt-key add -

tee /etc/apt/sources.list.d/nvidia-docker.list <<< \
"deb https://nvidia.github.io/libnvidia-container/ubuntu16.04/amd64 /
deb https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64 /
deb https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64 /"

apt-get update
apt-get install -y nvidia-docker2
pkill -SIGHUP dockerd

ソースコード管理

CodeCommitとの連携

apt-get install -y git
git config --global credential.helper '!aws --region ap-northeast-1 codecommit credential-helper $@'
git config --global credential.UseHttpPath true

EC2に紐付いているIAMの設定

  • IAMSelfManageServiceSpecificCredentials
  • AWSCodeCommitFullAccess
  • IAMReadOnlyAccess

参考にさせていただいた記事

関連する自身の記事

3
6
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
3
6