32

Run Deep Learning Containers on AWS with One Command

 5 years ago
source link: https://www.tuicool.com/articles/hit/uQ3MBny
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
yuIFNbf.jpg!web

There are many publicly available Docker images like TensorFlow , PyTorch , Jupyter Docker Stacks or AWS Deep Learning Containers that can be used for training deep learning models.

With Spotty you can run Docker containers on AWS with just one command. Spotty manages for you all necessary AWS resources including volumes, snapshots and SSH keys, synchronizes local project with the instance and uses tmux to detach remote processes from their terminals.

All you need to have is one configuration file called spotty.yaml in the root directory of your project.

Installation

Requirements:

Use pip to install or upgrade Spotty:

pip install -U spotty

Configuration File

A configuration file describes parameters of an EC2 instance and parameters of the Docker container that will be used as an environment for your project. Here is an example:

MzUVvue.jpg!web

With the configuration above, Spotty will run an On-Demand p2.xlarge instance in the us-east-2 (Ohio) region. Feel free to change this configuration: for example, you could change the image parameter to pytorch/pytorch:latest to run a PyTorch container.

If you want to start a Spot instance instead of an On-Demand one, remove the onDemandInstance parameter. To find a region with the lowest price for a chosen instance type, use the spotty aws spot-prices -i <INSTANCE_TYPE> command.

Read more about configuration in the documentation .

Starting the Container

Once you have a spotty.yaml file in the project’s directory, you can start the container using the following command:

spotty start

This command will start an EC2 instance, synchronize your local project with the instance and run the container.

faA7zie.png!web

Use the spotty ssh command to connect to the container.

Don’t forget to stop the instance later using the spotty stop command!

AWS Deep Learning Containers

AWS Deep Learning Containers are Docker images pre-installed with deep learning frameworks that are optimized for the highest performance:

AWS DL Containers include AWS optimizations and improvements to the latest versions of popular frameworks, like TensorFlow and Apache MXNet, and libraries to deliver the highest performance for training and inference in the cloud. For example, AWS TensorFlow optimizations allow models to train up to twice as fast through significantly improved GPU scaling.

Docker images are available in Amazon ECR. Here you can find a list of image URLs that can be used in a Spotty configuration file.

To run AWS DL Containers, the instance should have access to Amazon ECR:

  1. Use the managedPolicyArns parameter to attach the arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess policy to the instance role.
  2. Use the commands parameter to login to Amazon ECR before the container is run: $(aws ecr get-login --no-include-email --region us-east-2 --registry-ids 763104351884) .
MzUVvue.jpg!web

Make sure that the region in the name of the image and the region in the login command matches the region parameter.

Conclusion

Spotty is a fast and easy way to train deep learning models on AWS using Docker containers. It will save you time on managing AWS resources and will help with the workflow by syncing the project with the instance, running custom remote scripts and using tmux to detach remote processes.

If you enjoyed this post, please star the project on GitHub and share this post with your friends.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK