This repository has been archived by the owner on Jun 25, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example script for docker-machine testing with aws
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
# define the following env vars first: | ||
# AWS_ACCESS_KEY_ID | ||
# AWS_SECRET_ACCESS_KEY | ||
# AWS_DEFAULT_REGION | ||
|
||
# Instance types: see https://aws.amazon.com/ec2/instance-types/ | ||
# and pricing: https://aws.amazon.com/ec2/pricing/on-demand/ | ||
|
||
# defaults to --amazonec2-root-siez of 16gbs (16 GB EBS disk storage) | ||
# on a ubuntu-based AMI | ||
|
||
docker-machine create \ | ||
--driver amazonec2 \ | ||
--amazonec2-instance-type p2.xlarge \ | ||
aws-gpu | ||
|
||
docker-machine restart aws-gpu | ||
docker-machine ssh aws-gpu | ||
|
||
sudo usermod -aG docker $USER | ||
|
||
# Install official NVIDIA driver package | ||
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub | ||
sudo sh -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/cuda.list' | ||
sudo apt-get update && sudo apt-get install -y --no-install-recommends linux-headers-generic dkms cuda-drivers | ||
|
||
# Add the package repositories | ||
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ | ||
sudo apt-key add - | ||
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) | ||
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \ | ||
sudo tee /etc/apt/sources.list.d/nvidia-docker.list | ||
sudo apt-get update | ||
|
||
# Install nvidia-docker2 and reload the Docker daemon configuration | ||
sudo apt-get install -y nvidia-docker2 | ||
sudo pkill -SIGHUP dockerd | ||
|
||
# Add the nvidia-docker 2.0 package repositories | ||
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ | ||
sudo apt-key add - | ||
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) | ||
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \ | ||
sudo tee /etc/apt/sources.list.d/nvidia-docker.list | ||
sudo apt-get update | ||
|
||
# Install nvidia-docker2 and reload the Docker daemon configuration | ||
sudo apt-get install -y nvidia-docker2 | ||
sudo pkill -SIGHUP dockerd | ||
|
||
# Test nvidia-smi with the latest official CUDA image | ||
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi |