Skip to content

Instantly share code, notes, and snippets.

@holmesconan
Last active June 18, 2018 13:58
Show Gist options
  • Select an option

  • Save holmesconan/6834bee42c869697673c434048a462d8 to your computer and use it in GitHub Desktop.

Select an option

Save holmesconan/6834bee42c869697673c434048a462d8 to your computer and use it in GitHub Desktop.
Tensorflow GPU deploy script
#!/bin/sh
# This script is used to config tensorflow docker runtime environment on aliyun.
# System should be Ubuntu 16.04
# echo Install NVIDIA driver
# sudo add-apt-repository ppa:graphics-drivers
# sudo apt-get update
# sudo ubuntu-drivers devices
# https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository
echo ********************************************************************************
echo ****************************** Install System ****************************
echo ********************************************************************************
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
tmux \
software-properties-common
echo ********************************************************************************
echo ****************************** Install docker ****************************
echo ********************************************************************************
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
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
# Verify that Docker CE is installed correctly by running the hello-world image.
# sudo docker run hello-world
# https://github.com/NVIDIA/nvidia-docker
echo ********************************************************************************
echo ****************************** Install nvidia-docker *************************
echo ********************************************************************************
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
# Verify the nvidia-docker is ready
# sudo nvidia-docker run --rm nvidia/cuda nvidia-smi
docker pull registry.docker-cn.com/tensorflow/tensorflow:latest-gpu
nvidia-docker run -it -p 6006:6006 -v $PWD:/env tensorflow/tensorflow:latest-gpu /bin/bash
#!/bin/bash
# This is prepared for Ubuntu 16.04 on aliyun
# CUDA and GPU drivers is installed when by the server.
# Tensorflow 1.8, CUDA 9.0, cuDNN 7.0
# You nned to download and upload cuDNN 7.0 for CUDA 9.0
# Ref: https://medium.com/@taylordenouden/installing-tensorflow-gpu-on-ubuntu-18-04-89a142325138
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
echo Install system requirements
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y git wget curl vim-nox tmux \
linux-headers-$(uname -r)
echo Install cuDNN
tar xvzf cudnn-9.0-linux-x64-v7.tgz
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo cp cuda/include/cudnn.h /usr/local/cuda-9.0/include/
sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
echo 'export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64 ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64
echo Install Anaconda
# curl -O https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
curl -O https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.2.0-Linux-x86_64.sh
bash Anaconda3-5.2.0-Linux-x86_64.sh -b
export PATH="$HOME/anaconda3/bin:$PATH"
echo ". $HOME/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
. $HOME/anaconda3/etc/profile.d/conda.sh
conda create -y -n tensorflow anaconda
conda activate tensorflow
echo Install tensorflow-gpu
pip install msgpack
pip install tensorflow-gpu
git clone https://github.com/holmescn/deep-learning-practice.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment