Commit f1aa4e5d authored by Cresson Remi's avatar Cresson Remi
Browse files

COMP: move installed python modules in /usr/

1 merge request!90Draft: Move installed python modules in /usr/ folder
Pipeline #47423 passed with stages
in 70 minutes and 47 seconds
Showing with 7 additions and 10 deletions
+7 -10
......@@ -36,7 +36,7 @@ FROM otbtf-base AS builder
# A smaller value may be required to avoid OOM errors when building OTB GUI
ARG CPU_RATIO=1
RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3
RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include
WORKDIR /src/tf
RUN git config --global advice.detachedHead false
......@@ -79,10 +79,10 @@ RUN cd tensorflow \
# Installation
RUN cd tensorflow \
&& ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg \
&& pip3 install --no-cache-dir --prefix=/opt/otbtf /tmp/tensorflow_pkg/tensorflow*.whl \
&& ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \
&& pip3 install --no-cache-dir /tmp/tensorflow_pkg/tensorflow*.whl \
&& ls tensorflow/cc/saved_model/tag_constants.h \
&& ln -s /opt/otbtf/local/bin/* /opt/otbtf/bin \
&& ln -s $(find /opt/otbtf -type d -wholename "*/dist-packages/tensorflow/include") /opt/otbtf/include/tf \
&& ln -s $(find /usr/local/lib/python3.10/ -type d -wholename "*/dist-packages/tensorflow/include") /opt/otbtf/include/tf \
# The only missing header in the wheel
&& cp tensorflow/cc/saved_model/tag_constants.h /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \
&& cp tensorflow/cc/saved_model/signature_constants.h /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \
......@@ -150,18 +150,14 @@ RUN cd /src/otb/build/OTB/build \
-DOTB_WRAP_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DOTB_USE_TENSORFLOW=ON -DModule_OTBTensorflow=ON \
-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/local/lib/python3.10/dist-packages/tensorflow/libtensorflow_cc.so.2 \
-DTENSORFLOW_FRAMEWORK_LIB=/opt/otbtf/local/lib/python3.10/dist-packages/tensorflow/libtensorflow_framework.so.2 \
-DTENSORFLOW_CC_LIB=$(find /usr -type f -iname libtensorflow_cc.so.2) \
-DTENSORFLOW_FRAMEWORK_LIB=$(find /usr -type f -iname 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* ) \
&& ( $KEEP_SRC_OTB || rm -rf /src/otb ) \
&& rm -rf /root/.cache /tmp/*
# Symlink executable python files in PATH
RUN for f in /src/otbtf/python/*.py; do if [ -x $f ]; then ln -s $f /opt/otbtf/bin/; fi; done
# ----------------------------------------------------------------------------
# Final stage
FROM otbtf-base
......@@ -169,6 +165,7 @@ LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>"
# Copy files from intermediate stage
COPY --from=builder /opt/otbtf /opt/otbtf
COPY --from=builder /usr/local/lib/python3.10/dist-packages/ /usr/local/lib/python3.10/dist-packages/
COPY --from=builder /src /src
# System-wide ENV
......
Supports Markdown
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