Skip to content
ProGamerGov edited this page Oct 11, 2019 · 19 revisions

If you have a Windows PC, but it lacks the hardware necessary to run the programs/projects you want to use (ex: neural-style-pt), then this guide will help you use an AWS server like many artists in your position do.


Computer Setup

  • What you need to do on your PC.

AWS Account Creation

  • Create an AWS account.

Ubuntu AMI Selection

  • Select an AMI in your desired region.

Saving Your Newly created AMI

  • Every time you boot it up after it's saved, it will be exactly as it was when you saved it. So don't worry about breaking thing once it's saved, because your mistakes aren't going to be saved.

Loading A Saved AMI

Terminating/Stopping Your AMI From Running

  • Always stop/terminate an AMI/server that's running, when you aren't using it! It costs money to keep it running!

Miscellaneous


Driver Stuff



Computer Setup

First download and install WinSCP: https://winscp.net/eng/download.php

PuTTY Setup

Open up this link to download PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Then scroll down to "putty.exe (the SSH and Telnet client itself)", and download either the 32bit or 64bit versions of PuTTY.exe (depending on your OS):

PuTTY

Navigate to:

C:\Program Files

And create a folder called PuTTY:

C:\Program Files\PuTTY`

Place putty.exe in this folder:

C:\Program Files\PuTTY\PuTTY.exe

It is possible to setup a Ubuntu AMI with a desktop GUI on AWS, and then you use some software that lets you use it like a normal home desktop PC remotely, but that is outside of the scope of this guide. A desktop GUI would also take away precious GPU resources from the projects you want to run. So, this is why we use WinSCP with the PuTTY terminal.

AWS Account Creation

If you do not have an AWS already, go to https://aws.amazon.com/, and click on "My Account" on the top right, and then select "AWS Management Console". Then create an account and sign in.

REMEMBER TO MAKE SURE THAT YOU HAVE NOT LEFT YOUR AMI RUNNING WHEN NOT USING IT, BECAUSE YOU ARE PAYING BY THE MINUTE/HOUR!

AMI Selection

Use this site to find the desired Ubuntu version in the region (zone) you want: https://cloud-images.ubuntu.com/locator/ec2/

Pick your region based on wherever you think is cheapest and not whatever is closest to you. Make sure the region you pick has "p2.xlarge" spot instance available!

  • p2.xlarge spot request instances have a single Tesla K80 GPU with 12GB of memory. They normally cost around $0.20-$0.30 per hour, depending on the region you pick.

  • p2.8xlarge spot request instances have 8 Tesla K80 GPUs with 12GB of memory each. They normally cost around $2-$5 per hour, depending on the region you pick.

If you make your AMI in one region and later find out it's cheaper in another region, you can just copy your completed AMI to that cheaper region.

Then click on the "AMI-ID" of the AMI you want and it will take you to AWS' site. You are looking for an AMI that has: hvm:ebs-ssd under "Instance Type", and amd64 under "Arch".

I chose a Ubuntu 16.04 AMI for this guide (for compatibility reasons), but setup is the same for other Ubuntu versions.

When you click on the links under AMI-ID, you'll be taken to this page (if you are already signed into AWS):

1_step

Click on "all Instance types" from the top left and select "GPU instances":

2_step

You'll now be shown this screen:

3_step

Scroll down and select "p2.xlarge" and then click "Next: Configure Instance Details":

4_step

You'll now see this page:

5_step

Click on the "Request Spot instances" checkbox, and put some like $1 for the "Maximum price", then click "Next: Add Storage":

6_step

You'll now see this page:

7_step

Change 8GB to something higher, like 32GB or 64GB, then click "Next: Add Tags":

8_step

Ignore this page. Click "Next: Configure Security Group":

9_step

You'll now see this page:

10_step

Under "Source" change "custom" to "My IP", then hit "Review and Launch":

11_step

Make sure everything looks good, and the click "Launch":

12_step

If you don't have an existing Key Pair, now is the time to create a new one: 13_step

Give your new key pair a name, and then download it:

14_step

Open up WinSCP:

15_step

Add "ubuntu" to the "User name" section, and then select advanced:

16_step

You'll now see WinSCP's advanced settings window:

17_step

Navigate to "authentication" by clicking the option on the left side of the window. Then click the 3 dots under the private key input section:

18_step

Now navigate to and select your private key that you previously downloaded from AWS:

19_step

Select "Yes" for converting your private key to PuTTY's format:

20_step

Save the newly converted private key:

21_step

Click "Okay":

22_step

Click "Okay":

23_step

Now select "Save" and you'll see this screen:

24_step

Give your new session a name:

25_step

Now go back to AWS and make sure that you have selected the key pair that you made, then click "Request Spot Instances":

26_step

You'll now see this screen. Click "View Spot Requests" on the right:

27_step

You'll now see this screen:

28_step

Click on "Instances" on the right hand side:

29_step

You'll now see this screen. Click on your instance:

30_step

Scroll down and look at the information in the bottom bar:

31_step

Copy the public IPv4 address:

32_step

And put that IPv4 address in your WinSCP session's Hostname:

33_step

Now you'll see this screen. Click "Login":

34_step

Once your AMI is fully booted, WinSCP will give you this message. Click "Yes":

35_step

You'll now see this screen. You can easily move files back and fourth between your computer and the AMI/server by simply dragging them from the left/right window in WinSCP to the other window in WinSCP. WinSCP does not automatically check for new files and other changes, so you'll have to use the green arrows at the top to refresh it when creating new files like images:

36_step

Now click the two tiny PC screens with a lightning bolt in between them on the top left of WinSCP:

35-putty

PuTTY should automatically boot up and login to your AMI. If there's a key warning message, click "Yes":

37_step

Sometimes AMIs can have issues when you first boot them, so I like to test for that with a simple and useless sudo apt-get install time command:

38_step

This is the main issue I was checking for:

ubuntu@ip-Address:~$ sudo apt-get install time
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Even if that command doesn't have any issues, it's still a good idea to reboot just encase. You should do this every time you boot up your AMI:

39_step

After you run the reboot command, PuTTY will stop working and give an error, letting you know it lost connection. Close the PuTTY window:

40_step

WinSCP will keep looking for the server until it's rebooted. If it stops, you can make it start again:

41_step

Now you can install whatever you want on your sever/AMI for later. If you wish to install neural-style-pt, check out the installation guide here: https://github.com/ProGamerGov/neural-style-pt/blob/master/INSTALL.md

I recommend the Github and pip or just simply the pip guide for installing neural-style-pt.

If you run into issues installing things, other people have probably run into those errors as well. So, use a search engine and see if anyone has posted how they fixed the issue.

Saving your AMI for later:

Once you have installed everything that you want on your AMI, you now need to save it. Every time you load up the AMI, it will be exactly like it was when you saved it. Nothing is saved unless you create a new AMI from the current AMI.

On the AWS console page, right click on your instance and navigate to "Create Image":

42_step

You'll now see this page. Make sure there's enough storage space:

43_step

Give the Image a name and description, so that you will know what it contains in the future. Then click "Create Image" in the bottom right:

44_step

You'll now see this page. Click "Close":

45_step

Your AMI is now saved!

Loading a saved AMI

Click on "AMIs" on the left panel:

46_step

Right click on the AMI that you want to launch and select "Spot Requests":

47_step

Now, when you start up your saved instance, it's pretty much just like before, only you don't have to make a new key pair:

48_step

You do however have to replace the Hostname in your WinSCP session with the new IPv4 address from your newly launched spot request.

Stop AMI from running

If your AMI has previously been saved, terminating it will not delete it. You will only loose whatever you have done since saving/booting up your AMI.

On the Instances page, right click on your currently running AMI and select "Terminate": 49_step

You'll now see this page. Select "Yes, Terminate": 50_step


Miscellaneous

If you ever end up on this AWS Console page:

51_step

Simply click on "EC2".


Driver Issues Updating/Fixing/Installation:

I found the CUDA driver installation guide from here to be useful for installing/updating drivers for PyTorch: https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu/1077063#1077063

There may be better or more applicable guides elsewhere for drivers, but you'll have to search for them.