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.
Configuring an EC2 Instance
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.
Select an AMI
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 Docker installed. In this example, we will use the Ubuntu Deep Learning AMI that already has Docker and NVIDIA-Docker installed. To find this AMI in the EC2 dashboard, look under Images and navigate the AMI Catalog then search for “docker”. 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 instance an instance from the p or g family.
The majority of channels launched on the Rendered.ai platform use the AWS p2.xlarge instance type. If you do choose this instance type, you will need to install an older driver version to get the GPU to work appropriately. See this StackOverflow for more guidance – choose the right driver file by visiting https://www.nvidia.com/download/index.aspx.
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.
Now you can launch the instance. The default values for the remaining parameters are appropriate for channel development (generic security group, allow SSH traffic, and no extra storage).
Launch the Instance
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.
Connect to the Instance in VSCode
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…”. For Linux developers, this file is in your home directory, ~/.ssh/config.
Add an entry to the ssh configuration file as follows:
Host <ami name> HostName <public DNS> IdentityFile <key location>/<key name>.pem User ec2-user
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 '
<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.
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
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.
Each time you stop and start your EC2 instance, a new address may be assigned. To trouble shoot connection issues, try to ssh to the instance from a terminal:
ssh -i ~/.aws/mykey.pem email@example.com
Congratulations, you can now clone a channel repository to the instance to get started developing your channel with AWS EC2!