GCP Tutorial Slides
GCP Tutorial Slides
http://cs231n.github.io/gce-tutorial/ (http://cs231n.github.io/gce-tutorial/)
A word of caution: STOP YOUR INSTANCES
Please do not forget to stop your instance(s) when you are done, otherwise you
will run out of credits!
You can stp by clicking on the stop button at the top of the page
showing your instances)
First things rst: Try the free stu rst, if you want!
Google is generous enough to give $300 worth of google cloud credit to the new
google/gmail users:
Here is the link to activate your credit
https://cloud.google.com/free/docs/frequently-asked-questions#free-
trial (https://cloud.google.com/free/docs/frequently-asked-
questions#free-trial)
Just make sure you are eligible.
Remember to select Individual as Account Type
It might ask you for your credit card information, but Google made it
very clear that they won't charge you a penny during your free trial
(which is a year from the day you are given the credit), and it won't
auto-recharge after the trial is over! Neat, isn't it!
First things rst: Try the free stu rst, if you want!
CAUTION: If you exceed the credit limit (which is $300) within the trial period,
you may notice the charge based on the Google cloud platform's pricing model,
which is located at https://cloud.google.com/compute/pricing
(https://cloud.google.com/compute/pricing). Please do understand the
consequences of overuse of the credit within the trial period. I will not be
responsible for any of these incurred charges.
Make sure you read all the agreements/terms etc. before you signup, and I will
not be responsible for any consequences including Google's way of collecting
user data (including user information, email, credit card information,
demographics, dataset stored in cloud storage), or in an unlikely event of a
massive attack against Google platform revealing its user information.
Google cloud platform credit from me
(1) Not happy with the google free trial? Or, (2) the google trial credit of $300 is
nished? I have something for you!
As an enrolled student in my class, I will give you $50 google cloud
credit.
Please send me an email requesting the credit and also mentioning
which of the two cases (1 or 2) applies to you. I will send you a link to
get the credit.
CAUTION: If you exceed the credit limit (which is $50), you may notice
the charge based on the Google cloud platform's pricing model, which
is located at https://cloud.google.com/compute/pricing
(https://cloud.google.com/compute/pricing). Please do understand the
consequences of overuse of the credit within the trial period. I will not
be responsible for any of these incurred charges.
CAUTION Make sure you read all the agreements/terms etc. before
you signup, and I will not be responsible for any consequences
including Google's way of collecting user data (including user
information, email, credit card information, demographics, dataset
stored in cloud storage), or in an unlikely event of a massive attack
against Google platform revealing its user information.
You can request for more if you nish up the $50. Please let me know
by email. Thanks
Google cloud platform credit from me
CAUTION: If you exceed the credit limit (which is $50), you may notice the
charge based on the Google cloud platform's pricing model, which is located at
https://cloud.google.com/compute/pricing
(https://cloud.google.com/compute/pricing). Please do understand the
consequences of overuse of the credit within the trial period. I will not be
responsible for any of these incurred charges.
CAUTION Make sure you read all the agreements/terms etc. before you signup,
and I will not be responsible for any consequences including Google's way of
collecting user data (including user information, email, credit card
information, demographics, dataset stored in cloud storage), or in an unlikely
event of a massive attack against Google platform revealing its user
information.
You can request for more if you nish up the $50. Please let me know by email.
Thanks
Getting to know the GCP Console
Once signed-up, go to http://console.cloud.google.com
(http://console.cloud.google.com)
( gs/console-01.png)
Click on the "Billing" link
( gs/console-02a.png)
Create the compute engine for the course
1. From the GCP/console dashboard, click "Compute Engine"
2. Click "Images"
Create the compute engine for the course
1. Click on "c2-deeplearning-tf-1-10-cu92-20180914" image and and click
"Create an instance" button. Then con gure the following entries before you hit
the "Create" button at the bottom of the con guration page:
Name: cse-cudenver-deep-learning
Region: us-west1 (Oregon),
Zone: us-west1-b
Machine type (Click "Customize" to get more options):
Cores: 1 vCPU (1-8 cores)
Memory: 3.75 GB
CPU Platform: Automatic
GPUs
Number of GPUs: 1
GPU Type: NVIDIA Tesla K80
Boot disk: Deep Learning image: (30GB)
Create the compute engine for the course
1. Hit the "Create" button at the bottom of the page. It takes few minutes to create
your instance. Once done, connect to the instance via SSH. It might prompt you
if you would like to install nvidia driver (y/n). Please hit "y" to install it.
2. After the instance is created, it automatically boots up the instance. So BE
CAREFUL FROM NOW ON. The INSTANCE IS RUNNING!! Running your
instance will cost you. According to the current pricing model (as of 9/23/2018),
Google will charge you $ 0.35 (for the CPU), $0.45 (for the GPU) per hour of
running the instance.
( gs/instance-01.png)
The instance is running... now connect via SSH
( gs/instance-02.png)
And here is the SSH prompt
( gs/instance-03.png)
Be sure to stop the instance when done, by typing
sudo powero
( gs/instance-04.png)
Want to run jupyter notebook on the GCP instance?
Step 1: Allow HTTP/HTTPS tra c by editing the instance
Stop the instance, and hit the "Edit" button below
( gs/allow-HTTP-HTTPS.png)
Want to run jupyter notebook on the GCP instance?
Step 1: Allow HTTP/HTTPS tra c by editing the instance
Want to run jupyter notebook on the GCP instance?
Step 1: Allow HTTP/HTTPS tra c by editing the instance
Then select the the two options at the "Firewalls" section of the form:
( gs/allow-HTTP-HTTPS-02.png)
Want to run jupyter notebook on the GCP instance?
Step 2: Open a port, (e.g., 5800)
Go to "Network details" of the instance
( gs/step-01.png)
Want to run jupyter notebook on the GCP instance?
Step 2: Open a port, (e.g., 5800)
Click on the "Firewall rules" option
( gs/step-02.png)
Want to run jupyter notebook on the GCP instance?
Step 2: Open a port, (e.g., 5800)
Create a new rule.
we use dl-rule. Select “All instances in the network” for Targets (if the menu item
exists). Enter 0.0.0.0/0 for Source IP ranges and tcp: for Speci ed protocols and
ports where is the number you used above. Click on the blue Create button. See
the screenshot below.
( gs/step-03.png)
Want to run jupyter notebook on the GCP instance?
Step 2: Open a port, (e.g., 5800)
Just created the rule "dl_rule"
( gs/step-04.png)
Want to run jupyter notebook on the GCP instance?
Step 2: Open a port, (e.g., 5800)
Now, you are ready to start the instance. Also, make note of the external IP
address (e.g., here in this case it is 35.227.148.50. It might change overtime. Or,
you can have a static external ip address with a fee so that you don't have to
worry about the change of external ip over time.
( gs/step-05.png)
Want to run jupyter notebook on the GCP instance?
Step 3: Con gure jupyter notebook
Open up an SSH session with the GCP instance, and check if you have a jupyter
con gure le at:
ls ~/.jupyter/jupyter_notebook_config.py
Open the con g le and browse through the following 3 lines (uncomment and
change the values to the following):
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5800
Here, 5800 is the desired port number for the jupyter notebook.
Want to run jupyter notebook on the GCP instance?
Step 3: Con gure jupyter notebook
Now, lauch jupyter notebook and copy the :5800/?token..... portion of the url as
highlighted in the following snapshot
( gs/jpn-01.png)
Want to run jupyter notebook on the GCP instance?
Step 4: Now go to your browser (in your local machine)
At the address bar, type the external IP and the :5800/?token... portion to get
the exact jupyter notebook URL
( gs/jpn-02.png)
Want to run jupyter notebook on the GCP instance?
Step 4: Now go to your browser (in your local machine)
You should see the following
( gs/jpn-03.png)
Want to run jupyter notebook on the GCP instance?
Step 4: Now go to your browser (in your local machine)
Commandline tools to Connect to GCP instance
Download the Google Cloud SDK that is appropriate for your platform from
https://cloud.google.com/sdk/docs/ (https://cloud.google.com/sdk/docs/) and
follow their installation instructions.
Then run gcloud init to get started:
gcloud init
To know more about the GCP api commands, please look into the SDK
documentation above.
BIG REMINDER: Make sure you stop your instances!
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.
In [1]: print("Thanks all for your attention. See you in class. - Dr. B")