Skip to content

Instantly share code, notes, and snippets.

@DEKHTIARJonathan
Created November 28, 2018 13:54
Show Gist options
  • Save DEKHTIARJonathan/a6ac6860f3dd6dbcf72cdd9e325dec35 to your computer and use it in GitHub Desktop.
Save DEKHTIARJonathan/a6ac6860f3dd6dbcf72cdd9e325dec35 to your computer and use it in GitHub Desktop.
FROM nvidia/cudagl:10.0-runtime-ubuntu16.04
LABEL version="1.0" maintainer="Jonathan DEKHTIAR <contact@jonathandekhtiar.eu>"
# Install the most recent bazel release.
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /workspace
# Install Basic Dependencies and Python 3
RUN apt-get update && \
apt-get install -qqy \
build-essential cmake pkg-config rsync \
python python-dev python3 python3-dev \
python-numpy python-pip python3-numpy python3-pip \
doxygen git vim unzip wget git curl zip g++ \
software-properties-common libcurl3 zlib1g-dev \
libfreetype6-dev libhdf5-serial-dev libpng12-dev \
libzmq3-dev x11-apps mesa-utils && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python && \
rm -f /usr/bin/pip && ln -s /usr/bin/pip3 /usr/bin/pip && \
rm -f /usr/bin/python-config && ln -s /usr/bin/python3.5-config /usr/bin/python-config
# Installing CUDA + CUDA CLI + CuDNN + NCCL + CuBLAS + CuFFT + CuRAND + NvInfer (TRT)
RUN apt-get update && \
apt-get install -y --no-install-recommends --allow-change-held-packages \
cuda-command-line-tools-10-0 \
cuda-cublas-10-0 \
cuda-cufft-10-0 \
cuda-curand-10-0 \
cuda-cusolver-10-0 \
cuda-cusparse-10-0 \
libcudnn7=7.4.1.5-1+cuda10.0 \
libnccl2=2.3.7-1+cuda10.0 \
libnccl-dev=2.3.7-1+cuda10.0 && \
apt-get update && \
apt-get install -y \
nvinfer-runtime-trt-repo-ubuntu1604-5.0.2-ga-cuda10.0 && \
apt-get update && \
apt-get install -y \
libnvinfer5=5.0.2-1+cuda10.0 \
libnvinfer-dev=5.0.2-1+cuda10.0 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Link NCCL libray and header where the build script expects them.
RUN mkdir /usr/local/cuda-10.0/lib && \
ln -s /usr/lib/x86_64-linux-gnu/libnccl.so.2 /usr/local/cuda/lib/libnccl.so.2 && \
ln -s /usr/include/nccl.h /usr/local/cuda/include/nccl.h
# Installing Common Python Packages Dependencies
RUN python -m pip install --upgrade pip && \
pip --no-cache-dir install \
Pillow \
h5py \
ipykernel \
jupyter \
keras_applications \
keras_preprocessing \
matplotlib \
numpy \
pandas \
scipy \
sklearn
# Configure the build for our CUDA configuration.
# ======== CUDA Compute Capabilities ========
#
# GTX Titan X: 5.2
# Quadro GP100: 6.0
# GTX 1080 (Ti): 6.1
# NVIDIA Titan X/Xp: 6.1
# NVIDIA Titan V: 7.0
# Tesla GV100: 7.0
# RTX 2080 (Ti): 7.5
#
# ======== CUDA Compute Capabilities ========
ENV CI_BUILD_PYTHON=python \
BAZEL_VERSION='0.15.0' \
LD_LIBRARY_PATH='/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH' \
TF_NEED_CUDA=1 \
TF_NEED_TENSORRT=1 \
TF_CUDA_COMPUTE_CAPABILITIES=5.2,6.0,6.1,7.0,7.5 \
TF_CUDA_VERSION=10.0 \
TF_CUDNN_VERSION=7 \
TF_NCCL_VERSION=2 \
TF_BUILD_BRANCH='r1.12'
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH}
# Set up Bazel.
# Running bazel inside a `docker build` command causes trouble, cf:
# https://github.com/bazelbuild/bazel/issues/134
# The easiest solution is to set up a bazelrc file forcing --batch.
# Similarly, we need to workaround sandboxing issues:
# https://github.com/bazelbuild/bazel/issues/418
RUN rm -f /etc/bazel.bazelrc && \
echo "startup --batch" >> /etc/bazel.bazelrc && \
echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
>> /etc/bazel.bazelrc && \
rm -rf /bazel && mkdir /bazel && cd /bazel && \
curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" \
-fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" \
-fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \
chmod +x bazel-*.sh && \
./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
cd / && \
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
# Get the TF branch for later build
RUN rm -rf /tensorflow && \
git clone --branch=$TF_BUILD_BRANCH --depth=1 https://github.com/tensorflow/tensorflow.git /tensorflow && \
cd /tensorflow && \
tensorflow/tools/ci_build/builds/configured GPU \
bazel build -c opt --copt=-mavx --config=cuda \
--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
tensorflow/tools/pip_package:build_pip_package && \
rm /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/pip && \
pip --no-cache-dir install --upgrade /tmp/pip/tensorflow-*.whl && \
rm -rf /tmp/pip && \
rm -rf /root/.cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment