Installation instructions for setting up a GCP VM with Tensorflow-gpu.
- Select
Compute Engine > VM Instances > Create Instance.
- Specify
Name
,Region
, andZone
. Note, the zone must support GPU instances. - Under
Machine Type
, selectCustomize
.- Choose the number of VCPUs.
- Choose the amount of memory.
- Choose the number and type of GPUs.
- Under
Boot disk
, selectChange
.- Choose
Ubuntu 16.04 LTS
. - Specify the boot disk size.
- Choose
- Configure any other desired settings for the instance.
- Select
Create
.
- SSH into the instance.
- Download and install the CUDA 9.0 package.
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb sudo dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub sudo apt-get update sudo apt-get install cuda-9-0 -y export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
- Download
cudnn-9.0-linux-x64-v7.2.1.38.tgz
from the Nvidia website. - SCP the tar file to the server.
gcloud compute --project "${PROJECT_NAME}" scp --zone "${GCP_ZONE}" ${CUDNN_TAR_FILE} ${INSTANCE_NAME}:~/
- SSH into the instance.
- Install CUDNN.
tar -xvf ${CUDNN_TAR_FILE} sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r /usr/local/cuda/include/cudnn.h
- Install tensorflow-gpu.
sudo apt-get install python-pip python-dev python-virtualenv mkdir ~/tensorflow cd ~/tensorflow virtualenv --system-site-packages source ~/tensorflow/venv/bin/activate pip install --upgrade tensorflow-gpu
- Verify the installation.
python -c "import tensorflow as tf; print(tf.__version__)"