私は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