Skip to content
Snippets Groups Projects
Commit ba45a5ad authored by Vincent Delbar's avatar Vincent Delbar
Browse files

FIX: Docker - let bazel deal with optimizations

parent 40713c0a
No related branches found
No related tags found
No related merge requests found
......@@ -50,8 +50,10 @@ RUN wget https://github.com/bazelbuild/bazel/releases/download/$BAZEL/bazel-$BAZ
### TF
ARG TF=r2.4
ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow:libtensorflow_framework.so //tensorflow/tools/pip_package:build_pip_package"
ARG BZL_CONFIG="--config=opt --config=nogcp --config=noaws --config=nohdfs"
ARG BZL_OPTIONS="--compilation_mode opt --verbose_failures --remote_cache=http://localhost:9090"
# --config=opt with bazel's default optimizations
ARG BZL_CONFIG="--config=nogcp --config=noaws --config=nohdfs --config=opt"
# --compilation_mode opt is already enabled by default (see tf repo .bazelrc and configure.py)
ARG BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090"
RUN mkdir /src/tf
WORKDIR /src/tf
......
......@@ -13,8 +13,8 @@ BAZEL=3.1.0
TF=r2.4
OTB=release-7.2
BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow:libtensorflow_framework.so //tensorflow/tools/pip_package:build_pip_package"
BZL_CONFIG="--config=opt --config=nogcp --config=noaws --config=nohdfs"
BZL_OPTIONS="--compilation_mode opt --verbose_failures --remote_cache=http://localhost:9090"
BZL_CONFIG="--config=nogcp --config=noaws --config=nohdfs --config=opt"
BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090"
KEEP_SRC_TF=false
KEEP_SRC_OTB=false
SUDO=true
......@@ -41,20 +41,20 @@ Then ust add ` --network='host'` to the docker build command, or connect bazel t
# Build for CPU using default Dockerfiles args (without AWS, HDFS and GCP support)
docker build --network='host' -t otbtf:cpu --build-arg BASE_IMG=ubuntu:18.04 .
# Clear bazel config var
# Clear bazel config var (deactivate optimizations and unset noaws/nogcp/nohdfs)
docker build --network='host' -t otbtf:cpu --build-arg BASE_IMG=ubuntu:18.04 --build-arg BZL_CONFIG= .
# Build with latest CUDA
docker build --network='host' -t otbtf:gpu-dev --build-arg BASE_IMG=nvidia/cuda:11.0-cudnn8-devel-ubuntu18.04 --build-arg KEEP_SRC_OTB=true .
# Enable MKL
BZL_CONFIG="--config=opt --config=nogcp --config=noaws --config=nohdfs --config=mkl --copt='-mfpmath=both'"
docker build --network='host' -t otbtf:cpu-mkl --build-arg BZL_CONFIG=$BZL_CONFIG --build-arg BASE_IMG=nvidia/cuda:11.0-cudnn8-devel-ubuntu18.04 .
MKL_CONFIG="--config=nogcp --config=noaws --config=nohdfs --config=mkl --config=opt --copt='-mfpmath=both'"
docker build --network='host' -t otbtf:cpu-mkl --build-arg BZL_CONFIG=$MKL_CONFIG --build-arg BASE_IMG=nvidia/cuda:11.0-cudnn8-devel-ubuntu18.04 .
# Manage versions
docker build --network='host' -t otbtf:oldstable-gpu --build-arg BASE_IMG=nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 \
--build-arg TF=r2.1 --build-arg BAZEL=0.29.1 --build-arg OTB=release-7.2 \
--build-arg BAZEL_OPTIONS="--noincompatible_do_not_split_linking_cmdline -c opt --verbose_failures" .
--build-arg BAZEL_OPTIONS="--noincompatible_do_not_split_linking_cmdline --verbose_failures" .
# You could edit the Dockerfile to clone an old branch of the repo instead of cp new files from the build context
```
......
# TF - bazel build env variables
# Optimization is controlled with bazel -c opt
export CC_OPT_FLAGS="-march=native -Wno-sign-compare"
export GCC_HOST_COMPILER_PATH=$(which gcc)
# Optimization is controlled with bazel --config=opt, it will set AVX and SSE flags on linux if possible (without the march=native flag)
# It is disabled in TF2.4 config, you may pass it with --copt='-march=native', see BZL_CONFIG arg or just uncomment this line
#export CC_OPT_FLAGS="-march=native -Wno-sign-compare"
export PYTHON_BIN_PATH=$(which python)
export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')"
export TF_ENABLE_XLA=1
......@@ -21,7 +22,7 @@ export TF_SET_ANDROID_WORKSPACE=0
#export TF_NEED_AWS=0
#export TF_NEED_GCP=0
#export TF_NEED_HDFS=0
# For MKL support BZL_CONFIG+=" --config=mkl --copt='-mfpmath=both'"
# For MKL support BZL_CONFIG+=" --config=mkl --config=opt --copt='-mfpmath=both'"
#export TF_DOWNLOAD_MKL=1
#export TF_NEED_MKL=0
......
......@@ -17,10 +17,10 @@ docker run -d -u 1000:1000 -v $HOME/.cache/bazel-remote:/data -p 9090:8080 buch
#docker build --network='host' -t mdl4eo/otbtf$RELEASE:cpu --build-arg BASE_IMG=$IMG .
#docker build --network='host' -t mdl4eo/otbtf$RELEASE:cpu-dev --build-arg BASE_IMG=$IMG --build-arg KEEP_SRC_OTB=true .
# Enable MKL with bazel config flag
CONF="--config=opt --config=nogcp --config=noaws --config=nohdfs --config=mkl --copt='-mfpmath=both'"
docker build --network='host' -t mdl4eo/otbtf$RELEASE:cpu --build-arg BASE_IMG=$IMG --build-arg BZL_CONFIG="$CONF" .
MKL_CONF="--config=nogcp --config=noaws --config=nohdfs --config=mkl --config=opt --copt='-mfpmath=both'"
docker build --network='host' -t mdl4eo/otbtf$RELEASE:cpu --build-arg BASE_IMG=$IMG --build-arg BZL_CONFIG="$MKL_CONF" .
# Keep OTB src and build files in order to rebuild with other modules
docker build --network='host' -t mdl4eo/otbtf$RELEASE:cpu-dev --build-arg BASE_IMG=$IMG --build-arg BZL_CONFIG="$CONF" --build-arg KEEP_SRC_OTB=true .
docker build --network='host' -t mdl4eo/otbtf$RELEASE:cpu-dev --build-arg BASE_IMG=$IMG --build-arg BZL_CONFIG="$MKL_CONF" --build-arg KEEP_SRC_OTB=true .
# GPU support is enabled if CUDA is found in /usr/local
docker build --network='host' -t mdl4eo/otbtf$RELEASE:gpu --build-arg BASE_IMG=$GPU_IMG .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment