(We know you won't read until the very bottom once your assignment is running, so we are printing this at the top too since it is super important)
Don't forget to stop your instance when you are done (by clicking on the stop button at the top of the page showing your instances), otherwise you will run out of credits and that will be very sad. :(
If you follow our instructions below correctly, you should be able to restart your instance and the downloaded software will still be available.
For the class final project, we offer an option to use Google Compute Engine for developing and testing your implementations. This tutorial lists the necessary steps of working on the assignments using Google Cloud. We expect this tutorial to take a little while. Don't get intimidated by the steps, we tried to make the tutorial detailed so that you are less likely to get stuck on a particular step. I will open a discussion section on Canvas for students who are having problem setting up their account.
You will receive an email from me with a link to redeem your $50 credit (If $50 ends up not being enough, I will try to adjust this number as the semester goes on). When clicking that link you will be sent to a webpage where you will be requuired to enter your full name and email. You must use your UTK email. Note that the domain name is already placed there for you (can change between @utk.edu and @vols.utk.edu.)
This email should be sent relatively quickly. If you do not find it in your main inbox look for it in your spam folder. Once you recieve this email you will be asked to click an additional link to verify your email. This in turn will send you an additional email with your $50 credit. Simply click on this link and you will be sent to a webpage where you simply have to agree to the terms and conditions. That's it. You've created your Google Cloud Platform (GCP) account.
Note that at some point you will see a bar on the top allowing you to actiave $300 of credit since you are a new user. Feel free to do so, alothugh that requires you to insert a credit card (They say it will not be charged but I'm not 100% sure how it works). More details about that can be found in te bottom of this page.
You should now be able to go to the main dashboard by clicking on the "Google Cloud Platform" banner. Notice that through this tutorial all the menu options can be reached through the hamurger button on the top left.
Your account typically does not come with GPU quota. Please request the quota increase ASAP, because they will take up to a week to process! If you don't have GPU quota, you will have to create a CPU-only VM first and create another GPU VM later, explained in the next section.
Before you request a GPU you check that you have a default zone and region set under Compute Engine > Settings > Region / Zone. Please set these to be us-east1 and one of the zones, and then try again.
You have to explicitly request for it under IAM Admin >Quotas. Follow the instructions at:
-
Step-by-step GPU-specific walk-through (all answers in the link are useful)
- Go to this gcloud marketplace. You may (or may not) be taken to a page where you have to click on "Launch in Compute Engine", and then you should see a configuration sheet with the title "New Deep Learning VM deployment".
- Fill in
Deployment namefield with your preferred VM name. - In
Machine typefield, change2 vCPUsto1 vCPU. You can always add more CPUs later if necessary. - In
GPUsfield, you can follow one of the two paths:- (a) If you have successfully requested GPU quota, you should set
Number of GPUsto1. GPU drivers and CUDA will be automatically installed only if you select at least 1 GPU. It's better to do it this way, so wait for this step until you have receievd an your quota. - (b) If you don't have GPU quota yet, you must set
Number of GPUstoNone. WARNING: GPU drivers and CUDA will NOT be installed. All libraries will be CPU only. Once your GPU quota increase request is approved, you can follow path (a) to deploy a GPU-enabled image.
- (a) If you have successfully requested GPU quota, you should set
- In
Frameworksfield, make sureTensorFlow Enterprise 2.1 (Intel optimized ...)is selected. - Check the box
Install NVIDIA GPU driver automatically on first startup?. - Check the box
Enable access to JupyterLab via URL instead of SSH. (Beta)if you would like to try and set that up. - Leave all other options as default.
- Click the blue botton
Deployat the end of the page.
Your configuration sheet should look similar to below:
Once you click deploy you will have to wait a while till everything gets set up (a few minutes). In the meantime you will see a screen saying that it is being deplyed. Once it has completed you will see a message that it was deployed successfullly(do not worry about the warnings). Note that this may fail due to not having enough resources. You may be able to change your zone to a different one to fix that.
Your virtual machine is now running. You can always see all of your runnning virtual machines at: Compute Engine > VM Instances. This screen allows you to start and stop your instance. It also allows you to open a browser window to directly ssh into yout machine.
You can always change number of CPUs, number of GPUs, CPU memory, and GPU type after your VM has been created.
- You must stop the instance first.
- Go to your VM instance's details at Compute Engine > VM instances > [click on instance name]. Click "edit" on your VM's page.
- In
Machine typebox, clickCustomize. - Set
Number of GPUstoNoneif you don't need GPUs. - For
GPU type,NVIDIA Tesla K80is typically enough for most of our assignments.P100andV100are way more expensive, but also faster. - Scroll all the way down and click
Savebutton. - Start your instance again.
Now that you have created your virtual GCE, you want to be able to connect to it from your computer. The rest of this tutorial goes over how to do that using the command line. First, download the Google Cloud SDK that is appropriate for your platform from here and follow their installation instructions. NOTE: this tutorial assumes that you have performed step #4 on the website which they list as optional.
If gcloud command is not in system path, you can also reference it by its full path /<DIRECTORY-WHERE-GOOGLE-CLOUD-IS-INSTALLED>/bin/gcloud. See this page for more detailed instructions.
To ssh into your VM, go to your VM instance details page by clicking on its name. Under Remote access at the top of the page, you may either click directly on SSH which will launch a new browser window with the SSH session, or click on the drop-down arrow and select View gcloud command instead to retrieve the terminal command. It should look like
gcloud compute --project "<YOUR_PROJECT_ID>" ssh --zone "us-west1-b" "<YOUR_VM_NAME>"You can transfer the files from GCP instance to your local laptop. There is an easy command for this purpose:
gcloud compute scp <user>@<instance-name>:/path/to/assignment1.zip /local/path
For example, to download files from our instance to the current folder:
gcloud compute scp tonystark@cs231:/home/shared/assignment1.zip .
The transfer works in both directions. To upload a file to GCE:
gcloud compute scp /my/local/file tonystark@cs231:/home/shared/
Don't forget to stop your instance when you are done (by clicking on the stop button at the top of the page showing your instances). You can restart your instance and the downloaded software will still be available.
We have seen students who left their instances running for many days and ran out of credits. This includes code development time. We encourage you to read up on Google Cloud, regularly keep track of your credits and not solely rely on our tutorials.
The follwing describes some extra constumization information from Stanford's CS231n: Convolutional Neural Networks for Visual Recognition. I have not tried any of this and will only be able to offer minimal assistance. It mostly relates to actiavting your $300 credit and activating jupyter notebooks. If you are not worried about that then you are basically done.
Enter the requested information (your name, billing address and credit card information). Remember to select "Individual" as "Account Type":
Once you have entered the required information, press the blue Start my free trial button. You will be greeted by a page like this:
Click the "Google Cloud Platform" (in red circle), and it will take you to the main dashboard:
To change the name of your project, click on Go to project settings under the Project info section.
- You must stop the instance first.
- Go to your VM instance's details at Compute Engine > VM instances > [click on instance name]. Click "edit" on your VM's page.
- Select "Allow HTTP traffic" and "Allow HTTPS traffic".
- Scroll all the way down and click the blue button "save".
- Go to Firewall config page.
- Click "CREATE FIREWALL RULE"
- Give it an arbitrary name, such as
cs231n. - In
Targetsfield, selectAll instances in the network. - In
Source IP ranges, enter0.0.0.0/0. - In
Protocols and portsfield, select "Specified protocols and ports". Then checktcpand enter7000-9000. - Click the blue button
Create. - Restart your instance on the Compute Engine page.
Your configuration sheets should look similar to below:
Firewall Rules:
After you SSH into the VM for the first time, you need to run a few commands in your home directory. You will be asked to set up a password for your Jupyter notebook.
git clone https://github.com/cs231n/gcloud.git
cd gcloud/
chmod +x ./setup.sh
./setup.shIf you have GPU enabled, you should be able to:
- run
nvidia-smiand see the list of attached GPUs and their usage statistics. Runwatch nvidia-smito monitor your GPU usage in real time. - inside the
gcloud/folder, runpython verify_gpu.py. If your GPU is attached and CUDA is correctly installed, you shouldn't see any error. - If you want to use Tensorflow 2.0, run
python test_tf.py. The script will show you the installed Tensorflow version (2.0.0-alpha) and then run a sample MNIST training. You should see around 97% accuracy at the end.
Many of the assignments will involve using Jupyter Notebook. Below, we discuss how to run Jupyter Notebook from your GCE instance and connect to it with your local browser.
Change the External IP address of your Google Cloud Engine instance to be static (see screenshot below).
To Do this, click on the 3 line icon next to the Google Cloud Platform button on the top left corner of your screen, go to VPC network > External IP addresses (see screenshot below).
To have a static IP address, change Type from Ephemeral to Static. Enter your prefered name for your static IP, ours is cs231n-ip (see screenshot below). And click on Reserve.
NOTE: At the end of CS 231N when you don't need your instance anymore, release the static IP address because Google charges a small fee for unused static IPs (according to this page).
Take note of your Static IP address (circled on the screenshot below). We use 35.185.240.182 for this tutorial.
After you ssh into your VM using the prior instructions, run Jupyter notebook from the folder with your assignment files.
jupyter notebook
The default port is 8888, specified in ~/.jupyter/jupyter_notebook_config.py.
You can connect to your Jupyter session from your personal laptop. Open any browser and visit 35.185.240.182:8888. The login password is the one you set with the setup script above.














