Last active
May 22, 2019 08:50
-
-
Save ZeccaLehn/de42e70660e54f34628249fae7d26ce5 to your computer and use it in GitHub Desktop.
GCP/GCloud VM setup running R/Python using Anaconda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####### GCP/GCloud VM setup running R/Python using Anaconda ######## | |
# Prepared as part of a guest lecture series in parallel programming and GCloud setup | |
# at Pepperdine University for their inaugural ML class on 3/16/2018. | |
# Rights: MIT Licence | |
## 10 easy steps: Running R/Python in the cloud | |
1) Log into GCP | |
2) Create a project (if not done already), and log into <your project> from top of screen | |
3) Once logged into project, click on Compute Engine ("GCE") >> VM Instances from side ("Hamburger Bar") | |
4) Click on "Create Instance" | |
5) Complete below steps at a minimum: | |
- name: <your GCE VM name> | |
- zone: e.g. "us-west1-b" or <your zone name> | |
- boot disk: Ubuntu 16.04 w/Size of 10gb or more | |
6) Click CREATE at bottom of "Create Instance" page. VM will automatically start and turn green when on. | |
7) Click on SSH tab, of started machine. | |
Note: Can also log into machine from the inline command line via: | |
gcloud compute --project <your project> ssh --zone "us-west1-b" <machine name> | |
8) Run below code to install current versions of R/Python within bash shell of VM | |
# Install Anaconda | |
sudo apt-get update | |
mkdir Downloads | |
cd Downloads | |
wget "https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh" -O "Anaconda3-5.0.1-Linux-x86_64.sh" | |
chmod +x Anaconda3-5.0.1-Linux-x86_64.sh | |
sudo sh "Anaconda3-5.0.1-Linux-x86_64.sh" -b | |
cd $HOME | |
sudo -s | |
rm -r Downloads | |
# Export Conda Path | |
echo 'export PATH=$PATH:$HOME/anaconda3/bin' >> ~/.bashrc | |
source ~/.bashrc | |
# Create conda environment to work with Python | |
conda create --name py35 python=3.5 | |
source activate py35 | |
python # Then CTRL+Z exit | |
> x = ['hello','world']; x[0] + " " + x[1] + "!!!" | |
# Then CTRL+Z exit | |
source deactivate pyenv | |
# Create conda environment to work with a 'newer' version of R | |
# Find newest here https://repo.continuum.io/pkgs/r/linux-64/ | |
conda create --name r34 r=3.4.3 -y | |
source activate r34 | |
R | |
> x <- c("hello", "world") | |
> paste0(x[1],' ',x[2],"!!!") | |
9) Check box on running machine, and click STOP button at top of page to turn off. | |
10) Jump up and down, and celebrate. You've just made a Python/R machine which is billed by the minute to run your cool ML projects in the cloud. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment