Skip to content

AWS EC2 ML instance setup

Scott Came edited this page Jun 24, 2018 · 13 revisions

Steps for setting up an AWS EC2 instance for Docker+R+Keras

Based loosely on: https://github.com/NVIDIA/nvidia-docker (docker setup)

After launching a p2.xlarge instance...

Set up Docker

Original instructions: https://docs.docker.com/install/linux/docker-ce/ubuntu/

  1. sudo apt-get update
  2. sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
  3. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  4. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  5. sudo apt-get update
  6. sudo apt-get install docker-ce
  7. sudo groupadd docker
  8. sudo usermod -aG docker $USER

Test: $ docker run hello-world

Install NVIDIA drivers

Original instructions: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-nvidia-driver.html#obtain-nvidia-driver-linux

  1. sudo apt-get upgrade -y linux-aws
  2. sudo reboot

(wait for reboot)

  1. sudo apt-get install -y gcc make linux-headers-$(uname -r)
  2. cd /tmp
  3. curl -O http://us.download.nvidia.com/tesla/384.145/NVIDIA-Linux-x86_64-384.145.run
  4. sudo /bin/sh ./NVIDIA-Linux-x86_64-384.145.run
  5. rm NVIDIA-Linux-x86_64-384.145.run
  6. sudo apt-get remove --purge -y gcc make linux-headers-$(uname -r)
  7. sudo apt-get autoremove -y
  8. sudo apt-get autoclean -y
  9. sudo reboot

(wait for reboot)

Test driver install: $ nvidia-smi

Setup NVIDIA Docker runtime

Original instructions: https://github.com/NVIDIA/nvidia-docker

  1. curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
  2. distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
  3. curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
  4. sudo apt-get update
  5. sudo apt-get install -y nvidia-docker2
  6. sudo pkill -SIGHUP dockerd

Test: sudo nvidia-container-cli --load-kmods info And: docker run --rm --runtime=nvidia -ti nvidia/cuda

Clone this wiki locally