GuidesDiscussionChangelogLog In

Using Gigantum With AWS EC2 and Docker Machine

Here we demonstrate how to use Docker Machine to set up an EC2 instance for using Gigantum in the cloud. The Docker Machine command uses the variables <instance-type> and <instance-name>. The first should be a recognized EC2 instance type, such as p2.xlarge, that your have actual permissions to use. The second variable can be whatever name you decide to give the instance.

We also include some optional instructions for how to setup and configure a p2.xlarge instance to do deep learning workflows in the cloud using Gigantum. This is the cheapest instance we recommend for doing basic work or for demonstration purposes.

Setting up AWS credentials for command line use

  1. If you don't have the appropriate credentials to create an AWS instance, you will need to create an AWS account and create a new access-key-id and your secret-access-key. Note that you can only get the secret access key at the time of creation - so be sure to keep it somewhere safe.

  2. Install the AWS command line interface

  • On Linux/macOS run pip3 install awscli --upgrade --user
  • On Windows 10 you can also use the MSI Installer
  1. To create an EC2 instance you need your AWS access-key-id and your secret-access-key. If you have those, type aws configure into your terminal and a prompt will appear for you to enter your information for command line use. You do not need to enter anything for the default region or output format.
    AWS Access Key ID [None]: access-key-id
    AWS Secret Access Key [None]: secret-access-key   
    Default region name [None]:   
    Default output format [None]:

More information about aws access keys

Installing Docker Machine locally and using it to set up the EC2 instance

  1. If you haven't already, install Docker Machine locally.
  • On macOS and Windows if you have Docker installed then Docker Machine is already installed.
  • On Linux you still need to install it , even if you have Docker installed.
  1. Create an instance
  • On macOS + Linux use the following command
    docker-machine create --driver amazonec2 \  
    --amazonec2-ami  ami-0a313d6098716f372 \  
    --amazonec2-instance-type p2.xlarge \  
    --amazonec2-region us-east-1 \  
    --amazonec2-root-size 64 \  
  • On Windows in a Powershell use the following command.
    docker-machine create --driver amazonec2 `  
    --amazonec2-ami  ami-0a313d6098716f372 `  
    --amazonec2-instance-type p2.xlarge `  
    --amazonec2-region us-east-1 `  
    --amazonec2-root-size 64 `  


If creating this instance is unsuccessful, please ensure that your keys are correct and that they are associated with sufficient permissions to create a p2.xlarge. If you've never used a p2.xlarge you may need to request access to one from AWS.

Using Docker Machine to log in and configure the EC2 instance

  1. Log in to the instance
    docker-machine ssh <name-of-instance>

  2. Add your user to the docker group
    sudo usermod -aG docker $USER

  3. Add graphics repository (Optional)
    If you wish to add GPU support to your AWS instance you may also want to add the graphics repository so that later the drivers can be installed. This can be done with the following command:
    sudo add-apt-repository -y ppa:graphics-drivers/ppa

  4. Logout by pressing ctrl+d

Adding GPU Support

  1. Login to the instance
    docker-machine ssh <name-of-instance>

  2. Install Nvidia GPU drivers

    sudo apt-get install -y linux-aws nvidia-headless-430 nvidia-utils-430
  3. A menu should appear (if not, just go to the next step)
    select Install the package maintainer's version and hit enter

  4. Install Nvidia Docker drivers

    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

    followed by

    sudo apt-get update
    sudo apt-get install -y nvidia-docker2
  5. Logout by pressing crtl+d and then restart the instance with
    docker-machine restart <name-of-instance>

Install Gigantum CLI

  1. Login to the instance
    docker-machine ssh <name-of-instance>

  2. Install pip3 and Gigantum using.

    sudo apt-get install -y python3-pip
    pip3 install --user gigantum
  3. Press ctrl+d to logout and re-login by entering:
    docker-machine ssh <name-of-instance>

  4. Install Gigantum using
    gigantum install

  5. Logout and stop the instance by pressing ctrl+d and then entering:
    docker-machine stop <name-of-instance>

At this point you have a configured machine that is stopped that will cost a few pennies per month for storage. Going forwards, you can re-use this machine starting with the instructions below.

Starting Gigantum on and AWS Instance

  1. Start the instance by using
    docker-machine start <name-of-instance>

  2. remotely access the instance with port forwarding by entering
    docker-machine ssh <name-of-instance> -L 10000:localhost:10000

  3. Start Gigantum by using gigantum start .
    Since the program is running on a different machine, you'll need to enter https://localhost:10000 in your browser manually.

Stopping Gigantum on an AWS instance

  1. Exit Gigantum by entering:
    gigantum stop

  2. logout of the instance using ctrl+d

  3. In your local terminal, stop the instance
    docker-machine stop <name-of-instance>

Managing AWS instance with Docker Machine

  • Check what is running with docker-machine ls.
  • Start the instance with docker-machine start <name-of-instance>.
  • Reboot the instance with docker-machine restart <name-of-instance>.
  • Stop the instance with docker-machine stop <name-of-instance>.
  • ssh into the instance with docker-machine ssh <name-of-instance>.
  • ssh instance and forward port 10000 with docker-machine ssh -L 10000:localhost:10000