diff --git a/Dockerfile b/Dockerfile index 251f5958791824092046accd4d06a3fdc7cd6a14..6685ee3c39cde88e79cf18a9242af1566a54544b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele && chmod +x /opt/otbtf/bin/bazelisk \ && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel -ARG BZL_TARGETS="//tensorflow/tools/lib_package:libtensorflow //tensorflow/tools/pip_package:build_pip_package" +ARG BZL_TARGETS="//tensorflow/tools/lib_package:libtensorflow //tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:build_pip_package" # "--config=opt" will enable 'march=native' (otherwise read comments about CPU compatibility and edit CC_OPT_FLAGS in build-env-tf.sh) ARG BZL_CONFIGS="--config=nogcp --config=noaws --config=nohdfs --config=opt --config=monolithic --config=v2" # "--compilation_mode opt" is already enabled by default (see tf repo .bazelrc and configure.py) @@ -65,7 +65,11 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi && ./configure \ && export TMP=/tmp/bazel \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS" \ - && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' + && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ + && tar xvf bazel-bin/tensorflow/tools/lib_package/libtensorflow.tar.gz -C /opt/otbtf/ \ + && ./tensorflow/c/generate-pc.sh -p /opt/otbtf -v $TF \ + && mkdir /opt/otbtf/lib/pkgconfig/ \ + && cp tensorflow.pc /opt/otbtf/lib/pkgconfig/ ' # Installation - split here if you want to check files ^ RUN cd tensorflow \ @@ -80,9 +84,10 @@ RUN cd tensorflow \ # Symlink external libs (required for MKL - libiomp5) && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ # Compress and save TF binaries - && ( ! $ZIP_TF_BIN || zip -9 -j --symlinks /opt/otbtf/tf-$TF.zip tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h bazel-bin/tensorflow/libtensorflow_cc.so* /tmp/tensorflow_pkg/tensorflow*.whl ) \ - # Cleaning - && rm -rf bazel-* /src/tf /root/.cache/ /tmp/* + && ( ! $ZIP_TF_BIN || zip -9 -j --symlinks /opt/otbtf/tf-$TF.zip tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h bazel-bin/tensorflow/libtensorflow_cc.so* /tmp/tensorflow_pkg/tensorflow*.whl ) + +# NO Cleaning (debug) +# && rm -rf bazel-* /src/tf /root/.cache/ /tmp/* ### OTB ARG GUI=false @@ -113,9 +118,6 @@ COPY . /src/otbtf #RUN git clone https://github.com/remicres/otbtf.git /src/otbtf RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf -# this is a desperate try (copy a previously compiled lib from host) -COPY libtensorflow_framework.so.2 /opt/otbtf/lib/python3/site-packages/tensorflow/. - # Rebuild OTB with module ARG KEEP_SRC_OTB=true RUN cd /src/otb/build/OTB/build \ @@ -128,7 +130,6 @@ RUN cd /src/otb/build/OTB/build \ -Dtensorflow_include_dir=/opt/otbtf/include/tf \ # Forcing TF>=2, this Dockerfile hasn't been tested with v1 + missing link for libtensorflow_framework.so in the wheel -DTENSORFLOW_CC_LIB=/opt/otbtf/lib/libtensorflow_cc.so.2 \ - -DTENSORFLOW_FRAMEWORK_LIB=/opt/otbtf/lib/python3/site-packages/tensorflow/libtensorflow_framework.so.2 \ && make install -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ # Cleaning && ( $GUI || rm -rf /opt/otbtf/bin/otbgui* ) \