Last active
January 27, 2018 14:05
-
-
Save royshil/74ecb115d3d23692b008d769010a3d9d to your computer and use it in GitHub Desktop.
Setup an automatic Tensorflow-CUDA-Docker-Jupyter machine on Google Cloud Platform
This file contains 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
#!/bin/bash | |
# First you must install the 4.4.0 kernel: | |
# $ sudo apt-get install linux-image-4.4.0-112-generic | |
# find all the other kernels and remove them: | |
# $ sudo apt-get purge linux-image-4.13.0-1008-gcp | |
# $ sudo update-grub | |
# $ sudo reboot | |
sudo apt-get update && sudo apt-get install -y \ | |
build-essential \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
software-properties-common \ | |
linux-headers-$(uname -r) | |
#### Install Nvidia CUDA | |
wget -nc https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux | |
sudo sh cuda_9.1.85_387.26_linux -silent | |
rm -rf cuda_9.1.85_387.26_linux | |
#### Install Docker | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update && sudo apt-get install -y docker-ce | |
#### Install Nvidia Docker | |
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - | |
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list | |
sudo apt-get -qq update | |
sudo apt-get install -y nvidia-docker2 | |
sudo pkill -SIGHUP dockerd | |
#### Build Docker image | |
cat << EOF > Dockerfile.tensorflow_gpu_jupyter | |
FROM tensorflow/tensorflow:latest-gpu | |
RUN apt-get update && apt-get install -y python-opencv python-skimage git | |
RUN pip install requests ipywidgets seaborn | |
RUN jupyter nbextension enable --py widgetsnbextension | |
RUN git clone git://github.com/keras-team/keras.git && pip install keras[tests] && rm -rf keras | |
CMD ["/run_jupyter.sh", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password='sha1:c05e4b238956:8ac2f926ab754e180ec201ce0485b2a55f679ceb'"] | |
EOF | |
sudo docker build -t tensorflow_gpu_jupyter -f Dockerfile.tensorflow_gpu_jupyter . | |
sudo nvidia-docker run -dit --restart unless-stopped -p 8888:8888 tensorflow_gpu_jupyter | |
echo "The password to the notebook is 'tensorflow_gpu_jupyter'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment