Commit e09d3a0e authored by Andreas Gocht's avatar Andreas Gocht

update tf

parent e484d3fc
Bootstrap: docker
From: ubuntu:bionic
Namespace: amd64
%help
"
This is a buildcontainer for TensorFlow. Bot, a MKL and a CUDA version are build
# Custimaisation
Depending on your graphic driver, CUDA version and Graphic card you need to change:
* the installed cudnn package
* the installed NCCL package
* the specified TF_CUDA_COMPUTE_CAPABILITIES
Ubuntu 18.04 currently ships CUDA 9.1. So everything should work.
Most likely you still might want to adapt TF_CUDA_COMPUTE_CAPABILITIES to your device.
"
%runscript
echo "This is what happens when you run the container..."
%files
cudnn-9.1-linux-x64-v7.1.tgz /tmp/
nccl_2.1.15-1+cuda9.1_x86_64.txz /tmp/
%post
apt-get update
apt-get dist-upgrade -y
###################################
# default requirements
###################################
apt-get -y install vim
apt-get -y install wget curl build-essential make g++ gfortran git subversion cmake python python3 python-pip python3-pip git
###################################
# environment
###################################
if [ ! -d /apps ]; then
mkdir /apps
mkdir /scratch
mkdir /sw
mkdir /projects
fi
###################################
# scorep requirements
###################################
apt-get -y install zlib1g-dev autotools-dev automake autoconf gcc-5-plugin-dev flex bison texinfo
apt-get -y install python-virtualenv
apt-get -y install python3-dev
apt-get -y install python3-numpy python3-pip python3-wheel
###################################
# Tensorflow - Dependencies
###################################
python3.6 -m pip install --upgrade numpy six wheel
python3.6 -m pip install --upgrade keras_applications==1.0.6 --no-deps
python3.6 -m pip install --upgrade keras_preprocessing==1.0.5 --no-deps
apt-get -y install nvidia-cuda-toolkit=9.1.85-3ubuntu1
apt-get -y install nvidia-cuda-dev=9.1.85-3ubuntu1
cd /apps
if [ ! -d tensorflow-dep ]; then
mkdir tensorflow-dep
cd tensorflow-dep
cp /tmp/cudnn-9.1-linux-x64-v7.1.tgz ./
tar -vxf cudnn-9.1-linux-x64-v7.1.tgz
cp /tmp/nccl_2.1.15-1+cuda9.1_x86_64.txz ./
tar -xf nccl_2.1.15-1+cuda9.1_x86_64.txz
fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/tensorflow-dep/cuda/lib64:/apps/tensorflow-dep/nccl_2.1.15-1+cuda9.1_x86_64/lib
###################################
# Bazel
###################################
apt-get -y install openjdk-8-jdk
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
apt-get -y update
apt-get -y install bazel
###################################
# Get TensorFlow
###################################
cd /apps
if [ -d tensorflow ]; then
cd tensorflow
git fetch
else
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
fi
###################################
# Configure TensorFlow
###################################
git checkout v1.12.0
export TF_NEED_CUDA=1
export TF_NEED_MPI=0
export PYTHON_BIN_PATH="/usr/bin/python3.6"
export PYTHON_LIB_PATH="/usr/local/lib/python3.6/dist-packages/"
#export PYTHONPATH=$(pwd)/lib
#export PYTHON_ARG=$(pwd)/lib
export CUDA_TOOLKIT_PATH="/usr"
export CUDA_PATH="/usr"
export CUDNN_INSTALL_PATH="/apps/tensorflow-dep/cuda"
export TF_NCCL_VERSION="2.1"
export NCCL_INSTALL_PATH="/apps/tensorflow-dep/nccl_2.1.15-1+cuda9.1_x86_64/lib"
export NCCL_HDR_PATH="/apps/tensorflow-dep/nccl_2.1.15-1+cuda9.1_x86_64/include"
export TF_NEED_GCP=0
export TF_CUDA_VERSION="9.1"
export TF_CUDA_COMPUTE_CAPABILITIES=3.0
export TF_NEED_HDFS=0
export TF_NEED_OPENCL=0
export TF_NEED_JEMALLOC=1
export TF_ENABLE_XLA=0
export TF_NEED_VERBS=0
export TF_CUDA_CLANG=0
export TF_CUDNN_VERSION="7.1.2"
export TF_NEED_MKL=1
export TF_DOWNLOAD_MKL=1
./configure -march=native
###################################
# Build TensorFlow with MKL
###################################
# if compatibility to old c++ compilers is needed add --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
bazel build --config=mkl --config=opt //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg_mkl/
###################################
# Build TensorFlow with CUDA
###################################
# if compatibility to old c++ compilers is needed add --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
bazel build --config=cuda --config=opt //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg_cuda/
###################################
# Save TensorFlow for manual export
###################################
mkdir -p /apps/tf_cuda
mkdir -p /apps/tf_mkl
cp /tmp/tensorflow_pkg_mkl/*.whl /apps/tf_cuda
cp /tmp/tensorflow_pkg_mkl/*.whl /apps/tf_mkl
%environment
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/tensorflow-dep/cuda/lib64:/apps/tensorflow-dep/nccl_2.1.15-1+cuda9.1_x86_64/lib
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment