Skip to content

Instantly share code, notes, and snippets.

@revilokeb
Last active October 16, 2017 06:42
Show Gist options
  • Save revilokeb/02894302701fcea7ef4e85a92514e246 to your computer and use it in GitHub Desktop.
Save revilokeb/02894302701fcea7ef4e85a92514e246 to your computer and use it in GitHub Desktop.
Setting up Tensorflow Serving with CUDA 7.5 / cuDNN5 on Docker based on TF Serving commit from May 2016
# Create docker image with TF serving on GPU
# Ubuntu 14.04 LTS with nvidia-docker (https://github.com/NVIDIA/nvidia-docker)
# docker: docker bash
# host: bash on host machine
#host, pull nvidia-docker latest
nvidia-docker pull nvidia/cuda
#docker, start docker bash
nvidia-docker run --rm -ti -v /myhosthome:/mydockerhome nvidia/cuda:latest bash
#docker, install CUDA samples to check CUDA install, not strictly necessary, https://devblogs.nvidia.com/parallelforall/nvidia-docker-gpu-server-application-deployment-made-easy/
apt-get update && apt-get install -y --no-install-recommends \
cuda-samples-$CUDA_PKG_VERSION
rm -rf /var/lib/apt/lists/*
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
make
#docker, check GPUs
./deviceQuery
nvidia-smi
#docker, to prepare for TF serving GPU, https://tensorflow.github.io/serving/setup
sudo apt-get update && sudo apt-get install -y \
build-essential \
curl \
git \
libfreetype6-dev \
libpng12-dev \
libzmq3-dev \
pkg-config \
python-dev \
python-numpy \
python-pip \
software-properties-common \
swig \
zip \
zlib1g-dev \
nano
#host, download cudnn5 to host machine /myhosthome/cudnn5_download
#docker
cp /myhosthome/cudnn5_download/include/cudnn.h /usr/local/cuda/include/
cp /myhosthome/cudnn5_download/lib64/* /usr/local/cuda/lib64/
#docker, install bazel, first install Oracle JDK 8 (http://www.bazel.io/docs/install.html#install-on-ubuntu)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
echo "deb http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install bazel
sudo apt-get upgrade bazel
#docker, clone TF serving (https://tensorflow.github.io/serving/setup) and checkout commit b4e98154
git clone --recurse-submodules https://github.com/tensorflow/serving
cd serving
git checkout b4e981549df4fd041847df30158ee642b69db384
git submodule update --recursive --init
#docker, modification of CROSSTOOLS as in https://github.com/tensorflow/serving/issues/17 for commit b4e981549 not necessary here
cd tensorflow
./configure
cd ..
#docker, build TF serving
bazel build -c opt --config=cuda tensorflow_serving/...
#host, commit container
nvidia-docker commit XXXXXXXXXXXXXX tf_serving_old_commit_cuda7.5_cudnn5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment