Remote Development With AWS EC2
Last updated
Last updated
This guide will walk the reader through setting up a remote instance in AWS EC2 and connecting with that instance with the VSCode Remote - SSH extension. This allows users who do not have a compatible local environment to do channel development and can be a good way to ensure your channel will run correctly after being deployed to the platform.
Selecting the right EC2 image, instance, disk space, etc can be a point of confusion. To start configuring a new instance for channel development, sign in to your AWS account, set the region you want to use for the compute, and go to the EC2 dashboard.
The AMI Catalog has several pre-configured instances that will work for channel development. The instance operating system needs to be Linux-based and will need NVIDIA and Docker. In this example, we will use the Ubuntu Deep Learning Base AMI. To find this AMI in the EC2 dashboard, look under Images and navigate the AMI Catalog then search for “nvidia”. After selecting the AMI, click the Launch Instance with AMI button at the top to move on in the setup wizard.
In the “Launch an instance” dialogue, give the instance a name, such as “Channel Development”, and select a an instance type. We recommend selecting an instance that has at least one GPU, for example, an instance from the p or g family.
The majority of channels launched on the Rendered.ai platform use the AWS g4dn.2xlarge instance type.
Next a Key Pair is added so you can connect to the instance locally. If you have not set up a Key Pair in AWS, follow the dialog using all the default options. Download the .pem file and do not loose it! This is your key to accessing instance once it's running.
Finally, you might want to add extra disk space for storing generated images and videos. We recommend adding 100 GB of general purpose storage. AWS has a procedure to move your AMI to an instance with more storage later, but it's easier to add it here.
Now you can launch the instance. The default values for the remaining parameters are appropriate for channel development (generic security group, allow SSH traffic).
After completing the wizard, the instance will begin the launch process. This can take some time depending on the instance type and availability. You will need to wait until your instance is in the Running state with “2/2 checks passed” for the status check.
Billing is calculated from when the instance starts running. Make sure to stop the instance when you are done!
Once the instance is in the “Running” state you can ssh to it using the Public IPv4 address and DNS.
In the above screenshot, the public DNS is circled. Copy this for the configuration of VSCode below. For information about more ways to connect to the instance, including from the command line, follow the Connect button.
It is required the local identity file not be readable by others. On Mac and Linux, the permissions can be set in a shell as follows:
chmod 400 <key name>.pem
For Windows developers, we recommend installing Ubuntu in WSL, the Windows Subsystem for Linux.
From PowerShell, run "wsl --install -d ubuntu"; you’ll have to create a username and password for the new OS.
Find and save the *.pem file from earlier into a directory that can be accessed by WSL Ubuntu.
Update the permissions of the .pem file by rght clicking on it, selecting "Properties" and check "Read-only". Next, under "Security" - "Advanced", select "Disable Inheritance" and for the users, "Remove All". Click "Apply", and your group or user names should be empty. Go back to "Advanced" and add your windows user and apply. Next, in the permissions give all permissions to your user.
Open VSCode and install “Remote - SSH” and “Remote - Containers” extensions. In the following screen shot, the extensions menu is active and the said extensions are found by searching for the keyword “remote”.
To connect to the AMI, update your ssh config file. This can be done right in VS Code by clicking the green box on the bottom left and then “Open SSH Configuration File…”.
This file is in your home directory, ~/.ssh/config. On Windows, you need to restrict the permissions on the ssh config file as described above for the .pem file.
Add an entry to the ssh configuration file as follows:
All the items that are surrounded by angle bracket need to be replaced.
<ami name> is the name of the host, e.g. ‘anadevami’. This can be whatever reminds you of the entry when connecting
<public DNS> is the URL from the AWS dashboard above, it takes the form 'ec2-xx-xx-xx-xx.us-xxx-x.compute.amazonaws.com
'
<key name> is the name you gave the key pair and <key location> is where the .pem file is stored. This might be in Downloads and is safely stored by moving it to the .aws directory in your home directory.
Now you can connect to the instance by using the “Connect to Host…” command in VSCode.
Clicking “Connect to Host…” will then list all the entries in your ssh config file. Select the one you just created.
Watch the lower left green icon to verify VSCode is connected to the host. If you have trouble connecting, the logs can be found in VSCode to run down any issues.
Now you can clone a channel repository and begin development as described here: