[yes|no][no] >>> yes# Use it right awaysource ~/.
bashrc# Create a Python 3 virtual environmentconda create -n <env_name> python=3.
6# Activate our environmentsource activate <env_name>Install NVIDIA CUDAAfter we activate the environment, it’s time to install CUDA.
Run the commands below in sequence# download the CUDA 9.
2curl -O https://developer.
deb# install the CUDAsudo dpkg -i cuda-repo-ubuntu1604_9.
deb# Downgrade it to 9.
0 since tensorflow-gpu can only use v9.
0sudo apt-get updatesudo apt-get install cuda-9-0# check if CUDA is installednvidia-smiIf CUDA is successfully installed, it would show something like this:Install cuDNNThe sad news is that we can not directly install cuDNN with commands like CUDA above.
Hence, we need to download the package from the website, then upload them to Storage, transfer to our instance and then install them.
1- Download the packagesWe need to register NVIDIA Developer account first, then download two packages below (Runtime Library and Developer Library)2- Upload to StorageNavigate to Storage tab > BrowserIf you do not have any bucket, create one, then upload two files we have downloaded.
Here my bucket is kyanon_storage3- Transfer files to our instanceNow back to SSH window, we will use the gsutil command to transfer the two packages we have uploaded to our current instance.
First we need to know the syntax of transfer:gsutil cp -r gs://<bucket_name>/<file_path> /home/<username>The first path is the source path where you store the file: gs://<bucket_name>/<file_path>The second path is the destination path in our instance: /home/<username>So in my case, the commands will be:gsutil cp -r gs://kyanon_storage/libcudnn7_7.
deb /home/quan_trangsutil cp -r gs://kyanon_storage/libcudnn7-dev_7.
deb /home/quan_tran4- Install the packagesAfter the transfer is done, run the following commands in sequence to install cuDNN packages:# install the cuDNN Runtime Librarysudo dpkg -i libcudnn7-dev_7.
deb# install the cuDNN Developer Librarysudo dpkg -i libcudnn7_7.
debInstall Tensorflow GPUJust run the simple commands:# install the tensorflow-gpupip install tensorflow-gpu# Make sure the package is up to datepip install –upgrade tensorflow-gpuTo ensure GPU is ready, access to python and run this script:# enter python python# check tensorflow>>>import tensorflow as tf>>>from tensorflow.
client import device_lib>>>print(device_lib.
list_local_devices())The result should be like this:You can see that GPU is now on the list.
Finally, type exit() to escape the python environment.
Install KerasNow simply install Keras by command:# install the keraspip install keras3.
Install Jupyter NotebookGenerally, we will go through this process:Set our instance to static HTTPS using VPC Network services, this helps us have global access to Jupyter NotebookConfig firewall rulesInstall Jupyter Notebook and then modify the configuration fileFirst, navigate to VPC Network > External IP addressesChange Type to StaticThen go to Firewall rules tab and choose Create Firewall RuleSet a rule name and config some fields:Targets: All instances in the networkSource filter: IP rangesSource IP ranges: 0.
0/0Protocols and ports: choose Specified protocols and ports, pick on tcp and choose a port you want, here we set 7000 (this tcp port will be used to access to Jupyter Notebook)The rest are defaultsThen click createBefore we move on, back to External IP addresses tab and make sure that the IP address is In use by our target instanceBack to SSH window and install jupyter:# download the jupyter notebook to our environmentpip install Jupyter NotebookOnce the Jupyter Notebook package is installed, we need to configure the Jupyter Notebook setting:# Generate Configuration filejupyter notebook –generate-config# Check if the configure file existls ~/.
py# change directory to target pathcd /home/<uesr_name>/.
jupyter/# open jupyter_notebook_config.
pyAfter opening jupyter_notebook_config.
py, add these few lines of code:c = get_config()c.
ip = '0.
open_browser = Falsec.
port = 7000The jupyter_notebook_config.
py should look something like this:We passed the 0.
0 for the ip and 7000 for the port number.
Then, save the file.
Now the Jupyter Notebook is ready to use, use the command below:# Launch the Notebookjupyter-notebook –no-browser –port=7000The output will be something like this:We need to modify the URL a little bit, change the IP to the static of our instance (the External IP field)Then paste it to the browser, now Jupyter Notebook is ready to useSometimes, it might ask you to insert password or token by showing this page:Just need to copy the token from the URL and pass it to the page:Now you can set a new password if you want.
That’s all we need to set up a very basic GPU environment on Google Cloud Platform.
Hope that this article could help those who are looking for a convenient and simple way to solve their problem.
References:Complete Step by Step Guide of Keras Transfer Learning with GPU on Google Cloud PlatformIn this guide, I have chosen an expired Kaggle competition — Plant Seedlings Classification to be the template project…medium.
comRunning Jupyter Notebook on Google Cloud Platform in 15 minRecently, while I was doing my research project on Computer Vision using Convolutional Neural Network, I found out that…towardsdatascience.
com.. More details