Last active
October 31, 2017 03:56
-
-
Save marvin-hansen/333bf5f5d59fe25c27dc3e056872eb5d to your computer and use it in GitHub Desktop.
Creates a fast.ai DL environment on Google Cloud
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
# Preare disk | |
# Here sdb is the device ID I get from lsblk | |
# Uncomment if you want to use a shared disk. | |
# Details on: # https://cloud.google.com/compute/docs/disks/add-persistent-disk | |
# You can add a persistent disk already when creating a computing instnance | |
#echo "Format Disk" | |
#sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb | |
#sudo mkdir -p /mnt/disks/data | |
#echo "Mount Disk" | |
#sudo mount -o discard,defaults /dev/sdb /mnt/disks/data | |
#echo UUID=`sudo blkid -s UUID -o value /dev/sdb` /mnt/disks/data ext4 discard,defaults,nofail 0 2 | sudo tee -a /etc/fstab | |
#ln -s /mnt/disks/data/ data | |
#echo "Done" | |
# install Anaconda for current user | |
echo "Install Anaconda" | |
mkdir downloads | |
cd downloads | |
wget "https://repo.continuum.io/archive/Anaconda3-5.0.0.1-Linux-x86_64.sh" -O "Anaconda3-5.0.0.1-Linux-x86_64.sh" | |
bash "Anaconda3-5.0.0.1-Linux-x86_64.sh" -b | |
echo "export PATH=\"$HOME/anaconda3/bin:\$PATH\"" >> ~/.bashrc | |
export PATH="$HOME/anaconda3/bin:$PATH" | |
conda install -y bcolzconda install -y bcolz | |
conda install -y pip | |
conda upgrade -y --all | |
python --version | |
which python | |
# Some students have reported GPU instances whose drivers disappear upon restarts. | |
# And there is strong evidence to suggest that the issue happens when Ubuntu auto-installs security updates upon booting up. | |
# To disable auto-updating, run | |
# http://cs231n.github.io/gce-tutorial-gpus/ | |
sudo apt-get update | |
sudo apt-get --assume-yes remove unattended-upgrades | |
# ensure system is updated and has basic build tools | |
sudo apt-get --assume-yes install tmux libcupti-dev build-essential gcc g++ make binutils software-properties-common | |
# download and install GPU drivers | |
# see https://cloud.google.com/compute/docs/gpus/add-gpus#install-gpu-driver | |
echo "Checking for CUDA and installing." | |
# Check for CUDA and try to install. | |
if ! dpkg-query -W cuda-8-0; then | |
# The 16.04 installer works with 16.10. | |
echo "Installing CUDA" | |
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb | |
sudo dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb | |
sudo apt-get update | |
sudo apt-get install cuda-8-0 -y | |
fi | |
# verify that GPU driver installed | |
echo "verify GPU Driver" | |
sudo modprobe nvidia | |
nvidia-smi | |
# install cudnn libraries | |
echo "Install cudnn" | |
wget "http://files.fast.ai/files/cudnn.tgz" -O "cudnn.tgz" | |
tar -zxf cudnn.tgz | |
cd cuda | |
sudo cp lib64/* /usr/local/cuda/lib64/ | |
sudo cp include/* /usr/local/cuda/include/ | |
# install and configure theano | |
echo "install and configure theano" | |
conda install theano pygpu | |
clear | |
# install and configure keras | |
echo "install and configure keras" | |
conda install keras | |
mkdir ~/.keras | |
echo '{ | |
"epsilon": 1e-07, | |
"floatx": "float32", | |
"backend": "theano", | |
"image_data_format": "channels_first" | |
}' > ~/.keras/keras.json | |
# install pytorch | |
echo "install pytorch" | |
conda install pytorch torchvision cuda80 -c soumith | |
# clone the fast.ai course repo and prompt to start notebook | |
echo "clone the fast.ai course repo" | |
cd ~ | |
git clone https://github.com/fastai/courses.git | |
# configure jupyter and prompt for password | |
echo "install and configure jupyter" | |
conda install scikit-learn | |
conda install pandas | |
conda install jupyter | |
jupyter notebook --generate-config | |
jupass=`python -c "from notebook.auth import passwd; print(passwd())"` | |
echo "c.NotebookApp.ip = '*' | |
c.NotebookApp.password = u'"$jupass"' | |
c.NotebookApp.open_browser = False | |
c.NotebookApp.port = 8888" >> $HOME/.jupyter/jupyter_notebook_config.py | |
echo "Done. Setup completed" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
wget https://gist.github.com/marvin-hansen/333bf5f5d59fe25c27dc3e056872eb5d
chmod + x setup.sh
sudo ./setup.sh