From a537f248e4ac2d177300b5a48ce8dcee4ead3359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:09:55 +0200 Subject: [PATCH 001/317] ci: enh --- .gitlab-ci.yml | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd41bbf9..002a22c1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -94,14 +94,21 @@ docker image: stage: Static Analysis allow_failure: true -flake8: + +.py_static_analysis_base: extends: .static_analysis_base + rules: + - changes: + - otbtf/**/* + +flake8: + extends: .py_static_analysis_base script: - sudo pip install flake8 - flake8 $OTBTF_SRC/otbtf --exclude=tensorflow_v1x pylint: - extends: .static_analysis_base + extends: .py_static_analysis_base script: - sudo pip install pylint - pylint $OTBTF_SRC/otbtf --ignore=tensorflow_v1x @@ -115,6 +122,10 @@ codespell: cppcheck: extends: .static_analysis_base + rules: + - changes: + - app/**/* + - include/**/* script: - sudo apt update && sudo apt install cppcheck -y - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . @@ -123,6 +134,13 @@ cppcheck: stage: Documentation before_script: - pip install -r doc/doc_requirements.txt + rules: + - changes: + - doc/**/* + - *.md + - *.txt + - mkdocs.yml + - .readthedocs.yaml artifacts: paths: - public @@ -147,6 +165,18 @@ pages: .tests_base: tags: [godzilla] + rules: + - changes: + - app/**/* + - include/**/* + - otbtf/**/* + - test/**/* + - tools/**/* + - .gitlab-ci.yml + - Dockerfile + - otb-module.cmake + - CMakeLists.txt + - setup.py artifacts: paths: - $ARTIFACT_TEST_DIR/*.* @@ -260,7 +290,7 @@ deploy_cpu-dev-testing: extends: .docker_build_base stage: Ship only: - - master + - tags deploy_cpu: extends: .ship base -- GitLab From 8ca0392657a2455f9033b968c9c99765f5a8fe82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:10:04 +0200 Subject: [PATCH 002/317] doc: update links --- doc/app_sampling.md | 2 +- doc/app_training.md | 2 +- doc/docker_use.md | 22 ++++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/doc/app_sampling.md b/doc/app_sampling.md index b79ba7f4..9a9fc047 100644 --- a/doc/app_sampling.md +++ b/doc/app_sampling.md @@ -84,7 +84,7 @@ specific field of the input vector data. Typically, the *class* field can be used to generate a dataset suitable for a model that performs pixel wise classification. - + The application description can be displayed using: diff --git a/doc/app_training.md b/doc/app_training.md index eb3f4708..c1e731ef 100644 --- a/doc/app_training.md +++ b/doc/app_training.md @@ -47,7 +47,7 @@ patches images, a convenient method consist in reading patches images as numpy arrays using OTB applications (e.g. `ExtractROI`) or GDAL, then do a `numpy.reshape` to the dimensions wanted. - + The application description can be displayed using: diff --git a/doc/docker_use.md b/doc/docker_use.md index 81211066..323e4268 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -21,16 +21,18 @@ Read more in the following sections. Here is the list of the latest OTBTF docker images hosted on [dockerhub](https://hub.docker.com/u/mdl4eo). Since OTBTF >= 3.2.1 you can find the latest docker images on -[gitlab.irstea.fr](https://gitlab.irstea.fr/remi.cresson/otbtf/container_registry). - -| Name | Os | TF | OTB | Description | Dev files | Compute capability | -|------------------------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:4.3.1-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +[gitlab.irstea.fr](https://gitlab.irstea.fr/remi.cresson/otbtf/container_registry) +(before otbtf 4.3.0) and [forgemia](https://forgemia.inra.fr/orfeo-toolbox/otbtf/container_registry) +(since otbtf 4.3.1). + +| Name | Os | TF | OTB | Description | Dev files | Compute capability | +|---------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | +| **mdl4eo/otbtf:4.3.1-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| The list of older releases is available [here](#older-images). -- GitLab From 45ceeb8f79589077f9b4b37778cd02e8492abe0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:10:18 +0200 Subject: [PATCH 003/317] doc: update links --- otbtf/examples/tensorflow_v1x/__init__.py | 10 +++++----- setup.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/otbtf/examples/tensorflow_v1x/__init__.py b/otbtf/examples/tensorflow_v1x/__init__.py index c77256a4..796e4cbd 100644 --- a/otbtf/examples/tensorflow_v1x/__init__.py +++ b/otbtf/examples/tensorflow_v1x/__init__.py @@ -38,7 +38,7 @@ Predicted label is a single pixel, for an input patch of size 16x16 (for an inpu The learning rate of the training operator can be adjusted using the *lr* placeholder. The following figure summarizes this architecture. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_cnn.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_cnn.png" /> ## Generate the model @@ -143,7 +143,7 @@ otbcli_TensorflowModelServe \\ The `create_savedmodel_simple_fcn.py` script enables you to create a fully convolutional model which does not use any stride. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_fcnn.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_fcnn.png" /> Thanks to that, once trained this model can be applied on the image to produce a landcover map at the same resolution as the input image, in a fully @@ -208,7 +208,7 @@ available parameters. Let's train the M3 model from time series (TS) and Very High Resolution Satellite (VHRS) patches images. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/model_training.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/model_training.png" /> First, tell OTBTF that we want two sources: one for time series + one for VHR image @@ -255,7 +255,7 @@ otbcli_TensorflowModelTrain \\ Let's produce a land cover map using the M3 model from time series (TS) and Very High Resolution Satellite image (VHRS) -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/classif_map.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/classif_map.png" /> Since we provide time series as the reference source (*source1*), the output classes are estimated at the same resolution. This model can be run in @@ -363,7 +363,7 @@ See: Gaetano, R., Ienco, D., Ose, K., & Cresson, R. (2018). *A two-branch CNN architecture for land cover classification of PAN and MS imagery*. Remote Sensing, 10(11), 1746. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_pxs_fcn.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_pxs_fcn.png" /> Use `create_savedmodel_pxs_fcn.py` to generate this model. diff --git a/setup.py b/setup.py index 8519fb11..c1a6294a 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setuptools.setup( description="OTBTF: Orfeo ToolBox meets TensorFlow", long_description=long_description, long_description_content_type="text/markdown", - url="https://gitlab.irstea.fr/remi.cresson/otbtf", + url="https://github.com/remicres/otbtf", classifiers=[ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", -- GitLab From 8869511fbca39f0096d9a65cc7622fac00a25238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:12:41 +0200 Subject: [PATCH 004/317] ci: enh --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 002a22c1..64f888d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,8 +137,7 @@ cppcheck: rules: - changes: - doc/**/* - - *.md - - *.txt + - "*.{md,txt}" - mkdocs.yml - .readthedocs.yaml artifacts: -- GitLab From 01ca6840d333e5704ded6d599f617895f63b2568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:15:16 +0200 Subject: [PATCH 005/317] ci: enh --- .gitlab-ci.yml | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 64f888d4..a0c9c1e1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ image: $BRANCH_IMAGE workflow: rules: - if: $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ # Execute jobs in merge request context, or commit in master branch - + stages: - Build - Static Analysis @@ -36,7 +36,7 @@ stages: .docker_build_base: allow_failure: false - tags: [godzilla] + tags: [ godzilla ] image: docker:latest services: - name: docker:dind @@ -99,7 +99,7 @@ docker image: extends: .static_analysis_base rules: - changes: - - otbtf/**/* + - otbtf/**/* flake8: extends: .py_static_analysis_base @@ -124,8 +124,8 @@ cppcheck: extends: .static_analysis_base rules: - changes: - - app/**/* - - include/**/* + - app/**/* + - include/**/* script: - sudo apt update && sudo apt install cppcheck -y - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . @@ -136,10 +136,10 @@ cppcheck: - pip install -r doc/doc_requirements.txt rules: - changes: - - doc/**/* - - "*.{md,txt}" - - mkdocs.yml - - .readthedocs.yaml + - doc/**/* + - "*.{md,txt}" + - mkdocs.yml + - .readthedocs.yaml artifacts: paths: - public @@ -163,19 +163,19 @@ pages: - public .tests_base: - tags: [godzilla] + tags: [ godzilla ] rules: - changes: - - app/**/* - - include/**/* - - otbtf/**/* - - test/**/* - - tools/**/* - - .gitlab-ci.yml - - Dockerfile - - otb-module.cmake - - CMakeLists.txt - - setup.py + - app/**/* + - include/**/* + - otbtf/**/* + - test/**/* + - tools/**/* + - .gitlab-ci.yml + - Dockerfile + - otb-module.cmake + - CMakeLists.txt + - setup.py artifacts: paths: - $ARTIFACT_TEST_DIR/*.* @@ -186,7 +186,7 @@ ctest: extends: .tests_base stage: Test script: - - sudo apt update && sudo apt install -y git-lfs + - sudo apt update && sudo apt install -y git-lfs - cd /src/otb/otb && sudo git lfs fetch --all && sudo git lfs pull - cd $OTB_BUILD/ - sudo ctest -L OTBTensorflow @@ -212,7 +212,7 @@ crc_book: - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=$CI_PROJECT_DIR/report_tutorial.xml $OTBTF_SRC/test/tutorial_unittest.py after_script: - cp $CRC_BOOK_TMP/*.* $ARTIFACT_TEST_DIR/ - + sr4rs: extends: .applications_test_base script: -- GitLab From 579bafb7bdc26f655eaadc9042d1761c1a885a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:16:27 +0200 Subject: [PATCH 006/317] ci: enh --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a0c9c1e1..7a8f130e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,9 +137,7 @@ cppcheck: rules: - changes: - doc/**/* - - "*.{md,txt}" - - mkdocs.yml - - .readthedocs.yaml + artifacts: paths: - public -- GitLab From cb9b92822de4a508e3022784db51d4e1dfc44021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:26:29 +0200 Subject: [PATCH 007/317] ci: enh --- .gitlab-ci.yml | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7a8f130e..2becb355 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -130,35 +130,26 @@ cppcheck: - sudo apt update && sudo apt install cppcheck -y - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . -.doc_base: +pages: stage: Documentation - before_script: - - pip install -r doc/doc_requirements.txt + variables: + PTH: "public_test" rules: - changes: - doc/**/* - - artifacts: - paths: - - public - - public_test - -pages_test: - extends: .doc_base - except: - - master - script: - - mkdocs build --site-dir public_test - -pages: - extends: .doc_base - only: - - master + - "*.{md,txt}" + - mkdocs.yml + - .readthedocs.yaml + - if: $CI_COMMIT_REF_NAME == /master/ + variables: + PTH: "public" + before_script: + - pip install -r doc/doc_requirements.txt script: - - mkdocs build --site-dir public + - mkdocs build --site-dir $PTH artifacts: paths: - - public + - $PTH .tests_base: tags: [ godzilla ] -- GitLab From 3d58d28a458da057f3297a59d3b9fcfbcf7a237a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Wed, 24 Apr 2024 16:30:11 +0200 Subject: [PATCH 008/317] ci: enh --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2becb355..17526bf7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,7 +45,7 @@ stages: timeout: 10 hours -docker image: +dev docker image build: extends: .docker_build_base stage: Build except: -- GitLab From 5972934ea6265fe3a4c05d17702faf34a9f1864b Mon Sep 17 00:00:00 2001 From: Cresson Remi <remi.cresson@irstea.fr> Date: Fri, 30 Aug 2024 13:17:12 +0200 Subject: [PATCH 009/317] COMP: move tensorflow version to 2.16 --- Dockerfile | 3 +-- RELEASE_NOTES.txt | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 904431e3..ea38e00f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,8 +37,7 @@ RUN git config --global advice.detachedHead false ### TF -ARG TF=v2.14.0 -ARG TENSORRT +ARG TF=v2.16.0 # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index af4e4429..92f8d2c7 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,7 @@ +Version 4.3.2 (01 sep 2024) +---------------------------------------------------------------- +* Move TensorFlow to version 2.16.0 + Version 4.3.1 (02 jan 2024) ---------------------------------------------------------------- * Fix a bug with PROJ due to OTB 9 packaging -- GitLab From 9034de0cfdf2da6044969d33b13f98277e1478d6 Mon Sep 17 00:00:00 2001 From: Cresson Remi <remi.cresson@irstea.fr> Date: Fri, 30 Aug 2024 13:22:09 +0200 Subject: [PATCH 010/317] COMP: move tensorflow version to 2.16.2 --- Dockerfile | 2 +- RELEASE_NOTES.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ea38e00f..02884919 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ RUN git config --global advice.detachedHead false ### TF -ARG TF=v2.16.0 +ARG TF=v2.16.2 # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 92f8d2c7..7c4cb06b 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,6 +1,6 @@ Version 4.3.2 (01 sep 2024) ---------------------------------------------------------------- -* Move TensorFlow to version 2.16.0 +* Move TensorFlow to version 2.16.2 Version 4.3.1 (02 jan 2024) ---------------------------------------------------------------- -- GitLab From 269a0c4d229f616d8d855152f912199eda8aefec Mon Sep 17 00:00:00 2001 From: Cresson Remi <remi.cresson@irstea.fr> Date: Fri, 30 Aug 2024 20:45:56 +0200 Subject: [PATCH 011/317] Update 3 files - /doc/docker_use.md - /README.md - /Dockerfile --- Dockerfile | 2 +- README.md | 4 ++-- doc/docker_use.md | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02884919..f0e6a334 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN pip install --no-cache-dir pip --upgrade # In case NumPy version is conflicting with system's gdal dep and may require venv ARG NUMPY_SPEC="" # This is to avoid https://github.com/tensorflow/tensorflow/issues/61551 -ARG PROTO_SPEC="==4.23.*" +ARG PROTO_SPEC="" RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$NUMPY_SPEC" "protobuf$PROTO_SPEC" packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing diff --git a/README.md b/README.md index 9704bb43..dc7683d1 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ The documentation is available on [otbtf.readthedocs.io](https://otbtf.readthedo You can use our latest GPU enabled docker images. ```bash -docker run --runtime=nvidia -ti mdl4eo/otbtf:latest-gpu otbcli_PatchesExtraction -docker run --runtime=nvidia -ti mdl4eo/otbtf:latest-gpu python -c "import otbtf" +docker run --gpus=all -ti mdl4eo/otbtf:latest-gpu otbcli_PatchesExtraction +docker run --gpus=all -ti mdl4eo/otbtf:latest-gpu python -c "import otbtf" ``` You can also build OTBTF from sources (see the documentation) diff --git a/doc/docker_use.md b/doc/docker_use.md index 81211066..d20e4bb1 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -21,7 +21,8 @@ Read more in the following sections. Here is the list of the latest OTBTF docker images hosted on [dockerhub](https://hub.docker.com/u/mdl4eo). Since OTBTF >= 3.2.1 you can find the latest docker images on -[gitlab.irstea.fr](https://gitlab.irstea.fr/remi.cresson/otbtf/container_registry). +[gitlab.irstea.fr](https://gitlab.irstea.fr/remi.cresson/otbtf/container_registry) for +versions <= 4.3.0 and [forgemia.inra.fr](https://forgemia.inra.fr/orfeo-toolbox/otbtf/container_registry/) since version 4.3.1. | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | @@ -29,8 +30,8 @@ Since OTBTF >= 3.2.1 you can find the latest docker images on | **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| The list of older releases is available [here](#older-images). @@ -57,7 +58,7 @@ docker run --runtime=nvidia -ti mdl4eo/otbtf:latest-gpu bash With Docker version including and after 19.03 : ```bash -docker run --gpus all -ti mdl4eo/otbtf:latest-gpu bash +docker run --gpus=all -ti mdl4eo/otbtf:latest-gpu bash ``` You can find some details on the **GPU docker image** and some **docker tips -- GitLab From ee91a32408aa3fd9ce3b258477ea23fd230c89cf Mon Sep 17 00:00:00 2001 From: Cresson Remi <remi.cresson@irstea.fr> Date: Fri, 30 Aug 2024 23:11:47 +0200 Subject: [PATCH 012/317] Update 2 files - /tools/docker/build-deps-cli.txt - /Dockerfile --- Dockerfile | 2 +- tools/docker/build-deps-cli.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f0e6a334..cf26f187 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,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:libtensorflow_cc.so //tensorflow/tools/pip_package:build_pip_package" +ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # "--config=opt" will enable 'march=native' # (otherwise read comments about CPU compatibility and edit CC_OPT_FLAGS in diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index 49a4572b..fe8503a9 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -22,4 +22,6 @@ unzip vim wget sudo -zip \ No newline at end of file +zip +llvm-17 +clang-17 -- GitLab From e16f422357c9f15a1432d81d62b435777889aae0 Mon Sep 17 00:00:00 2001 From: Cresson Remi <remi.cresson@irstea.fr> Date: Fri, 30 Aug 2024 23:15:49 +0200 Subject: [PATCH 013/317] Update file build-deps-cli.txt --- tools/docker/build-deps-cli.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index fe8503a9..49a4572b 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -22,6 +22,4 @@ unzip vim wget sudo -zip -llvm-17 -clang-17 +zip \ No newline at end of file -- GitLab From 7fd9281bf50cbed2a824fe58f9eb53fab3506a8a Mon Sep 17 00:00:00 2001 From: Cresson Remi <remi.cresson@irstea.fr> Date: Fri, 30 Aug 2024 23:28:26 +0200 Subject: [PATCH 014/317] Update file Dockerfile --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index cf26f187..22f95a61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN pip install --no-cache-dir pip --upgrade # In case NumPy version is conflicting with system's gdal dep and may require venv ARG NUMPY_SPEC="" # This is to avoid https://github.com/tensorflow/tensorflow/issues/61551 -ARG PROTO_SPEC="" +ARG PROTO_SPEC="==4.23.*" RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$NUMPY_SPEC" "protobuf$PROTO_SPEC" packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing @@ -37,14 +37,15 @@ RUN git config --global advice.detachedHead false ### TF -ARG TF=v2.16.2 +ARG TF=v2.16.1 +ARG TENSORRT # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ && chmod +x /opt/otbtf/bin/bazelisk \ && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel -ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" +ARG BZL_TARGETS="//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 -- GitLab From e53d34db7e6454b2958e7087e5c0294200ec7d21 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:15:20 +0200 Subject: [PATCH 015/317] Move back OTB build flags in Dockerfile --- Dockerfile | 11 ++++++++++- tools/docker/build-flags-otb.txt | 8 -------- 2 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 tools/docker/build-flags-otb.txt diff --git a/Dockerfile b/Dockerfile index 22f95a61..a4dc7d1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -125,7 +125,16 @@ RUN cd /src/otb/otb \ # Possible ENH: superbuild-all-dependencies switch, with separated build-deps-minimal.txt and build-deps-otbcli.txt) #&& if $OTB_SUPERBUILD_ALL; then sed -i -r "s/-DUSE_SYSTEM_([A-Z0-9]*)=ON/-DUSE_SYSTEM_\1=OFF/ " ../build-flags-otb.txt; fi \ && OTB_FLAGS=$(cat "../build-flags-otb.txt") \ - && cmake ../otb/SuperBuild -DCMAKE_INSTALL_PREFIX=/opt/otbtf $OTB_FLAGS \ + && cmake ../otb/SuperBuild \ + -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ + -DOTB_BUILD_FeaturesExtraction=ON \ + -DOTB_BUILD_Hyperspectral=ON \ + -DOTB_BUILD_Learning=ON \ + -DOTB_BUILD_Miscellaneous=ON \ + -DOTB_BUILD_RemoteModules=ON \ + -DOTB_BUILD_SAR=ON \ + -DOTB_BUILD_Segmentation=ON \ + -DOTB_BUILD_StereoProcessing=ON \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") ### OTBTF - copy (without .git/) or clone repository diff --git a/tools/docker/build-flags-otb.txt b/tools/docker/build-flags-otb.txt deleted file mode 100644 index 8c9b0123..00000000 --- a/tools/docker/build-flags-otb.txt +++ /dev/null @@ -1,8 +0,0 @@ --DOTB_BUILD_FeaturesExtraction=ON --DOTB_BUILD_Hyperspectral=ON --DOTB_BUILD_Learning=ON --DOTB_BUILD_Miscellaneous=ON --DOTB_BUILD_RemoteModules=ON --DOTB_BUILD_SAR=ON --DOTB_BUILD_Segmentation=ON --DOTB_BUILD_StereoProcessing=ON -- GitLab From d2736a9795f6158ca5e06e2e0c42301ef3e4763b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:15:42 +0200 Subject: [PATCH 016/317] Add missing patchelf --- tools/docker/build-deps-cli.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index 49a4572b..134bea27 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -12,6 +12,7 @@ lsb-release make nano patch +patchelf pkg-config python3-dev python3-pip @@ -22,4 +23,4 @@ unzip vim wget sudo -zip \ No newline at end of file +zip -- GitLab From 838ffe4e148dc1a3c8b11956936a72403e8c09e7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:16:39 +0200 Subject: [PATCH 017/317] Enable useful optimizations by default --- tools/docker/build-env-tf.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index e7703f01..38c2b2cd 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -1,11 +1,7 @@ -### TF - bazel build env variables - -# As in official TF wheels, you'll need to remove "-march=native" to ensure -# portability (avoid AVX2 / AVX512 compatibility issues) -# You could also add CPUs instructions one by one, in this example to avoid -# only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 -#export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" -export CC_OPT_FLAGS="-march=native -Wno-sign-compare" +#!/usr/bin/bash +# As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues +# Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 +export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" export GCC_HOST_COMPILER_PATH=$(which gcc) export PYTHON_BIN_PATH=$(which python) export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')" -- GitLab From 5ef6037fb5c4629c785dc00c4a4a2605a7375cdc Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:17:18 +0200 Subject: [PATCH 018/317] Add missing variable to build TF>2.16 with system python --- tools/docker/build-env-tf.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 38c2b2cd..f22ba871 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -3,6 +3,8 @@ # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" export GCC_HOST_COMPILER_PATH=$(which gcc) +# Required variable since TF 2.16 +export TF_PYTHON_VERSION=$(python3 -c 'import sys; print(sys.version[:4])') export PYTHON_BIN_PATH=$(which python) export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')" export TF_DOWNLOAD_CLANG=0 @@ -20,11 +22,6 @@ export TF_NEED_CLANG=0 # For MKL support BZL_CONFIGS+=" --config=mkl" #export TF_DOWNLOAD_MKL=1 #export TF_NEED_MKL=0 -# Needed BZL_CONFIGS=" --config=nogcp --config=noaws --config=nohdfs" -#export TF_NEED_S3=0 -#export TF_NEED_AWS=0 -#export TF_NEED_GCP=0 -#export TF_NEED_HDFS=0 ## GPU export TF_NEED_ROCM=0 -- GitLab From f811fd102d26cdc914e13eed4a52d3f706b72ecb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:17:50 +0200 Subject: [PATCH 019/317] Bump versions --- .gitlab-ci.yml | 4 ++-- Dockerfile | 7 +++---- tools/docker/multibuild.sh | 42 +++++++------------------------------- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd41bbf9..ee5bab9a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ variables: - OTBTF_VERSION: 4.3.1 + OTBTF_VERSION: 4.3.2 OTB_BUILD: /src/otb/build/OTB/build # Local OTB build directory OTBTF_SRC: /src/otbtf # Local OTBTF source directory OTB_TEST_DIR: $OTB_BUILD/Testing/Temporary # OTB testing directory @@ -17,7 +17,7 @@ variables: DOCKERHUB_BASE: mdl4eo/otbtf DOCKERHUB_IMAGE_BASE: ${DOCKERHUB_BASE}:${OTBTF_VERSION} CPU_BASE_IMG: ubuntu:22.04 - GPU_BASE_IMG: nvidia/cuda:12.0.1-cudnn8-devel-ubuntu22.04 + GPU_BASE_IMG: nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 image: $BRANCH_IMAGE diff --git a/Dockerfile b/Dockerfile index a4dc7d1d..91799b0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,8 +36,8 @@ WORKDIR /src/tf RUN git config --global advice.detachedHead false ### TF - -ARG TF=v2.16.1 +ARG TF=v2.17.0 +# 2.17 will be the last release to support TensorRT ARG TENSORRT # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) @@ -89,8 +89,7 @@ RUN cd tensorflow \ && rm -rf bazel-* /src/tf /root/.cache/ /tmp/* ### OTB - -ARG OTB=release-9.0 +ARG OTB=release-9.1 ARG OTBTESTS=false RUN mkdir /src/otb diff --git a/tools/docker/multibuild.sh b/tools/docker/multibuild.sh index 9373d292..b015de26 100644 --- a/tools/docker/multibuild.sh +++ b/tools/docker/multibuild.sh @@ -1,6 +1,6 @@ #!/bin/bash # Various docker builds using bazel cache -RELEASE=3.5 +RELEASE=4.3.2 CPU_IMG=ubuntu:22.04 GPU_IMG=nvidia/cuda:12.1.0-devel-ubuntu22.04 @@ -13,42 +13,19 @@ buchgr/bazel-remote-cache --max_size=20 ### CPU images -# CPU-Dev -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-cpu-dev \ ---build-arg BASE_IMG=$CPU_IMG \ ---build-arg KEEP_SRC_OTB=true - # CPU docker build . \ --network='host' \ -t mdl4eo/otbtf:$RELEASE-cpu \ ---build-arg BASE_IMG=$CPU_IMG - -# CPU-GUI -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-cpu-gui \ --build-arg BASE_IMG=$CPU_IMG \ ---build-arg GUI=true +--build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ -### CPU images with Intel MKL support -MKL_CONF="--config=nogcp --config=noaws --config=nohdfs --config=mkl --config=opt" - -# CPU-MKL -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-cpu-mkl \ ---build-arg BASE_IMG=$CPU_IMG \ ---build-arg BZL_CONFIGS="$MKL_CONF" - -# CPU-MKL-Dev +# CPU-Dev docker build . \ --network='host' \ --t mdl4eo/otbtf:$RELEASE-cpu-mkl-dev \ +-t mdl4eo/otbtf:$RELEASE-cpu-dev \ --build-arg BASE_IMG=$CPU_IMG \ ---build-arg BZL_CONFIGS="$MKL_CONF" \ +--build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ --build-arg KEEP_SRC_OTB=true ### GPU enabled images @@ -59,17 +36,12 @@ docker build . \ --network='host' \ -t mdl4eo/otbtf:$RELEASE-gpu-dev \ --build-arg BASE_IMG=$GPU_IMG \ +--build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ --build-arg KEEP_SRC_OTB=true # GPU-Dev docker build . \ --network='host' \ -t mdl4eo/otbtf:$RELEASE-gpu \ ---build-arg BASE_IMG=$GPU_IMG - -# GPU-GUI -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-gpu-gui \ +--build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ --build-arg BASE_IMG=$GPU_IMG \ ---build-arg GUI=true -- GitLab From dfa000b87285def4b33b05f7942a2480348da7cd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:18:29 +0200 Subject: [PATCH 020/317] Remove empty bazel options and cache by default --- .gitlab-ci.yml | 17 ++++++----------- Dockerfile | 15 +++++++-------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee5bab9a..d807ec65 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,10 +67,8 @@ docker image: --cache-from $CACHE_IMAGE_BUILDER --tag $CACHE_IMAGE_BUILDER --build-arg KEEP_SRC_OTB="true" - --build-arg BZL_CONFIGS="" --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=$BAZELCACHE" --build-arg OTBTESTS="true" "." - docker push $CACHE_IMAGE_BUILDER @@ -82,10 +80,8 @@ docker image: --cache-from $DEV_IMAGE --tag $BRANCH_IMAGE --build-arg KEEP_SRC_OTB="true" - --build-arg BZL_CONFIGS="" --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=$BAZELCACHE" --build-arg OTBTESTS="true" "." - docker push $BRANCH_IMAGE @@ -272,10 +268,10 @@ deploy_cpu: DOCKERHUB_LATEST: $DOCKERHUB_BASE:latest script: # cpu - - docker build --build-arg BZL_OPTIONS="--remote_cache=$BAZELCACHE" --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_CONFIGS="" . + - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG . - docker push $IMAGE_CPU # cpu-dev - - docker build --build-arg BZL_OPTIONS="--remote_cache=$BAZELCACHE" --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_CONFIGS="" --build-arg KEEP_SRC_OTB=true . + - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_CPUDEV # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -299,16 +295,16 @@ deploy_gpu: DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu-opt - - docker build --build-arg BZL_OPTIONS="--remote_cache=$BAZELCACHE" --tag $IMAGE_GPUOPT --build-arg BASE_IMG=$GPU_BASE_IMG . + - docker build --tag $IMAGE_GPUOPT --build-arg BASE_IMG=$GPU_BASE_IMG . - docker push $IMAGE_GPUOPT # gpu-opt-dev - - docker build --build-arg BZL_OPTIONS="--remote_cache=$BAZELCACHE" --tag $IMAGE_GPUOPTDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . + - docker build --tag $IMAGE_GPUOPTDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_GPUOPTDEV # gpu-basic - - docker build --build-arg BZL_OPTIONS="--remote_cache=$BAZELCACHE" --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg BZL_CONFIGS="" . + - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG . - docker push $IMAGE_GPU # gpu-basic-dev - - docker build --build-arg BZL_OPTIONS="--remote_cache=$BAZELCACHE" --tag $IMAGE_GPUDEV --build-arg BZL_CONFIGS="" --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . + - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_GPUDEV # push gpu-basic* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -319,4 +315,3 @@ deploy_gpu: # latest-gpu = gpu image - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST - docker push $DOCKERHUB_GPULATEST - diff --git a/Dockerfile b/Dockerfile index 91799b0d..0292ae50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,14 +47,13 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele ARG BZL_TARGETS="//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" - -# "--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" +# Using "--config=opt" here will enable 'march=native' +# (see comments about CPU compatibility and edit CC_OPT_FLAGS in build-env-tf.sh) +# To disable gcp, aws and hdfs : BZL_CONFIGS="--config=nogcp --config=noaws --config=nohdfs" +ARG BZL_CONFIGS + +# You may add --remote_cache=http://localhost:9090, see example in tools/docker/multibuild.sh +ARG BZL_OPTIONS="--verbose_failures" # Build ARG ZIP_TF_BIN=false -- GitLab From 031803d1f30fc1087bd1d2d43b8bc314be6222a9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:19:02 +0200 Subject: [PATCH 021/317] Ensure numpy<2, and let bazel choose the right protobuf version --- Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0292ae50..39edd739 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,11 +17,9 @@ RUN apt-get update -y && apt-get upgrade -y \ RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip # Upgrade pip RUN pip install --no-cache-dir pip --upgrade -# In case NumPy version is conflicting with system's gdal dep and may require venv -ARG NUMPY_SPEC="" -# This is to avoid https://github.com/tensorflow/tensorflow/issues/61551 -ARG PROTO_SPEC="==4.23.*" -RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$NUMPY_SPEC" "protobuf$PROTO_SPEC" packaging requests \ +# Numpy 2 support in TF is planned for 2.18, but isn't supported by most libraries for now +ARG NUMPY_SPEC="<2" +RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$NUMPY_SPEC" packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing # ---------------------------------------------------------------------------- -- GitLab From f2f3ac6684323d8d8bac52d62769a3bdd4b90bd1 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:25:15 +0200 Subject: [PATCH 022/317] Cleaning Dockerfile comments --- Dockerfile | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 39edd739..68211b66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -##### Configurable Dockerfile with multi-stage build - Author: Vincent Delbar -## Mandatory +##### Configurable Dockerfile with multi-stage build +# Mandatory ARG BASE_IMG # ---------------------------------------------------------------------------- @@ -8,12 +8,13 @@ FROM $BASE_IMG AS otbtf-base WORKDIR /tmp ### System packages -COPY tools/docker/build-deps-*.txt ./ +COPY tools/docker/build-deps-cli.txt ./ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -y && apt-get upgrade -y \ && cat build-deps-cli.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* -### Python3 links and pip packages + +### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip # Upgrade pip RUN pip install --no-cache-dir pip --upgrade @@ -68,7 +69,6 @@ RUN cd tensorflow \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' # Installation -RUN apt update && apt install -y patchelf 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 \ @@ -118,9 +118,6 @@ RUN cd /src/otb/otb \ && cd build \ && if $OTBTESTS; then \ echo "-DBUILD_TESTING=ON" >> ../build-flags-otb.txt; fi \ - # Possible ENH: superbuild-all-dependencies switch, with separated build-deps-minimal.txt and build-deps-otbcli.txt) - #&& if $OTB_SUPERBUILD_ALL; then sed -i -r "s/-DUSE_SYSTEM_([A-Z0-9]*)=ON/-DUSE_SYSTEM_\1=OFF/ " ../build-flags-otb.txt; fi \ - && OTB_FLAGS=$(cat "../build-flags-otb.txt") \ && cmake ../otb/SuperBuild \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ -DOTB_BUILD_FeaturesExtraction=ON \ @@ -173,8 +170,7 @@ ENV PYTHONPATH="/opt/otbtf/lib/python3/dist-packages:/opt/otbtf/lib/otb/python" ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" RUN pip install -e /src/otbtf -# Default user, directory and command (bash is the entrypoint when using -# 'docker create') +# Default user, directory and command (bash will be the default entrypoint) RUN useradd -s /bin/bash -m otbuser WORKDIR /home/otbuser @@ -184,10 +180,8 @@ RUN if $SUDO; then \ usermod -a -G sudo otbuser \ && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi -# Set /src/otbtf ownership to otbuser (but you still need 'sudo -i' in order -# to rebuild TF or OTB) +# Set /src/otbtf ownership to otbuser (you'll need root user in order to rebuild OTB) RUN chown -R otbuser:otbuser /src/otbtf - # This won't prevent ownership problems with volumes if you're not UID 1000 USER otbuser -- GitLab From 3f90595361df3625d7aa00a5603d71e8bb42993e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:31:11 +0200 Subject: [PATCH 023/317] Removed file build-flags-otb --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 68211b66..094373b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -93,7 +93,6 @@ RUN mkdir /src/otb WORKDIR /src/otb # SuperBuild OTB -COPY tools/docker/build-flags-otb.txt ./ RUN apt-get update -y \ && apt-get install --reinstall ca-certificates -y \ && update-ca-certificates \ -- GitLab From c09057cae4ec469d1c183d3449afdea312a0cde9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:35:19 +0200 Subject: [PATCH 024/317] Add compute capability 8.9 --- tools/docker/build-env-tf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index f22ba871..9ca5fc43 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -40,7 +40,7 @@ if [ ! -z $CUDA_TOOLKIT_PATH ] ; then fi export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_TOOLKIT_PATH/lib64:$CUDA_TOOLKIT_PATH/lib64/stubs" export TF_CUDA_VERSION=$(echo $CUDA_TOOLKIT_PATH | sed -r 's/.*\/cuda-(.*)/\1/') - export TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.1,7.0,7.5,8.0,8.6,9.0" + export TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0" export TF_NEED_CUDA=1 export TF_CUDA_CLANG=0 export TF_NEED_TENSORRT=0 -- GitLab From 197c7c44c5609b62333d586ba605c1443f51c684 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 15:44:09 +0200 Subject: [PATCH 025/317] Fix for renamed bazel target build_pip_package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 094373b6..43096b48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,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:libtensorflow_cc.so //tensorflow/tools/pip_package:build_pip_package" +ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:build_pip_package.py" # Using "--config=opt" here will enable 'march=native' # (see comments about CPU compatibility and edit CC_OPT_FLAGS in build-env-tf.sh) -- GitLab From 4b94ec27d8069c371a022c0e0710b4f0115abb5c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 16:00:53 +0200 Subject: [PATCH 026/317] Target pip_package:wheel --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 43096b48..58613145 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,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:libtensorflow_cc.so //tensorflow/tools/pip_package:build_pip_package.py" +ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # Using "--config=opt" here will enable 'march=native' # (see comments about CPU compatibility and edit CC_OPT_FLAGS in build-env-tf.sh) -- GitLab From 094d1fdd04761a4eb502c5e328e789a310f10c74 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 16:01:29 +0200 Subject: [PATCH 027/317] Move to clang 17 --- tools/docker/build-deps-cli.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index 134bea27..99a3607b 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -3,8 +3,8 @@ ca-certificates curl cmake file -g++ -gcc +clang-17 +llvm-17 git libc6-dev libtool -- GitLab From 2f5a53aacfcb3922bedb5c56e41fb1bec62ddab2 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 16:25:22 +0200 Subject: [PATCH 028/317] Install clang17 from github --- Dockerfile | 6 ++++++ tools/docker/build-deps-cli.txt | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 58613145..8083a805 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,12 @@ RUN apt-get update -y && apt-get upgrade -y \ && cat build-deps-cli.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* +# Install clang+llvm from github +ARG CLANG_VERSION=17.0.6 +RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz \ + && tar -xvf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz -C /usr/local --strip-components=1 \ + && rm -rf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz + ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip # Upgrade pip diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index 99a3607b..3e2fa180 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -3,8 +3,6 @@ ca-certificates curl cmake file -clang-17 -llvm-17 git libc6-dev libtool -- GitLab From 5d91e7514ced4216029728e0c9876619253add02 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 16:26:32 +0200 Subject: [PATCH 029/317] Remove gcc path variable --- tools/docker/build-env-tf.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 9ca5fc43..777db1a6 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -2,7 +2,6 @@ # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" -export GCC_HOST_COMPILER_PATH=$(which gcc) # Required variable since TF 2.16 export TF_PYTHON_VERSION=$(python3 -c 'import sys; print(sys.version[:4])') export PYTHON_BIN_PATH=$(which python) -- GitLab From f88259617646df30cc7a6e40e19315daacba00c5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 16:38:29 +0200 Subject: [PATCH 030/317] Add missing xz dependency --- Dockerfile | 2 +- tools/docker/build-deps-cli.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8083a805..23add826 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ RUN apt-get update -y && apt-get upgrade -y \ # Install clang+llvm from github ARG CLANG_VERSION=17.0.6 -RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz \ +RUN wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz \ && tar -xvf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz -C /usr/local --strip-components=1 \ && rm -rf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index 3e2fa180..42373d6a 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -21,4 +21,5 @@ unzip vim wget sudo +xz-utils zip -- GitLab From b3c1236ac82f21203888618df87ec22daf5c0c28 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 16:55:04 +0200 Subject: [PATCH 031/317] Remove untar verbose arg --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 23add826..396e26ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get update -y && apt-get upgrade -y \ # Install clang+llvm from github ARG CLANG_VERSION=17.0.6 RUN wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz \ - && tar -xvf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz -C /usr/local --strip-components=1 \ + && tar -xf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz -C /usr/local --strip-components=1 \ && rm -rf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz ### Python3 environment -- GitLab From fbeaf13cfb20f53502466920d731963d6ae4f720 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 17:04:26 +0200 Subject: [PATCH 032/317] Remove gpu opt build since some opt are enabled by default (except avx512) --- .gitlab-ci.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d807ec65..0d5380bf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -288,25 +288,17 @@ deploy_gpu: variables: IMAGE_GPU: $CI_REGISTRY_PUBIMG-gpu IMAGE_GPUDEV: $CI_REGISTRY_PUBIMG-gpu-dev - IMAGE_GPUOPT: $CI_REGISTRY_PUBIMG-gpu-opt - IMAGE_GPUOPTDEV: $CI_REGISTRY_PUBIMG-gpu-opt-dev DOCKERHUB_GPU: $DOCKERHUB_IMAGE_BASE-gpu DOCKERHUB_GPUDEV: $DOCKERHUB_IMAGE_BASE-gpu-dev DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: - # gpu-opt - - docker build --tag $IMAGE_GPUOPT --build-arg BASE_IMG=$GPU_BASE_IMG . - - docker push $IMAGE_GPUOPT - # gpu-opt-dev - - docker build --tag $IMAGE_GPUOPTDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . - - docker push $IMAGE_GPUOPTDEV - # gpu-basic + # gpu - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG . - docker push $IMAGE_GPU - # gpu-basic-dev + # gpu-dev - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_GPUDEV - # push gpu-basic* images on dockerhub + # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - docker tag $IMAGE_GPU $DOCKERHUB_GPU - docker push $DOCKERHUB_GPU -- GitLab From 4df3253c1d14830a05770e9b1c4e651bafa8c068 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 17:04:35 +0200 Subject: [PATCH 033/317] Ensure clang is used by bazel --- tools/docker/build-env-tf.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 777db1a6..963efa9d 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -1,4 +1,7 @@ #!/usr/bin/bash +export BAZEL_COMPILER=$(which clang) +export CC=$(which clang) +export CXX=$(which clang++) # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" @@ -47,3 +50,6 @@ if [ ! -z $CUDA_TOOLKIT_PATH ] ; then export TF_CUDNN_VERSION=$(sed -n 's/^#define CUDNN_MAJOR\s*\(.*\).*/\1/p' $CUDNN_INSTALL_PATH/include/cudnn_version.h) export TF_NCCL_VERSION=2 fi + +echo "Starting build with the following environment variables:" +env -- GitLab From d534371aede7099145d89e49c98c539e7d38ae0c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 17:08:57 +0200 Subject: [PATCH 034/317] Update pip install to new tf wheel location --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 396e26ca..54e295ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,8 +76,7 @@ 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 \ + && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ && ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \ && 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 \ -- GitLab From a25bc1efc3b1e52d439de73a3a3a4a349f9c3296 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 17:38:57 +0200 Subject: [PATCH 035/317] Remove env BAZEL_COMPILER --- tools/docker/build-env-tf.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 963efa9d..1b79c02b 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -1,5 +1,4 @@ #!/usr/bin/bash -export BAZEL_COMPILER=$(which clang) export CC=$(which clang) export CXX=$(which clang++) # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues -- GitLab From 493cae6d9e4024c1e6b2e2010bbdaae6752d110a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 17:56:15 +0200 Subject: [PATCH 036/317] Use clang installation script --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 54e295ab..042305e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,12 @@ RUN apt-get update -y && apt-get upgrade -y \ && cat build-deps-cli.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* -# Install clang+llvm from github +# Install clang+llvm ARG CLANG_VERSION=17.0.6 -RUN wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz \ - && tar -xf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz -C /usr/local --strip-components=1 \ - && rm -rf clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-22.04.tar.xz +RUN wget https://apt.llvm.org/llvm.sh \ + && chmod +x llvm.sh \ + && ./llvm.sh $CLANG_VERSION \ + && rm -f llvm.sh ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip -- GitLab From c2623644ef755b6262dbfad25d56d16497b255ca Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 18:01:35 +0200 Subject: [PATCH 037/317] Clang version arg is major --- Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 042305e0..76d3f44b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,11 +15,8 @@ RUN apt-get update -y && apt-get upgrade -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Install clang+llvm -ARG CLANG_VERSION=17.0.6 -RUN wget https://apt.llvm.org/llvm.sh \ - && chmod +x llvm.sh \ - && ./llvm.sh $CLANG_VERSION \ - && rm -f llvm.sh +ARG CLANG=17 +RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh $CLANG ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip -- GitLab From 652e556b9f9023237d37007d435c2a21dee9132f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 18:04:02 +0200 Subject: [PATCH 038/317] Add missing dependencies to add apt repo --- tools/docker/build-deps-cli.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index 42373d6a..a9c232a4 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -4,6 +4,7 @@ curl cmake file git +gpg libc6-dev libtool lsb-release @@ -17,6 +18,7 @@ python3-pip python3-setuptools python3-venv swig +software-properties-common unzip vim wget -- GitLab From 8a457f30e30ef4b76c79f5f6d4fef99134faf614 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 18:16:02 +0200 Subject: [PATCH 039/317] Add env var BAZEL_COMPILER --- tools/docker/build-env-tf.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 1b79c02b..4763199e 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -1,6 +1,7 @@ #!/usr/bin/bash export CC=$(which clang) export CXX=$(which clang++) +export BAZEL_COMPILER=$(which clang) # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" -- GitLab From 3433afe0e75397236a7f62e21e150e03a42a66b1 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 18:17:42 +0200 Subject: [PATCH 040/317] Update docker related docs --- doc/docker_build.md | 20 +++---- doc/docker_use.md | 124 +++++++++++++++++++++++--------------------- 2 files changed, 71 insertions(+), 73 deletions(-) diff --git a/doc/docker_build.md b/doc/docker_build.md index debc1ea8..6ce73ec1 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -17,7 +17,7 @@ order to preserve OTB git directory. ```bash CPU_IMG=ubuntu:22.04 -GPU_IMG=nvidia/cuda:12.1.0-devel-ubuntu22.04 +GPU_IMG=nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 ``` ### Default arguments @@ -25,21 +25,15 @@ GPU_IMG=nvidia/cuda:12.1.0-devel-ubuntu22.04 ```bash BASE_IMG # mandatory CPU_RATIO=1 -GUI=false -NUMPY_SPEC="==1.19.*" -TF=v2.12.0 -OTB=8.1.0 -BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:build_pip_package" -BZL_CONFIGS="--config=nogcp --config=noaws --config=nohdfs --config=opt" -BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" +NUMPY_SPEC="<2" +TF=v2.17.0 +OTB=release-9.1 +BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" +BZL_CONFIGS="" +BZL_OPTIONS="--verbose_failures" ZIP_TF_BIN=false KEEP_SRC_OTB=false SUDO=true - -# NumPy version requirement : -# TF < 2.4 : "numpy<1.19.0,>=1.16.0" -# TF >= 2.4 : "numpy==1.19.*" -# TF >= 2.8 : "numpy==1.22.*" ``` ### Bazel remote cache daemon diff --git a/doc/docker_use.md b/doc/docker_use.md index d20e4bb1..416288a1 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -26,12 +26,10 @@ versions <= 4.3.0 and [forgemia.inra.fr](https://forgemia.inra.fr/orfeo-toolbox/ | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:4.3.1-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.2-cpu** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| +| **mdl4eo/otbtf:4.3.2-cpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| +| **mdl4eo/otbtf:4.3.2-gpu** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| +| **mdl4eo/otbtf:4.3.2-gpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| The list of older releases is available [here](#older-images). @@ -113,87 +111,93 @@ Here you can find the list of older releases of OTBTF: | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- | ------ |-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:1.6-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU, no optimization | yes | 5.2,6.1,7.0 | -| **mdl4eo/otbtf:1.7-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU, no optimization | yes | 5.2,6.1,7.0 | +| **mdl4eo/otbtf:1.6-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU | yes | 5.2,6.1,7.0 | +| **mdl4eo/otbtf:1.7-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU | yes | 5.2,6.1,7.0 | | **mdl4eo/otbtf:1.7-gpu** | Ubuntu Xenial | r1.14 | 7.0.0 | GPU | yes | 5.2,6.1,7.0 | -| **mdl4eo/otbtf:2.0-cpu** | Ubuntu Xenial | r2.1 | 7.1.0 | CPU, no optimization | yes | 5.2,6.1,7.0,7.5 | +| **mdl4eo/otbtf:2.0-cpu** | Ubuntu Xenial | r2.1 | 7.1.0 | CPU | yes | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.0-gpu** | Ubuntu Xenial | r2.1 | 7.1.0 | GPU | yes | 5.2,6.1,7.0,7.5 | -| **mdl4eo/otbtf:2.4-cpu** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU, no optimization | yes | 5.2,6.1,7.0,7.5 | +| **mdl4eo/otbtf:2.4-cpu** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU | yes | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.4-cpu-opt** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU, few optimizations | no | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.4-cpu-mkl** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU, Intel MKL, AVX512 | yes | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.4-gpu** | Ubuntu Focal | r2.4.1 | 7.2.0 | GPU | yes | 5.2,6.1,7.0,7.5 | -| **mdl4eo/otbtf:2.5-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:2.5:cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:2.5-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:2.5:cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:2.5-cpu-opt** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, few optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:2.5-gpu-opt** | Ubuntu Focal | r2.5 | 7.4.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:2.5-gpu-opt-dev** | Ubuntu Focal | r2.5 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.0-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.0-cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.0-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.0-cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.0-gpu-opt** | Ubuntu Focal | r2.5 | 7.4.0 | GPU | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.0-gpu-opt-dev** | Ubuntu Focal | r2.5 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-cpu** | Ubuntu Focal | r2.8 | 7.4.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-cpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-gpu** | Ubuntu Focal | r2.8 | 7.4.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-gpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-cpu** | Ubuntu Focal | r2.8 | 7.4.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-cpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-gpu** | Ubuntu Focal | r2.8 | 7.4.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-gpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.1-gpu-opt** | Ubuntu Focal | r2.8 | 7.4.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.1-gpu-opt-dev** | Ubuntu Focal | r2.8 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.0-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.0-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.2-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.2-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.3-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.3-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.4.0-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.4.0-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.0.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.0.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-cpu** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-gpu** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-cpu** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-gpu** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.1-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.1-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-cpu** | Ubuntu Jammy | r2.12 | d74ab | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-cpu-dev** | Ubuntu Jammy | r2.12 | d74ab | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-gpu** | Ubuntu Jammy | r2.12 | d74ab | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-gpu-dev** | Ubuntu Jammy | r2.12 | d74ab | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-cpu** | Ubuntu Jammy | r2.12 | d74ab | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-cpu-dev** | Ubuntu Jammy | r2.12 | d74ab | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-gpu** | Ubuntu Jammy | r2.12 | d74ab | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-gpu-dev** | Ubuntu Jammy | r2.12 | d74ab | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.2-gpu-opt** | Ubuntu Jammy | r2.12 | d74ab | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.2-gpu-opt-dev** | Ubuntu Jammy | r2.12 | d74ab | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-cpu** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-cpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-gpu** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-gpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -- GitLab From 7fdea64353d15d7afadfaa6aaa80934963ff7fcb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 14 Oct 2024 18:27:40 +0200 Subject: [PATCH 041/317] Ensure clang binary is found --- Dockerfile | 3 +-- tools/docker/build-env-tf.sh | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 76d3f44b..3ef96d64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,7 @@ RUN apt-get update -y && apt-get upgrade -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Install clang+llvm -ARG CLANG=17 -RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh $CLANG +RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 17 ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 4763199e..9857fd37 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -1,7 +1,7 @@ #!/usr/bin/bash -export CC=$(which clang) -export CXX=$(which clang++) -export BAZEL_COMPILER=$(which clang) +export CC=$(which clang-17) +export CXX=$(which clang++-17) +export BAZEL_COMPILER=$(which clang-17) # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" -- GitLab From c03181fb13399a3a9545943cdad66676f10fdf1c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 20:04:26 +0200 Subject: [PATCH 042/317] Remove mfpmath from opt build flags --- tools/docker/build-env-tf.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 9857fd37..d7c18c87 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -4,7 +4,7 @@ export CXX=$(which clang++-17) export BAZEL_COMPILER=$(which clang-17) # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 -export CC_OPT_FLAGS="-Wno-sign-compare --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2" +export CC_OPT_FLAGS="--copt=-mfma --copt=-msse4.2 --copt=-mavx --copt=-mavx2" # Required variable since TF 2.16 export TF_PYTHON_VERSION=$(python3 -c 'import sys; print(sys.version[:4])') export PYTHON_BIN_PATH=$(which python) @@ -20,7 +20,7 @@ export TF_NEED_OPENCL=0 export TF_NEED_OPENCL_SYCL=0 export TF_NEED_VERBS=0 export TF_SET_ANDROID_WORKSPACE=0 -export TF_NEED_CLANG=0 +export TF_NEED_CLANG=1 # For MKL support BZL_CONFIGS+=" --config=mkl" #export TF_DOWNLOAD_MKL=1 #export TF_NEED_MKL=0 -- GitLab From 9851a4df630ab13c2e2a3581db457451ce0367f5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 20:05:37 +0200 Subject: [PATCH 043/317] Remove var TF_CUDA_CLANG=0 --- tools/docker/build-env-tf.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index d7c18c87..bbf68ae5 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -44,7 +44,6 @@ if [ ! -z $CUDA_TOOLKIT_PATH ] ; then export TF_CUDA_VERSION=$(echo $CUDA_TOOLKIT_PATH | sed -r 's/.*\/cuda-(.*)/\1/') export TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0" export TF_NEED_CUDA=1 - export TF_CUDA_CLANG=0 export TF_NEED_TENSORRT=0 export CUDNN_INSTALL_PATH="/usr/" export TF_CUDNN_VERSION=$(sed -n 's/^#define CUDNN_MAJOR\s*\(.*\).*/\1/p' $CUDNN_INSTALL_PATH/include/cudnn_version.h) -- GitLab From 3becaecf19e9d16563aa000b277ed1385637531a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 20:08:26 +0200 Subject: [PATCH 044/317] Add TF_CUDA_CLANG=1 --- tools/docker/build-env-tf.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index bbf68ae5..f155fcb3 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -44,6 +44,7 @@ if [ ! -z $CUDA_TOOLKIT_PATH ] ; then export TF_CUDA_VERSION=$(echo $CUDA_TOOLKIT_PATH | sed -r 's/.*\/cuda-(.*)/\1/') export TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0" export TF_NEED_CUDA=1 + export TF_CUDA_CLANG=1 export TF_NEED_TENSORRT=0 export CUDNN_INSTALL_PATH="/usr/" export TF_CUDNN_VERSION=$(sed -n 's/^#define CUDNN_MAJOR\s*\(.*\).*/\1/p' $CUDNN_INSTALL_PATH/include/cudnn_version.h) -- GitLab From 213fa8b3d5b82ac866a78d5948400115072ad7da Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 21:17:21 +0200 Subject: [PATCH 045/317] Update docker images table --- doc/docker_use.md | 119 ++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 63 deletions(-) diff --git a/doc/docker_use.md b/doc/docker_use.md index 416288a1..7e90b97b 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -26,8 +26,8 @@ versions <= 4.3.0 and [forgemia.inra.fr](https://forgemia.inra.fr/orfeo-toolbox/ | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:4.3.2-cpu** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| -| **mdl4eo/otbtf:4.3.2-cpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| +| **mdl4eo/otbtf:4.3.2-cpu** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU | no | | +| **mdl4eo/otbtf:4.3.2-cpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU (dev) | yes | | | **mdl4eo/otbtf:4.3.2-gpu** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| | **mdl4eo/otbtf:4.3.2-gpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| @@ -98,7 +98,6 @@ Troubleshooting: - [WSL user guide](https://docs.nvidia.com/cuda/wsl-user-guide/index.html) - [XSL GPU support](https://docs.docker.com/docker-for-windows/wsl/#gpu-support) - ## Build your own images If you want to use optimization flags, change GPUs compute capability, etc. @@ -111,93 +110,87 @@ Here you can find the list of older releases of OTBTF: | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- | ------ |-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:1.6-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU | yes | 5.2,6.1,7.0 | -| **mdl4eo/otbtf:1.7-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU | yes | 5.2,6.1,7.0 | +| **mdl4eo/otbtf:1.6-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU, no optimization | yes | 5.2,6.1,7.0 | +| **mdl4eo/otbtf:1.7-cpu** | Ubuntu Xenial | r1.14 | 7.0.0 | CPU, no optimization | yes | 5.2,6.1,7.0 | | **mdl4eo/otbtf:1.7-gpu** | Ubuntu Xenial | r1.14 | 7.0.0 | GPU | yes | 5.2,6.1,7.0 | -| **mdl4eo/otbtf:2.0-cpu** | Ubuntu Xenial | r2.1 | 7.1.0 | CPU | yes | 5.2,6.1,7.0,7.5 | +| **mdl4eo/otbtf:2.0-cpu** | Ubuntu Xenial | r2.1 | 7.1.0 | CPU, no optimization | yes | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.0-gpu** | Ubuntu Xenial | r2.1 | 7.1.0 | GPU | yes | 5.2,6.1,7.0,7.5 | -| **mdl4eo/otbtf:2.4-cpu** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU | yes | 5.2,6.1,7.0,7.5 | +| **mdl4eo/otbtf:2.4-cpu** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU, no optimization | yes | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.4-cpu-opt** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU, few optimizations | no | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.4-cpu-mkl** | Ubuntu Focal | r2.4.1 | 7.2.0 | CPU, Intel MKL, AVX512 | yes | 5.2,6.1,7.0,7.5 | | **mdl4eo/otbtf:2.4-gpu** | Ubuntu Focal | r2.4.1 | 7.2.0 | GPU | yes | 5.2,6.1,7.0,7.5 | -| **mdl4eo/otbtf:2.5-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:2.5:cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:2.5-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:2.5:cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:2.5-cpu-opt** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, few optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:2.5-gpu-opt** | Ubuntu Focal | r2.5 | 7.4.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:2.5-gpu-opt-dev** | Ubuntu Focal | r2.5 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.0-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.0-cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.0-cpu** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.0-cpu-dev** | Ubuntu Focal | r2.5 | 7.4.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.0-gpu-opt** | Ubuntu Focal | r2.5 | 7.4.0 | GPU | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.0-gpu-opt-dev** | Ubuntu Focal | r2.5 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-cpu** | Ubuntu Focal | r2.8 | 7.4.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-cpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-gpu** | Ubuntu Focal | r2.8 | 7.4.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.1-gpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-cpu** | Ubuntu Focal | r2.8 | 7.4.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-cpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-gpu** | Ubuntu Focal | r2.8 | 7.4.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.1-gpu-dev** | Ubuntu Focal | r2.8 | 7.4.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.1-gpu-opt** | Ubuntu Focal | r2.8 | 7.4.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.1-gpu-opt-dev** | Ubuntu Focal | r2.8 | 7.4.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.0-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.0-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.2-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.2-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.2-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.2-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.3.3-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.3.3-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.3-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.3-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:3.4.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:3.4.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.4.0-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.4.0-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.0.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.0.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.0.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.0.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.1.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.1.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-cpu** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-gpu** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.1-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-cpu** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-gpu** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.1-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.1-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-cpu** | Ubuntu Jammy | r2.12 | d74ab | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-cpu-dev** | Ubuntu Jammy | r2.12 | d74ab | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-gpu** | Ubuntu Jammy | r2.12 | d74ab | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.2-gpu-dev** | Ubuntu Jammy | r2.12 | d74ab | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-cpu** | Ubuntu Jammy | r2.12 | d74ab | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-cpu-dev** | Ubuntu Jammy | r2.12 | d74ab | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-gpu** | Ubuntu Jammy | r2.12 | d74ab | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.2-gpu-dev** | Ubuntu Jammy | r2.12 | d74ab | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.2-gpu-opt** | Ubuntu Jammy | r2.12 | d74ab | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.2-gpu-opt-dev** | Ubuntu Jammy | r2.12 | d74ab | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-cpu** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-cpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-gpu** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.0-gpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.0-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -- GitLab From a3c9aa9d000d48c06320d502c80eccbdda7f365e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 21:19:45 +0200 Subject: [PATCH 046/317] Add old images to docker table --- doc/docker_use.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/docker_use.md b/doc/docker_use.md index 7e90b97b..0001d148 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -194,3 +194,9 @@ Here you can find the list of older releases of OTBTF: | **mdl4eo/otbtf:4.3.0-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.0-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-cpu** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization | no | | +| **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | | +| **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -- GitLab From e06843a224f148bcef575643799cdb3d9ab4c973 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 21:43:49 +0200 Subject: [PATCH 047/317] Try to add bazel disk global cache to CI --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d5380bf..df9d75f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,11 @@ stages: - Update dev image - Ship +cache: + key: bazel_cache + paths: + - .cache/ + .docker_build_base: allow_failure: false tags: [godzilla] @@ -42,9 +47,9 @@ stages: - name: docker:dind before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY + - echo "build --disk_cache=$CI_PROJECT_DIR/.cache" >> .bazelrc timeout: 10 hours - docker image: extends: .docker_build_base stage: Build -- GitLab From 7cf08810bba2ccee515fa2e7f42e2202070748bc Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:10:59 +0200 Subject: [PATCH 048/317] Update docs --- doc/docker_build.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/doc/docker_build.md b/doc/docker_build.md index 6ce73ec1..7e66135e 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -29,7 +29,6 @@ NUMPY_SPEC="<2" TF=v2.17.0 OTB=release-9.1 BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" -BZL_CONFIGS="" BZL_OPTIONS="--verbose_failures" ZIP_TF_BIN=false KEEP_SRC_OTB=false @@ -70,23 +69,16 @@ docker build --network='host' -t otbtf:cpu --build-arg BASE_IMG=ubuntu:22.04 . # Clear bazel config var (deactivate default optimizations and unset # noaws/nogcp/nohdfs) docker build --network='host' -t otbtf:cpu \ - --build-arg BASE_IMG=ubuntu:22.04 \ - --build-arg BZL_CONFIGS= . - -# Enable MKL -MKL_CONFIG="--config=nogcp --config=noaws --config=nohdfs --config=opt --config=mkl" -docker build --network='host' -t otbtf:cpu-mkl \ - --build-arg BZL_CONFIGS="$MKL_CONFIG" \ --build-arg BASE_IMG=ubuntu:22.04 . # Build for GPU (if you're building for your system only you should edit # CUDA_COMPUTE_CAPABILITIES in build-env-tf.sh) docker build --network='host' -t otbtf:gpu \ - --build-arg BASE_IMG=nvidia/cuda:12.1.0-devel-ubuntu22.04 . + --build-arg BASE_IMG=nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 . # Build latest TF and OTB, set git branches/tags to clone docker build --network='host' -t otbtf:gpu-dev \ - --build-arg BASE_IMG=nvidia/cuda:12.1.0-devel-ubuntu22.04 \ + --build-arg BASE_IMG=nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 \ --build-arg KEEP_SRC_OTB=true \ --build-arg TF=nightly \ --build-arg OTB=develop . -- GitLab From d487133292357a59dd0b77918498fabed57638cf Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:11:42 +0200 Subject: [PATCH 049/317] Move CC and CXX variables to dockerfile (for OTB cmake) --- Dockerfile | 3 +++ tools/docker/build-env-tf.sh | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ef96d64..45dc4837 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,9 @@ RUN apt-get update -y && apt-get upgrade -y \ # Install clang+llvm RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 17 +ENV BAZEL_COMPILER=/usr/bin/clang-17 +ENV CC=/usr/bin/clang-17 +ENV CXX=/usr/bin/clang++-17 ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index f155fcb3..67d8da8c 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -1,7 +1,4 @@ #!/usr/bin/bash -export CC=$(which clang-17) -export CXX=$(which clang++-17) -export BAZEL_COMPILER=$(which clang-17) # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 export CC_OPT_FLAGS="--copt=-mfma --copt=-msse4.2 --copt=-mavx --copt=-mavx2" @@ -21,9 +18,6 @@ export TF_NEED_OPENCL_SYCL=0 export TF_NEED_VERBS=0 export TF_SET_ANDROID_WORKSPACE=0 export TF_NEED_CLANG=1 -# For MKL support BZL_CONFIGS+=" --config=mkl" -#export TF_DOWNLOAD_MKL=1 -#export TF_NEED_MKL=0 ## GPU export TF_NEED_ROCM=0 -- GitLab From c35299f858857bbf93dd91b38f9e88a467c82aef Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:12:06 +0200 Subject: [PATCH 050/317] Drop build arg BZL_CONFIGS --- Dockerfile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 45dc4837..91bc0e8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,13 +51,7 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" - -# Using "--config=opt" here will enable 'march=native' -# (see comments about CPU compatibility and edit CC_OPT_FLAGS in build-env-tf.sh) -# To disable gcp, aws and hdfs : BZL_CONFIGS="--config=nogcp --config=noaws --config=nohdfs" -ARG BZL_CONFIGS - -# You may add --remote_cache=http://localhost:9090, see example in tools/docker/multibuild.sh +# You may add --remote_cache here, see example in tools/docker/multibuild.sh ARG BZL_OPTIONS="--verbose_failures" # Build @@ -71,7 +65,7 @@ RUN cd tensorflow \ source ../build-env-tf.sh \ && ./configure \ && export TMP=/tmp/bazel \ - && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS" \ + && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' # Installation -- GitLab From a4a9d827f3b3eb530544a010fca06f71113ce5df Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:19:12 +0200 Subject: [PATCH 051/317] Try bazel remote cache as a CI service --- .gitlab-ci.yml | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df9d75f7..7710fb69 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,11 @@ variables: CPU_BASE_IMG: ubuntu:22.04 GPU_BASE_IMG: nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 -image: $BRANCH_IMAGE +image: docker:latest +services: + - name: docker:dind + - name: buchgr/bazel-remote-cache + alias: bazel-cache workflow: rules: @@ -42,17 +46,14 @@ cache: .docker_build_base: allow_failure: false tags: [godzilla] - image: docker:latest - services: - - name: docker:dind + before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - - echo "build --disk_cache=$CI_PROJECT_DIR/.cache" >> .bazelrc timeout: 10 hours -docker image: - extends: .docker_build_base +docker_image: stage: Build + extends: .docker_build_base except: - develop script: @@ -88,11 +89,13 @@ docker image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" + --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" "." - docker push $BRANCH_IMAGE .static_analysis_base: stage: Static Analysis + image: $BRANCH_IMAGE allow_failure: true flake8: @@ -122,6 +125,7 @@ cppcheck: .doc_base: stage: Documentation + image: $BRANCH_IMAGE before_script: - pip install -r doc/doc_requirements.txt artifacts: @@ -147,6 +151,7 @@ pages: - public .tests_base: + image: $BRANCH_IMAGE tags: [godzilla] artifacts: paths: @@ -257,14 +262,14 @@ deploy_cpu-dev-testing: - docker tag $BRANCH_IMAGE $DEV_IMAGE - docker push $DEV_IMAGE -.ship base: +.ship_base: extends: .docker_build_base stage: Ship only: - master deploy_cpu: - extends: .ship base + extends: .ship_base variables: IMAGE_CPU: $CI_REGISTRY_PUBIMG-cpu IMAGE_CPUDEV: $CI_REGISTRY_PUBIMG-cpu-dev @@ -273,10 +278,10 @@ deploy_cpu: DOCKERHUB_LATEST: $DOCKERHUB_BASE:latest script: # cpu - - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG . + - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . - docker push $IMAGE_CPU # cpu-dev - - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . + - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . - docker push $IMAGE_CPUDEV # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -289,7 +294,7 @@ deploy_cpu: - docker push $DOCKERHUB_LATEST deploy_gpu: - extends: .ship base + extends: .ship_base variables: IMAGE_GPU: $CI_REGISTRY_PUBIMG-gpu IMAGE_GPUDEV: $CI_REGISTRY_PUBIMG-gpu-dev @@ -298,10 +303,10 @@ deploy_gpu: DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu - - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG . + - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . - docker push $IMAGE_GPU # gpu-dev - - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . + - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . - docker push $IMAGE_GPUDEV # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin -- GitLab From 701ac34927d5c26ba213d20b3dfde6198d8514d3 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:21:58 +0200 Subject: [PATCH 052/317] Remove CI cache dir --- .gitlab-ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7710fb69..a7ae1246 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,11 +38,6 @@ stages: - Update dev image - Ship -cache: - key: bazel_cache - paths: - - .cache/ - .docker_build_base: allow_failure: false tags: [godzilla] -- GitLab From 450573e8ac35c76cf3e1a03858a1e4b483bca2ce Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:23:28 +0200 Subject: [PATCH 053/317] Update CI config --- .gitlab-ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a7ae1246..898b7a4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,12 +39,11 @@ stages: - Ship .docker_build_base: + tags: [ godzilla ] allow_failure: false - tags: [godzilla] - + timeout: 10 hours before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - timeout: 10 hours docker_image: stage: Build @@ -147,7 +146,7 @@ pages: .tests_base: image: $BRANCH_IMAGE - tags: [godzilla] + tags: [ godzilla ] artifacts: paths: - $ARTIFACT_TEST_DIR/*.* -- GitLab From 376bddc9b86c988cd2ea9070c279c51515021911 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:41:22 +0200 Subject: [PATCH 054/317] Try fix bazel cache --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 898b7a4d..4e5c1890 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ variables: DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 DOCKER_DRIVER: overlay2 + FF_NETWORK_PER_BUILD: false CACHE_IMAGE_BASE: $CI_REGISTRY_IMAGE:otbtf-base CACHE_IMAGE_BUILDER: $CI_REGISTRY_IMAGE:builder BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME @@ -70,6 +71,7 @@ docker_image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" + --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" "." - docker push $CACHE_IMAGE_BUILDER - > -- GitLab From 419abc9fdb2e89bc11e7d6c5860eb9742ad6ce3e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 22:54:39 +0200 Subject: [PATCH 055/317] Try other hostname --- .gitlab-ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e5c1890..38018bf0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,6 @@ variables: DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 DOCKER_DRIVER: overlay2 - FF_NETWORK_PER_BUILD: false CACHE_IMAGE_BASE: $CI_REGISTRY_IMAGE:otbtf-base CACHE_IMAGE_BUILDER: $CI_REGISTRY_IMAGE:builder BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME @@ -24,7 +23,6 @@ image: docker:latest services: - name: docker:dind - name: buchgr/bazel-remote-cache - alias: bazel-cache workflow: rules: @@ -71,7 +69,7 @@ docker_image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" + --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" "." - docker push $CACHE_IMAGE_BUILDER - > @@ -85,7 +83,7 @@ docker_image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" + --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" "." - docker push $BRANCH_IMAGE @@ -274,10 +272,10 @@ deploy_cpu: DOCKERHUB_LATEST: $DOCKERHUB_BASE:latest script: # cpu - - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . + - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . - docker push $IMAGE_CPU # cpu-dev - - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . + - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . - docker push $IMAGE_CPUDEV # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -299,10 +297,10 @@ deploy_gpu: DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu - - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . + - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . - docker push $IMAGE_GPU # gpu-dev - - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-cache:8080" . + - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . - docker push $IMAGE_GPUDEV # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin -- GitLab From bfea7a507127aff536c4a315ddda87dfffc0be4c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Mon, 14 Oct 2024 23:02:20 +0200 Subject: [PATCH 056/317] Try network localhost --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 38018bf0..55fcbdc0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,7 +69,7 @@ docker_image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" + --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" "." - docker push $CACHE_IMAGE_BUILDER - > @@ -83,7 +83,7 @@ docker_image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" + --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" "." - docker push $BRANCH_IMAGE @@ -272,10 +272,10 @@ deploy_cpu: DOCKERHUB_LATEST: $DOCKERHUB_BASE:latest script: # cpu - - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . + - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . - docker push $IMAGE_CPU # cpu-dev - - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . + - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . - docker push $IMAGE_CPUDEV # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -297,10 +297,10 @@ deploy_gpu: DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu - - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . + - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . - docker push $IMAGE_GPU # gpu-dev - - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://bazel-remote-cache:8080" . + - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . - docker push $IMAGE_GPUDEV # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin -- GitLab From c9175d0f8820bfc9a60e51f307f76770a0f1d21c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 14:29:47 +0200 Subject: [PATCH 057/317] Fix OTB build with gcc --- .gitlab-ci.yml | 1 - Dockerfile | 5 ++++- tools/docker/build-deps-cli.txt | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55fcbdc0..baba9212 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,6 @@ variables: image: docker:latest services: - name: docker:dind - - name: buchgr/bazel-remote-cache workflow: rules: diff --git a/Dockerfile b/Dockerfile index 91bc0e8e..5387260f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,9 @@ RUN apt-get update -y && apt-get upgrade -y \ # Install clang+llvm RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 17 -ENV BAZEL_COMPILER=/usr/bin/clang-17 ENV CC=/usr/bin/clang-17 ENV CXX=/usr/bin/clang++-17 +ENV BAZEL_COMPILER=/usr/bin/clang-17 ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip @@ -98,6 +98,9 @@ RUN apt-get update -y \ && git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git \ && cd otb && git checkout $OTB +ENV CC=/usr/bin/gcc +ENV CXX=/usr/bin/g++ + # <---------------------------------------- Begin dirty hack # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt index a9c232a4..a92107fd 100644 --- a/tools/docker/build-deps-cli.txt +++ b/tools/docker/build-deps-cli.txt @@ -3,6 +3,8 @@ ca-certificates curl cmake file +g++ +gcc git gpg libc6-dev -- GitLab From 7a47e8d2e6e306f14d55d3a35d4518e609d56cd9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 14:42:01 +0200 Subject: [PATCH 058/317] Remove useless bazel remote cache url --- .gitlab-ci.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index baba9212..b19bad87 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,7 +68,6 @@ docker_image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" "." - docker push $CACHE_IMAGE_BUILDER - > @@ -82,7 +81,6 @@ docker_image: --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg OTBTESTS="true" - --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" "." - docker push $BRANCH_IMAGE @@ -271,10 +269,10 @@ deploy_cpu: DOCKERHUB_LATEST: $DOCKERHUB_BASE:latest script: # cpu - - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . + - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG . - docker push $IMAGE_CPU # cpu-dev - - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . + - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_CPUDEV # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -296,10 +294,10 @@ deploy_gpu: DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu - - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . + - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG . - docker push $IMAGE_GPU # gpu-dev - - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:8080" . + - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_GPUDEV # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin -- GitLab From 4b2942ad84dde7ae271cc790ea3e892a65e0c433 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 16:40:29 +0200 Subject: [PATCH 059/317] Use var $PYTHON_BIN_PATH + try drop tensorrt --- Dockerfile | 3 ++- tools/docker/build-env-tf.sh | 22 ++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5387260f..11ce5046 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ RUN git config --global advice.detachedHead false ### TF ARG TF=v2.17.0 # 2.17 will be the last release to support TensorRT -ARG TENSORRT +ARG TENSORRT=true # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ @@ -51,6 +51,7 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" +ARG BZL_CONFIGS="--no-tensorrt" # You may add --remote_cache here, see example in tools/docker/multibuild.sh ARG BZL_OPTIONS="--verbose_failures" diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 67d8da8c..e87a3ffc 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -2,10 +2,10 @@ # As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues # Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 export CC_OPT_FLAGS="--copt=-mfma --copt=-msse4.2 --copt=-mavx --copt=-mavx2" -# Required variable since TF 2.16 -export TF_PYTHON_VERSION=$(python3 -c 'import sys; print(sys.version[:4])') -export PYTHON_BIN_PATH=$(which python) +export PYTHON_BIN_PATH=$(which python3) export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')" +# Required variable since TF 2.16 +export TF_PYTHON_VERSION="$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])')" export TF_DOWNLOAD_CLANG=0 export TF_ENABLE_XLA=1 export TF_NEED_COMPUTECPP=0 @@ -22,24 +22,14 @@ export TF_NEED_CLANG=1 ## GPU export TF_NEED_ROCM=0 export TF_NEED_CUDA=0 +export TF_NEED_TENSORRT=0 export CUDA_TOOLKIT_PATH=$(find /usr/local -maxdepth 1 -type d -name 'cuda-*') if [ ! -z $CUDA_TOOLKIT_PATH ] ; then - if [ ! -z $TENSORRT ]; then - echo "Building tensorflow with TensorRT support" - apt install \ - libnvinfer8=$TENSORRT \ - libnvinfer-dev=$TENSORRT \ - libnvinfer-plugin8=$TENSORRT \ - libnvinfer-plugin-dev=$TENSORRT - export TF_TENSORRT_VERSION=$(cat $(find /usr/ -type f -name NvInferVersion.h) | grep '#define NV_TENSORRT_MAJOR' | cut -f3 -d' ') - export TF_NEED_TENSORRT=1 - fi export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_TOOLKIT_PATH/lib64:$CUDA_TOOLKIT_PATH/lib64/stubs" export TF_CUDA_VERSION=$(echo $CUDA_TOOLKIT_PATH | sed -r 's/.*\/cuda-(.*)/\1/') - export TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0" + # Let TF set compute capabilities + #export TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0" export TF_NEED_CUDA=1 - export TF_CUDA_CLANG=1 - export TF_NEED_TENSORRT=0 export CUDNN_INSTALL_PATH="/usr/" export TF_CUDNN_VERSION=$(sed -n 's/^#define CUDNN_MAJOR\s*\(.*\).*/\1/p' $CUDNN_INSTALL_PATH/include/cudnn_version.h) export TF_NCCL_VERSION=2 -- GitLab From c381ae668db9917a391145762c13bb1b538b0b24 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 17:14:44 +0200 Subject: [PATCH 060/317] Move to tf 2.18rc --- Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11ce5046..ce3102ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,9 +41,7 @@ WORKDIR /src/tf RUN git config --global advice.detachedHead false ### TF -ARG TF=v2.17.0 -# 2.17 will be the last release to support TensorRT -ARG TENSORRT=true +ARG TF=v2.18.0-rc1 # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ @@ -51,7 +49,6 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" -ARG BZL_CONFIGS="--no-tensorrt" # You may add --remote_cache here, see example in tools/docker/multibuild.sh ARG BZL_OPTIONS="--verbose_failures" @@ -65,12 +62,12 @@ RUN cd tensorflow \ && bash -c '\ source ../build-env-tf.sh \ && ./configure \ + && export TF_NEED_TENSORRT=0 \ && export TMP=/tmp/bazel \ && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS" \ - && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' - -# Installation -RUN cd tensorflow \ + && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' \ +# Installation / split command here to debug build + cd tensorflow \ && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ && ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \ && ln -s /opt/otbtf/local/bin/* /opt/otbtf/bin \ -- GitLab From baf3157fa0ec71b27896aff7010e25b6e5d4735e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 18:08:48 +0200 Subject: [PATCH 061/317] Move to TF 2.18.0-rc1 --- .gitlab-ci.yml | 17 ++++++--------- Dockerfile | 27 ++++++++++++------------ tools/docker/build-env-tf.sh | 40 ++++++++++++------------------------ 3 files changed, 33 insertions(+), 51 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b19bad87..338629af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,8 +16,6 @@ variables: CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION DOCKERHUB_BASE: mdl4eo/otbtf DOCKERHUB_IMAGE_BASE: ${DOCKERHUB_BASE}:${OTBTF_VERSION} - CPU_BASE_IMG: ubuntu:22.04 - GPU_BASE_IMG: nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 image: docker:latest services: @@ -54,7 +52,6 @@ docker_image: --target otbtf-base --cache-from $CACHE_IMAGE_BASE --tag $CACHE_IMAGE_BASE - --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 "." - docker push $CACHE_IMAGE_BASE @@ -64,9 +61,8 @@ docker_image: --cache-from $CACHE_IMAGE_BASE --cache-from $CACHE_IMAGE_BUILDER --tag $CACHE_IMAGE_BUILDER - --build-arg KEEP_SRC_OTB="true" - --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 + --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." - docker push $CACHE_IMAGE_BUILDER @@ -77,9 +73,8 @@ docker_image: --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE --tag $BRANCH_IMAGE - --build-arg KEEP_SRC_OTB="true" - --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg BUILDKIT_INLINE_CACHE=1 + --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." - docker push $BRANCH_IMAGE @@ -269,10 +264,10 @@ deploy_cpu: DOCKERHUB_LATEST: $DOCKERHUB_BASE:latest script: # cpu - - docker build --tag $IMAGE_CPU --build-arg BASE_IMG=$CPU_BASE_IMG . + - docker build --tag $IMAGE_CPU . - docker push $IMAGE_CPU # cpu-dev - - docker build --tag $IMAGE_CPUDEV --build-arg BASE_IMG=$CPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . + - docker build --tag $IMAGE_CPUDEV --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_CPUDEV # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -294,10 +289,10 @@ deploy_gpu: DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu - - docker build --tag $IMAGE_GPU --build-arg BASE_IMG=$GPU_BASE_IMG . + - docker build --tag $IMAGE_GPU --build-arg WITH_CUDA=true . - docker push $IMAGE_GPU # gpu-dev - - docker build --tag $IMAGE_GPUDEV --build-arg BASE_IMG=$GPU_BASE_IMG --build-arg KEEP_SRC_OTB=true . + - docker build --tag $IMAGE_GPUDEV --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true . - docker push $IMAGE_GPUDEV # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin diff --git a/Dockerfile b/Dockerfile index ce3102ce..01e434d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,8 @@ ##### Configurable Dockerfile with multi-stage build -# Mandatory -ARG BASE_IMG # ---------------------------------------------------------------------------- # Init base stage - will be cloned as intermediate build env -FROM $BASE_IMG AS otbtf-base +FROM ubuntu:22.04 AS otbtf-base WORKDIR /tmp ### System packages @@ -14,12 +12,6 @@ RUN apt-get update -y && apt-get upgrade -y \ && cat build-deps-cli.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* -# Install clang+llvm -RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 17 -ENV CC=/usr/bin/clang-17 -ENV CXX=/usr/bin/clang++-17 -ENV BAZEL_COMPILER=/usr/bin/clang-17 - ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip # Upgrade pip @@ -29,12 +21,20 @@ ARG NUMPY_SPEC="<2" RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$NUMPY_SPEC" packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing + + # ---------------------------------------------------------------------------- # Tmp builder stage - dangling cache should persist until "docker builder prune" FROM otbtf-base AS builder # A smaller value may be required to avoid OOM errors when building OTB ARG CPU_RATIO=1 +# Install clang+llvm +RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 18 +ENV CC=/usr/bin/clang-18 +ENV CXX=/usr/bin/clang++-18 +ENV BAZEL_COMPILER=/usr/bin/clang-18 + RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3 WORKDIR /src/tf @@ -42,6 +42,9 @@ RUN git config --global advice.detachedHead false ### TF ARG TF=v2.18.0-rc1 +ARG WITH_CUDA=false +ARG WITH_XLA=true +ARG WITH_MKL=false # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ @@ -61,12 +64,9 @@ RUN cd tensorflow \ && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otbtf/lib \ && bash -c '\ source ../build-env-tf.sh \ - && ./configure \ - && export TF_NEED_TENSORRT=0 \ && export TMP=/tmp/bazel \ - && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS" \ + && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' \ -# Installation / split command here to debug build cd tensorflow \ && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ && ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \ @@ -192,3 +192,4 @@ RUN python -c "import tensorflow" RUN python -c "import otbtf, tricks" RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" RUN python -c "from osgeo import gdal" + diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index e87a3ffc..dd81a519 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -6,34 +6,20 @@ export PYTHON_BIN_PATH=$(which python3) export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')" # Required variable since TF 2.16 export TF_PYTHON_VERSION="$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])')" -export TF_DOWNLOAD_CLANG=0 -export TF_ENABLE_XLA=1 -export TF_NEED_COMPUTECPP=0 -export TF_NEED_GDR=0 -export TF_NEED_JEMALLOC=1 -export TF_NEED_KAFKA=0 -export TF_NEED_MPI=0 -export TF_NEED_OPENCL=0 -export TF_NEED_OPENCL_SYCL=0 -export TF_NEED_VERBS=0 -export TF_SET_ANDROID_WORKSPACE=0 -export TF_NEED_CLANG=1 -## GPU -export TF_NEED_ROCM=0 -export TF_NEED_CUDA=0 -export TF_NEED_TENSORRT=0 -export CUDA_TOOLKIT_PATH=$(find /usr/local -maxdepth 1 -type d -name 'cuda-*') -if [ ! -z $CUDA_TOOLKIT_PATH ] ; then - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_TOOLKIT_PATH/lib64:$CUDA_TOOLKIT_PATH/lib64/stubs" - export TF_CUDA_VERSION=$(echo $CUDA_TOOLKIT_PATH | sed -r 's/.*\/cuda-(.*)/\1/') - # Let TF set compute capabilities - #export TF_CUDA_COMPUTE_CAPABILITIES="5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0" - export TF_NEED_CUDA=1 - export CUDNN_INSTALL_PATH="/usr/" - export TF_CUDNN_VERSION=$(sed -n 's/^#define CUDNN_MAJOR\s*\(.*\).*/\1/p' $CUDNN_INSTALL_PATH/include/cudnn_version.h) - export TF_NCCL_VERSION=2 +if $WITH_CUDA ; then + export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" +else + export BZL_CONFIGS="--config=release_cpu_linux" fi -echo "Starting build with the following environment variables:" +if $WITH_XLA ; then + export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" +fi + +if $WITH_MKL ; then + export BZL_CONFIGS="$BZL_CONFIGS --config=xla" +fi + +echo"Starting build with the following environment variables:" env -- GitLab From bbd8c04c057c92a345bf443753464e8f09971d2f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 18:13:29 +0200 Subject: [PATCH 062/317] Autoformat + restore some variables --- tools/docker/build-env-tf.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index dd81a519..e051cb01 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -7,18 +7,30 @@ export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepa # Required variable since TF 2.16 export TF_PYTHON_VERSION="$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])')" -if $WITH_CUDA ; then - export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" +# Disabled features +export TF_NEED_COMPUTECPP=0 +export TF_NEED_GDR=0 +export TF_NEED_KAFKA=0 +export TF_NEED_MPI=0 +export TF_NEED_OPENCL=0 +export TF_NEED_OPENCL_SYCL=0 +export TF_NEED_VERBS=0 +export TF_SET_ANDROID_WORKSPACE=0 + +if $WITH_CUDA; then + export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" else - export BZL_CONFIGS="--config=release_cpu_linux" + export BZL_CONFIGS="--config=release_cpu_linux" fi -if $WITH_XLA ; then - export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" +# Enabled features +export TF_NEED_JEMALLOC=1 +if $WITH_XLA; then + export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" fi -if $WITH_MKL ; then - export BZL_CONFIGS="$BZL_CONFIGS --config=xla" +if $WITH_MKL; then + export BZL_CONFIGS="$BZL_CONFIGS --config=xla" fi echo"Starting build with the following environment variables:" -- GitLab From 59ce3002b3aebb64e0e7cf0415cce6cccd308dcd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 18:34:30 +0200 Subject: [PATCH 063/317] Add missing libiomp --- Dockerfile | 3 +++ tools/docker/build-env-tf.sh | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01e434d5..2f224936 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,9 @@ RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 18 ENV CC=/usr/bin/clang-18 ENV CXX=/usr/bin/clang++-18 ENV BAZEL_COMPILER=/usr/bin/clang-18 +RUN apt-get update -y && apt-get upgrade -y \ + && apt-get install -y libomp-18-dev \ + && apt-get clean && rm -rf /var/lib/apt/lists/* RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3 WORKDIR /src/tf diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index e051cb01..c6eb0670 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -16,6 +16,7 @@ export TF_NEED_OPENCL=0 export TF_NEED_OPENCL_SYCL=0 export TF_NEED_VERBS=0 export TF_SET_ANDROID_WORKSPACE=0 +export TF_NEED_MKL=0 if $WITH_CUDA; then export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" @@ -26,11 +27,13 @@ fi # Enabled features export TF_NEED_JEMALLOC=1 if $WITH_XLA; then - export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" + export TF_NEED_XLA=1 + export BZL_CONFIGS="$BZL_CONFIGS --config=xla" fi if $WITH_MKL; then - export BZL_CONFIGS="$BZL_CONFIGS --config=xla" + export TF_NEED_MKL=1 + export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" fi echo"Starting build with the following environment variables:" -- GitLab From 44e08f9f1abd3c3ba30fc4fd816510ce83e488f5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 15 Oct 2024 18:47:39 +0200 Subject: [PATCH 064/317] Try without unused variables --- tools/docker/build-env-tf.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index c6eb0670..2e8a2219 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -7,32 +7,17 @@ export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepa # Required variable since TF 2.16 export TF_PYTHON_VERSION="$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])')" -# Disabled features -export TF_NEED_COMPUTECPP=0 -export TF_NEED_GDR=0 -export TF_NEED_KAFKA=0 -export TF_NEED_MPI=0 -export TF_NEED_OPENCL=0 -export TF_NEED_OPENCL_SYCL=0 -export TF_NEED_VERBS=0 -export TF_SET_ANDROID_WORKSPACE=0 -export TF_NEED_MKL=0 - if $WITH_CUDA; then export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" else export BZL_CONFIGS="--config=release_cpu_linux" fi -# Enabled features -export TF_NEED_JEMALLOC=1 if $WITH_XLA; then - export TF_NEED_XLA=1 export BZL_CONFIGS="$BZL_CONFIGS --config=xla" fi if $WITH_MKL; then - export TF_NEED_MKL=1 export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" fi -- GitLab From 6f3ce3f3383e33cf2487c38b08c6cc7e34f90b8d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 21:39:09 +0200 Subject: [PATCH 065/317] Remove cc opt flags --- Dockerfile | 2 -- tools/docker/build-env-tf.sh | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f224936..f0cd6d23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,6 @@ ARG NUMPY_SPEC="<2" RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$NUMPY_SPEC" packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing - - # ---------------------------------------------------------------------------- # Tmp builder stage - dangling cache should persist until "docker builder prune" FROM otbtf-base AS builder diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh index 2e8a2219..b93d6218 100644 --- a/tools/docker/build-env-tf.sh +++ b/tools/docker/build-env-tf.sh @@ -1,7 +1,4 @@ #!/usr/bin/bash -# As in official TF wheels, we avoid "-march=native" to prevent MAVX512 compatibility issues -# Here we disable only AVX512 but enable commons optimizations like FMA, SSE4.2 and AVX2 -export CC_OPT_FLAGS="--copt=-mfma --copt=-msse4.2 --copt=-mavx --copt=-mavx2" export PYTHON_BIN_PATH=$(which python3) export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')" # Required variable since TF 2.16 @@ -21,5 +18,5 @@ if $WITH_MKL; then export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" fi -echo"Starting build with the following environment variables:" +echo "Starting build with the following environment variables:" env -- GitLab From 75558983181978ab15095b0a160b0010182b42e2 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 21:45:44 +0200 Subject: [PATCH 066/317] Update release notes and bump to 4.4 --- .gitlab-ci.yml | 4 ++-- RELEASE_NOTES.txt | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 338629af..3ad77196 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ variables: - OTBTF_VERSION: 4.3.2 + OTBTF_VERSION: 4.4.0 OTB_BUILD: /src/otb/build/OTB/build # Local OTB build directory OTBTF_SRC: /src/otbtf # Local OTBTF source directory OTB_TEST_DIR: $OTB_BUILD/Testing/Temporary # OTB testing directory @@ -24,7 +24,7 @@ services: workflow: rules: - if: $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ # Execute jobs in merge request context, or commit in master branch - + stages: - Build - Static Analysis diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 7c4cb06b..1b3688e1 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,6 +1,14 @@ -Version 4.3.2 (01 sep 2024) ----------------------------------------------------------------- -* Move TensorFlow to version 2.16.2 +Version 4.4.0 (?? ??? ????) +---------------------------------------------------------------- +* Bump OTB version to 9.1.0 +* Bump TensorFlow to 2.18.0 +* Upgrade TF build workflow to newest specs (LLVM18/Clang, HERMETIC_CUDA) +* Drop Docker build argument BASE_IMG (ubuntu22 is used for every build) +* Add Docker build arguments WITH_CUDA=false, WITH_MKL=false, WITH_XLA=true +* Enable common CPU optimizations by default (FMA, AVX2, SSE4.2) +* Use default TF compute capabilities from .bazelrc (sm_60,sm_70,sm_80,sm_89,compute_90) +* Lock numpy version < 2.0 +* TODO: move packaging spec to pyproject.toml Version 4.3.1 (02 jan 2024) ---------------------------------------------------------------- -- GitLab From ce4762555597fdee15a4cab67d496249038abf8c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 21:52:33 +0200 Subject: [PATCH 067/317] Update RELEASE_NOTES.txt --- RELEASE_NOTES.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 1b3688e1..665de921 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -2,12 +2,14 @@ Version 4.4.0 (?? ??? ????) ---------------------------------------------------------------- * Bump OTB version to 9.1.0 * Bump TensorFlow to 2.18.0 -* Upgrade TF build workflow to newest specs (LLVM18/Clang, HERMETIC_CUDA) -* Drop Docker build argument BASE_IMG (ubuntu22 is used for every build) -* Add Docker build arguments WITH_CUDA=false, WITH_MKL=false, WITH_XLA=true -* Enable common CPU optimizations by default (FMA, AVX2, SSE4.2) -* Use default TF compute capabilities from .bazelrc (sm_60,sm_70,sm_80,sm_89,compute_90) * Lock numpy version < 2.0 +* Upgrade TF build workflow to latest specs: + - Drop Docker build argument BASE_IMG (ubuntu22 is used for every build) + - Use official wheels bazel configs (targets --config=release_{cpu,gpu}) + - Compile with Clang LLVM18, use "HERMETIC_CUDA" 12.5 + - Use default compute capabilities from .bazelrc (sm_60,sm_70,sm_80,sm_89,compute_90) + - Add Docker build arguments WITH_CUDA=false, WITH_MKL=false, WITH_XLA=true + - TODO: update python for Keras 3 * TODO: move packaging spec to pyproject.toml Version 4.3.1 (02 jan 2024) -- GitLab From ba733527c9606a1ba97680d75cb4766ddd90cfa7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 22:24:20 +0200 Subject: [PATCH 068/317] Fix OTBTEST variable --- Dockerfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index f0cd6d23..4ade7287 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,7 +100,6 @@ RUN apt-get update -y \ ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ -# <---------------------------------------- Begin dirty hack # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 # See https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2338 @@ -112,12 +111,10 @@ RUN cd /src/otb/otb \ && echo "" > Modules/Core/Edge/test/CMakeLists.txt \ && echo "" > Modules/Core/ImageBase/test/CMakeLists.txt \ && echo "" > Modules/Learning/DempsterShafer/test/CMakeLists.txt \ -# <---------------------------------------- End dirty hack + && cd .. \ && mkdir -p build \ && cd build \ - && if $OTBTESTS; then \ - echo "-DBUILD_TESTING=ON" >> ../build-flags-otb.txt; fi \ && cmake ../otb/SuperBuild \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ -DOTB_BUILD_FeaturesExtraction=ON \ @@ -128,13 +125,13 @@ RUN cd /src/otb/otb \ -DOTB_BUILD_SAR=ON \ -DOTB_BUILD_Segmentation=ON \ -DOTB_BUILD_StereoProcessing=ON \ + $($OTBTESTS && echo "-DBUILD_TESTING=ON") \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") -### OTBTF - copy (without .git/) or clone repository +# Rebuild OTB with OTBTF module COPY . /src/otbtf RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf -# Rebuild OTB with module ARG KEEP_SRC_OTB=false RUN cd /src/otb/build/OTB/build \ && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otbtf/lib \ @@ -147,7 +144,6 @@ RUN cd /src/otb/build/OTB/build \ -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 \ && make install -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ - # Cleaning && ( $KEEP_SRC_OTB || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* -- GitLab From 7ed91db401158f6144f9d4f01e10ff01a749c9ff Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 22:45:19 +0200 Subject: [PATCH 069/317] Clean comments --- Dockerfile | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ade7287..4f051a3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,11 +53,11 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" -# You may add --remote_cache here, see example in tools/docker/multibuild.sh +# You could add --remote_cache here, see example in tools/docker/multibuild.sh ARG BZL_OPTIONS="--verbose_failures" -# Build -ARG ZIP_TF_BIN=false +# Build and install TF wheels +ARG ZIP_COMP_FILES=false COPY tools/docker/build-env-tf.sh ./ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git RUN cd tensorflow \ @@ -67,26 +67,25 @@ RUN cd tensorflow \ source ../build-env-tf.sh \ && export TMP=/tmp/bazel \ && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ + && echo "Starting build with cmd \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' \ cd tensorflow \ && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ && ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \ && 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 \ - # 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/ \ - # Symlink external libs (required for MKL - libiomp5) + && cp tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ && 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 + && ( ! $ZIP_COMP_FILES || 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* bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl ) \ && rm -rf bazel-* /src/tf /root/.cache/ /tmp/* ### OTB ARG OTB=release-9.1 ARG OTBTESTS=false +ENV CC=/usr/bin/gcc +ENV CXX=/usr/bin/g++ + RUN mkdir /src/otb WORKDIR /src/otb @@ -97,9 +96,6 @@ RUN apt-get update -y \ && git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git \ && cd otb && git checkout $OTB -ENV CC=/usr/bin/gcc -ENV CXX=/usr/bin/g++ - # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 # See https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2338 -- GitLab From 1f9c035fe1ccb5f6d1b13cb2f3100513a7f5cc93 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 23:10:10 +0200 Subject: [PATCH 070/317] Move tf build env to Dockerfile --- Dockerfile | 23 +++++++++------- tools/docker/build-deps-cli.txt | 29 -------------------- tools/docker/build-env-tf.sh | 22 --------------- tools/docker/multibuild.sh | 47 --------------------------------- 4 files changed, 13 insertions(+), 108 deletions(-) delete mode 100644 tools/docker/build-deps-cli.txt delete mode 100644 tools/docker/build-env-tf.sh delete mode 100644 tools/docker/multibuild.sh diff --git a/Dockerfile b/Dockerfile index 4f051a3a..d2673539 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,7 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" -# You could add --remote_cache here, see example in tools/docker/multibuild.sh +# You could add --remote_cache=http://... here ARG BZL_OPTIONS="--verbose_failures" # Build and install TF wheels @@ -64,10 +64,17 @@ RUN cd tensorflow \ && export PATH=$PATH:/opt/otbtf/bin \ && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otbtf/lib \ && bash -c '\ - source ../build-env-tf.sh \ && export TMP=/tmp/bazel \ + && export PYTHON_BIN_PATH=$(which python3) \ + && export PYTHON_LIB_PATH=$($PYTHON_BIN_PATH -c "import site; print(site.getsitepackages()[0])") \ + && export TF_PYTHON_VERSION=$($PYTHON_BIN_PATH -c "import sys; print(sys.version[:4])") \ + && export BZL_CONFIGS="--config=release_cpu_linux" \ + && (! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel") \ + && (! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla") \ + && (! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl") \ + && echo "Build env:" && env \ && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ - && echo "Starting build with cmd \"bazel $BZL_CMD\"" \ + && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' \ cd tensorflow \ && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ @@ -168,13 +175,11 @@ WORKDIR /home/otbuser # Admin rights without password ARG SUDO=true -RUN if $SUDO; then \ - usermod -a -G sudo otbuser \ - && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi +RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi -# Set /src/otbtf ownership to otbuser (you'll need root user in order to rebuild OTB) +# Set /src/otbtf ownership to otbuser (but you'll need root user to rebuild OTB) RUN chown -R otbuser:otbuser /src/otbtf -# This won't prevent ownership problems with volumes if you're not UID 1000 +# Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 USER otbuser # User-only ENV @@ -184,5 +189,3 @@ ENV PATH="/home/otbuser/.local/bin:$PATH" RUN python -c "import tensorflow" RUN python -c "import otbtf, tricks" RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" -RUN python -c "from osgeo import gdal" - diff --git a/tools/docker/build-deps-cli.txt b/tools/docker/build-deps-cli.txt deleted file mode 100644 index a92107fd..00000000 --- a/tools/docker/build-deps-cli.txt +++ /dev/null @@ -1,29 +0,0 @@ -apt-transport-https -ca-certificates -curl -cmake -file -g++ -gcc -git -gpg -libc6-dev -libtool -lsb-release -make -nano -patch -patchelf -pkg-config -python3-dev -python3-pip -python3-setuptools -python3-venv -swig -software-properties-common -unzip -vim -wget -sudo -xz-utils -zip diff --git a/tools/docker/build-env-tf.sh b/tools/docker/build-env-tf.sh deleted file mode 100644 index b93d6218..00000000 --- a/tools/docker/build-env-tf.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/bash -export PYTHON_BIN_PATH=$(which python3) -export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')" -# Required variable since TF 2.16 -export TF_PYTHON_VERSION="$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])')" - -if $WITH_CUDA; then - export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" -else - export BZL_CONFIGS="--config=release_cpu_linux" -fi - -if $WITH_XLA; then - export BZL_CONFIGS="$BZL_CONFIGS --config=xla" -fi - -if $WITH_MKL; then - export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" -fi - -echo "Starting build with the following environment variables:" -env diff --git a/tools/docker/multibuild.sh b/tools/docker/multibuild.sh deleted file mode 100644 index b015de26..00000000 --- a/tools/docker/multibuild.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# Various docker builds using bazel cache -RELEASE=4.3.2 -CPU_IMG=ubuntu:22.04 -GPU_IMG=nvidia/cuda:12.1.0-devel-ubuntu22.04 - -## Bazel remote cache daemon -mkdir -p $HOME/.cache/bazel-remote -docker run -d -u 1000:1000 \ --v $HOME/.cache/bazel-remote:/data \ --p 9090:8080 \ -buchgr/bazel-remote-cache --max_size=20 - -### CPU images - -# CPU -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-cpu \ ---build-arg BASE_IMG=$CPU_IMG \ ---build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ - -# CPU-Dev -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-cpu-dev \ ---build-arg BASE_IMG=$CPU_IMG \ ---build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ ---build-arg KEEP_SRC_OTB=true - -### GPU enabled images -# Support is enabled if CUDA is found in /usr/local - -# GPU -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-gpu-dev \ ---build-arg BASE_IMG=$GPU_IMG \ ---build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ ---build-arg KEEP_SRC_OTB=true - -# GPU-Dev -docker build . \ ---network='host' \ --t mdl4eo/otbtf:$RELEASE-gpu \ ---build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" \ ---build-arg BASE_IMG=$GPU_IMG \ -- GitLab From afdf9f1ca1ba92dd98e3941434b220e20286664b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 23:12:11 +0200 Subject: [PATCH 071/317] Move cmd outside of bash subprocess --- Dockerfile | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index d2673539..28082901 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,19 +63,18 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi RUN cd tensorflow \ && export PATH=$PATH:/opt/otbtf/bin \ && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otbtf/lib \ - && bash -c '\ - && export TMP=/tmp/bazel \ - && export PYTHON_BIN_PATH=$(which python3) \ - && export PYTHON_LIB_PATH=$($PYTHON_BIN_PATH -c "import site; print(site.getsitepackages()[0])") \ - && export TF_PYTHON_VERSION=$($PYTHON_BIN_PATH -c "import sys; print(sys.version[:4])") \ - && export BZL_CONFIGS="--config=release_cpu_linux" \ - && (! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel") \ - && (! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla") \ - && (! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl") \ - && echo "Build env:" && env \ - && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ - && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ - && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" ' \ + && export TMP=/tmp/bazel \ + && export PYTHON_BIN_PATH=$(which python3) \ + && export PYTHON_LIB_PATH=$($PYTHON_BIN_PATH -c "import site; print(site.getsitepackages()[0])") \ + && export TF_PYTHON_VERSION=$($PYTHON_BIN_PATH -c "import sys; print(sys.version[:4])") \ + && export BZL_CONFIGS="--config=release_cpu_linux" \ + && (! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla") \ + && (! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl") \ + && (! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel") \ + && echo "Build env:" && env \ + && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ + && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ + && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ cd tensorflow \ && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ && ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \ -- GitLab From 1094e9bcb91abec3de95ceee9da2ba62bd6c3780 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 23:12:44 +0200 Subject: [PATCH 072/317] Move CMD --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 28082901..d31ae4b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,8 +71,8 @@ RUN cd tensorflow \ && (! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla") \ && (! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl") \ && (! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel") \ - && echo "Build env:" && env \ && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ + && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ cd tensorflow \ -- GitLab From f932a7f623bf307f175a59de259f4e5fec30b082 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 23:13:45 +0200 Subject: [PATCH 073/317] Remove duplicated cd cmd --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d31ae4b7..25b8ee33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,6 @@ RUN cd tensorflow \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ - cd tensorflow \ && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ && ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \ && ln -s /opt/otbtf/local/bin/* /opt/otbtf/bin \ -- GitLab From 406f247926efe9364ef5cf3af9ab8758ea102cfa Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 23:19:00 +0200 Subject: [PATCH 074/317] Move apt packages to apt-dependencies.txt --- Dockerfile | 5 ++--- apt-dependencies.txt | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 apt-dependencies.txt diff --git a/Dockerfile b/Dockerfile index 25b8ee33..29936b67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,10 @@ FROM ubuntu:22.04 AS otbtf-base WORKDIR /tmp ### System packages -COPY tools/docker/build-deps-cli.txt ./ +COPY apt-dependencies.txt ./ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -y && apt-get upgrade -y \ - && cat build-deps-cli.txt | xargs apt-get install --no-install-recommends -y \ + && cat apt-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* ### Python3 environment @@ -58,7 +58,6 @@ ARG BZL_OPTIONS="--verbose_failures" # Build and install TF wheels ARG ZIP_COMP_FILES=false -COPY tools/docker/build-env-tf.sh ./ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git RUN cd tensorflow \ && export PATH=$PATH:/opt/otbtf/bin \ diff --git a/apt-dependencies.txt b/apt-dependencies.txt new file mode 100644 index 00000000..0cdd73d8 --- /dev/null +++ b/apt-dependencies.txt @@ -0,0 +1,25 @@ +apt-transport-https +ca-certificates +curl +cmake +file +g++ +gcc +git +libc6-dev +libtool +lsb-release +make +nano +patch +pkg-config +python3-dev +python3-pip +python3-setuptools +python3-venv +swig +unzip +vim +wget +sudo +zip -- GitLab From 1c997c353add2028aff86bdf047b222342d58151 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 23:33:06 +0200 Subject: [PATCH 075/317] Merge TF clone and build steps --- Dockerfile | 37 ++++++++++++++++--------------------- RELEASE_NOTES.txt | 2 +- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29936b67..c019404b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -##### Configurable Dockerfile with multi-stage build +##### OTBTF configurable Dockerfile with multi-stage build # ---------------------------------------------------------------------------- # Init base stage - will be cloned as intermediate build env @@ -24,28 +24,23 @@ RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$N # ---------------------------------------------------------------------------- # Tmp builder stage - dangling cache should persist until "docker builder prune" FROM otbtf-base AS builder -# A smaller value may be required to avoid OOM errors when building OTB +# A smaller value may be used to limit bazel or to avoid OOM errors while building OTB ARG CPU_RATIO=1 -# Install clang+llvm +# Install Clang+LLVM 18 RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 18 ENV CC=/usr/bin/clang-18 ENV CXX=/usr/bin/clang++-18 ENV BAZEL_COMPILER=/usr/bin/clang-18 -RUN apt-get update -y && apt-get upgrade -y \ - && apt-get install -y libomp-18-dev \ - && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libomp-18-dev && apt-get clean && rm -rf /var/lib/apt/lists/* RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3 -WORKDIR /src/tf - -RUN git config --global advice.detachedHead false ### TF ARG TF=v2.18.0-rc1 -ARG WITH_CUDA=false ARG WITH_XLA=true ARG WITH_MKL=false +ARG WITH_CUDA=false # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ @@ -57,19 +52,21 @@ ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package ARG BZL_OPTIONS="--verbose_failures" # Build and install TF wheels +WORKDIR /src/tf ARG ZIP_COMP_FILES=false -RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git -RUN cd tensorflow \ - && export PATH=$PATH:/opt/otbtf/bin \ - && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otbtf/lib \ +RUN git config --global advice.detachedHead false +RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git \ + && cd tensorflow \ + && export PATH="$PATH:/opt/otbtf/bin" \ + && export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/otbtf/lib" \ && export TMP=/tmp/bazel \ && export PYTHON_BIN_PATH=$(which python3) \ - && export PYTHON_LIB_PATH=$($PYTHON_BIN_PATH -c "import site; print(site.getsitepackages()[0])") \ - && export TF_PYTHON_VERSION=$($PYTHON_BIN_PATH -c "import sys; print(sys.version[:4])") \ + && export PYTHON_LIB_PATH=$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])') \ + && export TF_PYTHON_VERSION=$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])') \ && export BZL_CONFIGS="--config=release_cpu_linux" \ - && (! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla") \ - && (! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl") \ - && (! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel") \ + && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ + && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ + && ( ! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ @@ -86,7 +83,6 @@ RUN cd tensorflow \ ### OTB ARG OTB=release-9.1 ARG OTBTESTS=false - ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ @@ -178,7 +174,6 @@ RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSW RUN chown -R otbuser:otbuser /src/otbtf # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 USER otbuser - # User-only ENV ENV PATH="/home/otbuser/.local/bin:$PATH" diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 665de921..2beeb575 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -9,7 +9,7 @@ Version 4.4.0 (?? ??? ????) - Compile with Clang LLVM18, use "HERMETIC_CUDA" 12.5 - Use default compute capabilities from .bazelrc (sm_60,sm_70,sm_80,sm_89,compute_90) - Add Docker build arguments WITH_CUDA=false, WITH_MKL=false, WITH_XLA=true - - TODO: update python for Keras 3 + - TODO: update python code for Keras 3 * TODO: move packaging spec to pyproject.toml Version 4.3.1 (02 jan 2024) -- GitLab From eeff05f5f0919b85a80603f587b5c7c70475113c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Tue, 15 Oct 2024 23:34:47 +0200 Subject: [PATCH 076/317] Add missing apt packages --- apt-dependencies.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apt-dependencies.txt b/apt-dependencies.txt index 0cdd73d8..2e11493e 100644 --- a/apt-dependencies.txt +++ b/apt-dependencies.txt @@ -6,6 +6,7 @@ file g++ gcc git +gpg libc6-dev libtool lsb-release @@ -17,6 +18,7 @@ python3-dev python3-pip python3-setuptools python3-venv +software-properties-common swig unzip vim -- GitLab From e9fc4dc5410b5fc2269e5ce28f8d15f14edcd6e6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 09:31:11 +0200 Subject: [PATCH 077/317] Add missing patchelf --- apt-dependencies.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/apt-dependencies.txt b/apt-dependencies.txt index 2e11493e..d19fd58e 100644 --- a/apt-dependencies.txt +++ b/apt-dependencies.txt @@ -13,6 +13,7 @@ lsb-release make nano patch +patchelf pkg-config python3-dev python3-pip -- GitLab From 2a4d31c0aba187b7040354c63b714c41a98cecbf Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 09:31:18 +0200 Subject: [PATCH 078/317] Update docker docs --- doc/deprecated.md | 6 +- doc/docker_build.md | 110 ++++++++++------------------------ doc/docker_troubleshooting.md | 12 +--- 3 files changed, 36 insertions(+), 92 deletions(-) diff --git a/doc/deprecated.md b/doc/deprecated.md index 3f76c1db..dfb95158 100644 --- a/doc/deprecated.md +++ b/doc/deprecated.md @@ -35,4 +35,8 @@ training, etc. is done using the so-called `tensorflow.Strategy` !!! Note - Read our [tutorial](api_tutorial.html) to know more on working with Keras! \ No newline at end of file + Read our [tutorial](api_tutorial.html) to know more on working with Keras! + +## Major changes between Keras 2 and 3 + +TODO diff --git a/doc/docker_build.md b/doc/docker_build.md index 7e66135e..a1dcef01 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -1,36 +1,30 @@ # Build your own docker images Docker build has to be called from the root of the repository (i.e. `docker -build .` or `bash tools/docker/multibuild.sh`). -You can build a custom image using `--build-arg` and several config files : +build .`. +You can build choose target versions using `--build-arg` : -- **Ubuntu** : `BASE_IMG` should accept any version, for additional packages -see *tools/docker/build-deps-cli.txt* and *tools/docker/build-deps-gui.txt*. - **TensorFlow** : `TF` arg for the git branch or tag + *build-env-tf.sh* and -BZL_* arguments for the build configuration. `ZIP_TF_BIN` allows you to save -compiled binaries if you want to install it elsewhere. +BZL_* arguments for the build configuration. `ZIP_COMP_FILES` allows you to save +compiled tf binaries if you want to install it elsewhere. - **OrfeoToolBox** : `OTB` arg for the git branch or tag + *tools/docker/build-flags-otb.txt* to edit cmake flags. Set `KEEP_SRC_OTB` in order to preserve OTB git directory. -### Base images - -```bash -CPU_IMG=ubuntu:22.04 -GPU_IMG=nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 -``` - ### Default arguments ```bash BASE_IMG # mandatory CPU_RATIO=1 NUMPY_SPEC="<2" -TF=v2.17.0 +TF=v2.18.0 +WITH_XLA=true +WITH_MKL=false +WITH_CUDA=false OTB=release-9.1 BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" BZL_OPTIONS="--verbose_failures" -ZIP_TF_BIN=false +ZIP_COMP_FILES=false KEEP_SRC_OTB=false SUDO=true ``` @@ -42,15 +36,14 @@ be a different branch of OTB, bazel cache will help you to rebuild everything except TF, even if the docker cache was purged (after `docker [system|builder] prune`). In order to recycle the cache, bazel config and TF git tag should be exactly -the same, any change in *tools/docker/build-env-tf.sh* and `--build-arg` -(if related to bazel env, cuda, mkl, xla...) may result in a fresh new build. +the same, any change in Dockerfile or `--build-arg` would create a new build. Start a cache daemon - here with max 20GB but 10GB should be enough to save 2 TF builds (GPU and CPU): ```bash mkdir -p $HOME/.cache/bazel-remote -docker run --detach -u 1000:1000 -v $HOME/.cache/bazel-remote:/data \ +docker run --detach -u $UID:$GID -v $HOME/.cache/bazel-remote:/data \ -p 9090:8080 buchgr/bazel-remote-cache --max_size=20 ``` @@ -64,74 +57,47 @@ address. ```bash # Build for CPU using default Dockerfiles args (without AWS, HDFS or GCP # support) -docker build --network='host' -t otbtf:cpu --build-arg BASE_IMG=ubuntu:22.04 . - -# Clear bazel config var (deactivate default optimizations and unset -# noaws/nogcp/nohdfs) -docker build --network='host' -t otbtf:cpu \ - --build-arg BASE_IMG=ubuntu:22.04 . +docker build --network='host' --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:cpu . -# Build for GPU (if you're building for your system only you should edit -# CUDA_COMPUTE_CAPABILITIES in build-env-tf.sh) -docker build --network='host' -t otbtf:gpu \ - --build-arg BASE_IMG=nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 . +# Build for GPU +docker build --network='host' --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:gpu --build-arg WITH_CUDA=true . # Build latest TF and OTB, set git branches/tags to clone -docker build --network='host' -t otbtf:gpu-dev \ - --build-arg BASE_IMG=nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 \ +docker build --network='host' --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:gpu --build-arg WITH_CUDA=true \ --build-arg KEEP_SRC_OTB=true \ --build-arg TF=nightly \ --build-arg OTB=develop . - -# Build old release (TF-2.1) -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 NUMPY_SPEC="<1.19" \ - --build-arg BAZEL_OPTIONS="--noincompatible_do_not_split_linking_cmdline --verbose_failures --remote_cache=http://localhost:9090" . -# You could edit the Dockerfile in order to clone an old branch of the repo -# instead of copying files from the build context ``` ### Build for another machine and save TF compiled files -Example with TF 2.5 - ```bash -# Use same ubuntu and CUDA version than your target machine, beware of CC -# optimization and CPU compatibility (set env variable CC_OPT_FLAGS and avoid -# "-march=native" if your Docker's CPU is optimized with AVX2/AVX512 but your -# target CPU isn't) -docker build --network='host' -t otbtf:custom \ - --build-arg BASE_IMG=nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04 \ - --build-arg TF=v2.5.0 \ - --build-arg ZIP_TF_BIN=true . -# Retrieve zip file -docker run -v $HOME:/home/otbuser/volume otbtf:custom \ - cp /opt/otbtf/tf-v2.5.0.zip /home/otbuser/volume +docker build --network='host' -t otbtf:custom --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:gpu --build-arg WITH_CUDA=true . +docker run -v $HOME:/home/otbuser/volume otbtf:custom cp /opt/otbtf/tf-v2.18.0.zip /home/otbuser/volume # Target machine shell cd $HOME -unzip tf-v2.5.0.zip +unzip tf-v2.18.0.zip sudo mkdir -p /opt/tensorflow/lib -sudo mv tf-v2.5.0/libtensorflow_cc* /opt/tensorflow/lib +sudo mv tf-v2.18.0/libtensorflow_cc* /opt/tensorflow/lib # You may need to create a virtualenv, here TF and dependencies are installed # next to user's pip packages -pip3 install -U pip wheel mock six future deprecated "numpy==1.19.*" +pip3 install -U pip wheel mock six future deprecated "numpy<2" pip3 install --no-deps keras_applications keras_preprocessing -pip3 install tf-v2.5.0/tensorflow-2.5.0-cp38-cp38-linux_x86_64.whl +pip3 install tf-v2.18.0/tensorflow-v2.18.0-cp310-cp310-linux_x86_64.whl -TF_WHEEL_DIR="$HOME/.local/lib/python3.8/site-packages/tensorflow" +TF_WHEEL_DIR="$HOME/.local/lib/python3.10/site-packages/tensorflow" # If you installed the wheel as regular user, with root pip it should be in # /usr/local/lib/python3.*, or in your virtualenv lib/ directory -mv tf-v2.5.0/tag_constants.h $TF_WHEEL_DIR/include/tensorflow/cc/saved_model/ +mv tf-v2.18.0/tag_constants.h $TF_WHEEL_DIR/include/tensorflow/cc/saved_model/ # Then recompile OTB with OTBTF using libraries in /opt/tensorflow/lib and # instructions in build_from_sources.md. cmake $OTB_GIT \ - -DOTB_USE_TENSORFLOW=ON -DModule_OTBTensorflow=ON \ - -DTENSORFLOW_CC_LIB=/opt/tensorflow/lib/libtensorflow_cc.so.2 \ - -Dtensorflow_include_dir=$TF_WHEEL_DIR/include \ - -DTENSORFLOW_FRAMEWORK_LIB=$TF_WHEEL_DIR/libtensorflow_framework.so.2 \ + -DOTB_USE_TENSORFLOW=ON \ + -DModule_OTBTensorflow=ON \ + -DTENSORFLOW_CC_LIB="/opt/tensorflow/lib/libtensorflow_cc.so.2" \ + -Dtensorflow_include_dir="$TF_WHEEL_DIR/include" \ + -DTENSORFLOW_FRAMEWORK_LIB="$TF_WHEEL_DIR/libtensorflow_framework.so.2" \ && make install -j ``` @@ -150,7 +116,7 @@ If you see OOM errors during SuperBuild you should decrease CPU_RATIO (e.g. # Pull GPU image and create a new container with your home directory as volume # (requires apt package nvidia-docker2 and CUDA>=11.0) docker create --gpus=all --volume $HOME:/home/otbuser/volume -it \ - --name otbtf-gpu mdl4eo/otbtf:3.3.2-gpu + --name otbtf-gpu mdl4eo/otbtf:4.4.0-gpu # Run interactive docker start -i otbtf-gpu @@ -166,7 +132,7 @@ docker exec otbtf-gpu \ Enter a development ready docker image: ```bash -docker create --gpus=all -it --name otbtf-gpu-dev mdl4eo/otbtf:3.3.2-gpu-dev +docker create --gpus=all -it --name otbtf-gpu-dev mdl4eo/otbtf:4.4.0-gpu docker start -i otbtf-gpu-dev ``` @@ -179,19 +145,3 @@ git clone https://gitlab.irstea.fr/raffaele.gaetano/otbSelectiveHaralickTextures cd /src/otb/build/OTB/build cmake -DModule_OTBAppSelectiveHaralickTextures=ON /src/otb/otb && make install -j ``` - -### Container with GUI - -GUI is disabled by default in order to save space, and because docker xvfb -isn't working properly with OpenGL. -OTB GUI seems OK but monteverdi isn't working - -```bash -docker build --network='host' -t otbtf:cpu-gui \ - --build-arg BASE_IMG=ubuntu:22.04 \ - --build-arg GUI=true . -docker create -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -it \ - --name otbtf-gui otbtf:cpu-gui -docker start -i otbtf-gui -$ mapla -``` diff --git a/doc/docker_troubleshooting.md b/doc/docker_troubleshooting.md index 4aa0d506..8f36cbe5 100644 --- a/doc/docker_troubleshooting.md +++ b/doc/docker_troubleshooting.md @@ -9,16 +9,6 @@ Big thanks to the authors. ## Common errors -### Manifest unknown - -``` -Error response from daemon: -manifest for nvidia/cuda:11.0-cudnn8-devel-ubuntu20.04 not found: -manifest unknown: manifest unknown -``` - -This means that the docker image is missing from dockerhub. - ### failed call to cuInit ``` @@ -87,7 +77,7 @@ docker create --interactive --tty --volume /home/$USER:/home/otbuser/ \ !!! warning Beware of ownership issues, see - [this section](#fix-volume-ownership-sissues). + [this section](#fix-volume-ownership-issues). ### Interactive session -- GitLab From 6df3c3693a6c501b0278844970bcc343e90e7f6c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 19:14:09 +0200 Subject: [PATCH 079/317] Try remove useless sudo commands, install and test as otbuser --- .gitlab-ci.yml | 18 +++++++++--------- Dockerfile | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3ad77196..a25ad219 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -87,19 +87,19 @@ docker_image: flake8: extends: .static_analysis_base script: - - sudo pip install flake8 + - pip install flake8 - flake8 $OTBTF_SRC/otbtf --exclude=tensorflow_v1x pylint: extends: .static_analysis_base script: - - sudo pip install pylint + - pip install pylint - pylint $OTBTF_SRC/otbtf --ignore=tensorflow_v1x codespell: extends: .static_analysis_base script: - - sudo pip install codespell + - pip install codespell - codespell otbtf - codespell doc @@ -150,13 +150,13 @@ ctest: stage: Test script: - sudo apt update && sudo apt install -y git-lfs - - cd /src/otb/otb && sudo git lfs fetch --all && sudo git lfs pull + - cd /src/otb/otb && git lfs fetch --all && git lfs pull - cd $OTB_BUILD/ - - sudo ctest -L OTBTensorflow - - sudo ctest -L OTBPanSharpening - - sudo ctest -L OTBProjection - - sudo ctest -L OTBTransform - - sudo ctest -L OTBIOGDAL + - ctest -L OTBTensorflow + - ctest -L OTBPanSharpening + - ctest -L OTBProjection + - ctest -L OTBTransform + - ctest -L OTBIOGDAL after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR diff --git a/Dockerfile b/Dockerfile index c019404b..15ed5c50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -170,8 +170,10 @@ WORKDIR /home/otbuser ARG SUDO=true RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi -# Set /src/otbtf ownership to otbuser (but you'll need root user to rebuild OTB) +# Set /src/otbtf and /src/otb ownership to otbuser RUN chown -R otbuser:otbuser /src/otbtf +RUN if [ -d "/src/otb" ]; then chown -R otbuser:otbuser /src/otb; fi + # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 USER otbuser # User-only ENV -- GitLab From d9cfa95086ee93da188ce16fa2617f7366aa7e46 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 19:15:20 +0200 Subject: [PATCH 080/317] Pip install rasterio using local gdal --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a25ad219..13658892 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -230,7 +230,7 @@ numpy_gdal_otb: rio: extends: .applications_test_base script: - - sudo pip install rasterio + - pip install rasterio --no-binary rasterio - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_rio.xml $OTBTF_SRC/test/rio_test.py nodata: -- GitLab From 68949a3671ce6e75a6123523ed7e092bb0508ebd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 20:29:42 +0200 Subject: [PATCH 081/317] Ensure all dev / src dirs are owned by otbuser --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 15ed5c50..eb49ae2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -170,8 +170,8 @@ WORKDIR /home/otbuser ARG SUDO=true RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi -# Set /src/otbtf and /src/otb ownership to otbuser -RUN chown -R otbuser:otbuser /src/otbtf +# Set directories ownership to otbuser +RUN chown -R otbuser:otbuser /src/otbtf /opt/otbtf RUN if [ -d "/src/otb" ]; then chown -R otbuser:otbuser /src/otb; fi # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 -- GitLab From 81b5710f77b016124ba9b3f69980e3c0d7b67c2a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 20:30:22 +0200 Subject: [PATCH 082/317] Try to upgrade to latest docker --- .gitlab-ci.yml | 79 +++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 13658892..9f016edc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,6 +40,7 @@ stages: timeout: 10 hours before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY + - docker buildx create --name container --driver=docker-container docker_image: stage: Build @@ -48,36 +49,25 @@ docker_image: - develop script: - > - docker build + docker buildx build --push -t $CACHE_IMAGE_BASE --target otbtf-base --cache-from $CACHE_IMAGE_BASE - --tag $CACHE_IMAGE_BASE - --build-arg BUILDKIT_INLINE_CACHE=1 + --cache-to type=registry,ref=$CACHE_IMAGE_BASE --provenance=mode=max "." - - docker push $CACHE_IMAGE_BASE - > - docker build + docker buildx build --push -t $CACHE_IMAGE_BUILDER --target builder - --cache-from $CACHE_IMAGE_BASE - --cache-from $CACHE_IMAGE_BUILDER - --tag $CACHE_IMAGE_BUILDER - --build-arg BUILDKIT_INLINE_CACHE=1 - --build-arg KEEP_SRC_OTB="true" - --build-arg OTBTESTS="true" + --cache-from $CACHE_IMAGE_BASE --cache-from $CACHE_IMAGE_BUILDER + --cache-to type=registry,ref=$CACHE_IMAGE_BUILDER --provenance=mode=max + --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." - - docker push $CACHE_IMAGE_BUILDER - > - docker build - --cache-from $CACHE_IMAGE_BASE - --cache-from $CACHE_IMAGE_BUILDER - --cache-from $BRANCH_IMAGE - --cache-from $DEV_IMAGE - --tag $BRANCH_IMAGE - --build-arg BUILDKIT_INLINE_CACHE=1 - --build-arg KEEP_SRC_OTB="true" - --build-arg OTBTESTS="true" + docker buildx build --push -t $BRANCH_IMAGE + --cache-from $CACHE_IMAGE_BASE --cache-from $CACHE_IMAGE_BUILDER + --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE + --cache-to type=registry,ref=$BRANCH_IMAGE --provenance=mode=max + --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." - - docker push $BRANCH_IMAGE .static_analysis_base: stage: Static Analysis @@ -264,20 +254,22 @@ deploy_cpu: DOCKERHUB_LATEST: $DOCKERHUB_BASE:latest script: # cpu - - docker build --tag $IMAGE_CPU . - - docker push $IMAGE_CPU + - > + docker buildx build --push -t $IMAGE_CPU + --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE + . # cpu-dev - - docker build --tag $IMAGE_CPUDEV --build-arg KEEP_SRC_OTB=true . - - docker push $IMAGE_CPUDEV + - > + docker buildx build --push -t $IMAGE_CPUDEV + --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE + --build-arg KEEP_SRC_OTB=true + . # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - - docker tag $IMAGE_CPU $DOCKERHUB_CPU - - docker push $DOCKERHUB_CPU - - docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV - - docker push $DOCKERHUB_CPUDEV + - docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU + - docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV # latest = cpu image - - docker tag $IMAGE_CPU $DOCKERHUB_LATEST - - docker push $DOCKERHUB_LATEST + - docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST deploy_gpu: extends: .ship_base @@ -289,17 +281,20 @@ deploy_gpu: DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu - - docker build --tag $IMAGE_GPU --build-arg WITH_CUDA=true . - - docker push $IMAGE_GPU + - > + docker buildx build --push -t $IMAGE_GPU + --cache-from $DEV_IMAGE + --build-arg WITH_CUDA=true + . # gpu-dev - - docker build --tag $IMAGE_GPUDEV --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true . - - docker push $IMAGE_GPUDEV + - > + docker buildx build --push -t $IMAGE_GPUDEV + --cache-from $DEV_IMAGE + --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true + . # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - - docker tag $IMAGE_GPU $DOCKERHUB_GPU - - docker push $DOCKERHUB_GPU - - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV - - docker push $DOCKERHUB_GPUDEV + - docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU + - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image - - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST - - docker push $DOCKERHUB_GPULATEST + - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST -- GitLab From 111afd48bbc8fb36425efef3dfdbf382d1bdc8a2 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 20:44:15 +0200 Subject: [PATCH 083/317] Ensure right docker builder is used --- .gitlab-ci.yml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f016edc..e74d7c6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ variables: API_TEST_TMP: /tmp/api_tests_tmp DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 + BUILDX_BUILDER: container DOCKER_DRIVER: overlay2 CACHE_IMAGE_BASE: $CI_REGISTRY_IMAGE:otbtf-base CACHE_IMAGE_BUILDER: $CI_REGISTRY_IMAGE:builder @@ -48,22 +49,8 @@ docker_image: except: - develop script: - - > - docker buildx build --push -t $CACHE_IMAGE_BASE - --target otbtf-base - --cache-from $CACHE_IMAGE_BASE - --cache-to type=registry,ref=$CACHE_IMAGE_BASE --provenance=mode=max - "." - - > - docker buildx build --push -t $CACHE_IMAGE_BUILDER - --target builder - --cache-from $CACHE_IMAGE_BASE --cache-from $CACHE_IMAGE_BUILDER - --cache-to type=registry,ref=$CACHE_IMAGE_BUILDER --provenance=mode=max - --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" - "." - > docker buildx build --push -t $BRANCH_IMAGE - --cache-from $CACHE_IMAGE_BASE --cache-from $CACHE_IMAGE_BUILDER --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE --cache-to type=registry,ref=$BRANCH_IMAGE --provenance=mode=max --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" @@ -283,13 +270,13 @@ deploy_gpu: # gpu - > docker buildx build --push -t $IMAGE_GPU - --cache-from $DEV_IMAGE + --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE --build-arg WITH_CUDA=true . # gpu-dev - > docker buildx build --push -t $IMAGE_GPUDEV - --cache-from $DEV_IMAGE + --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true . # push gpu-* images on dockerhub -- GitLab From c568ef5cff844b51e7175c312639a13a9340c092 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 21:07:37 +0200 Subject: [PATCH 084/317] Use separate image for cache --- .gitlab-ci.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e74d7c6f..0c15e25f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,8 +10,7 @@ variables: DOCKER_BUILDKIT: 1 BUILDX_BUILDER: container DOCKER_DRIVER: overlay2 - CACHE_IMAGE_BASE: $CI_REGISTRY_IMAGE:otbtf-base - CACHE_IMAGE_BUILDER: $CI_REGISTRY_IMAGE:builder + CACHE_IMAGE: $CI_REGISTRY_IMAGE:cache BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME DEV_IMAGE: $CI_REGISTRY_IMAGE:cpu-basic-dev-testing CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION @@ -51,8 +50,8 @@ docker_image: script: - > docker buildx build --push -t $BRANCH_IMAGE - --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE - --cache-to type=registry,ref=$BRANCH_IMAGE --provenance=mode=max + --cache-from $BRANCH_IMAGE --cache-from $CACHE_IMAGE --cache-from $CI_REGISTRY_IMAGE:builder + --cache-to type=registry,ref=$CACHE_IMAGE --provenance=mode=max --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." @@ -243,12 +242,12 @@ deploy_cpu: # cpu - > docker buildx build --push -t $IMAGE_CPU - --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE + --cache-from $CACHE_IMAGE . # cpu-dev - > docker buildx build --push -t $IMAGE_CPUDEV - --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE + --cache-from $CACHE_IMAGE --build-arg KEEP_SRC_OTB=true . # push images on dockerhub @@ -270,13 +269,13 @@ deploy_gpu: # gpu - > docker buildx build --push -t $IMAGE_GPU - --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE + --cache-from $CACHE_IMAGE --build-arg WITH_CUDA=true . # gpu-dev - > docker buildx build --push -t $IMAGE_GPUDEV - --cache-from $BRANCH_IMAGE --cache-from $DEV_IMAGE + --cache-from $CACHE_IMAGE --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true . # push gpu-* images on dockerhub -- GitLab From 643c383171655afe11c3c683a0706d04b1833180 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 21:37:42 +0200 Subject: [PATCH 085/317] Try fix image tag (drop --provenance) --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c15e25f..e7e6f6a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ variables: API_TEST_TMP: /tmp/api_tests_tmp DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 + BUILDX_NO_DEFAULT_ATTESTATIONS: 1 BUILDX_BUILDER: container DOCKER_DRIVER: overlay2 CACHE_IMAGE: $CI_REGISTRY_IMAGE:cache @@ -50,8 +51,8 @@ docker_image: script: - > docker buildx build --push -t $BRANCH_IMAGE - --cache-from $BRANCH_IMAGE --cache-from $CACHE_IMAGE --cache-from $CI_REGISTRY_IMAGE:builder - --cache-to type=registry,ref=$CACHE_IMAGE --provenance=mode=max + --cache-from $CACHE_IMAGE + --cache-to type=registry,ref=$CACHE_IMAGE,mode=max --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." -- GitLab From 39d1db0440f62359eab462bee23ac461a90564ab Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 21:38:13 +0200 Subject: [PATCH 086/317] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8519fb11..6c968599 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="otbtf", - version="4.3.1", + version="4.4.0", author="Remi Cresson", author_email="remi.cresson@inrae.fr", description="OTBTF: Orfeo ToolBox meets TensorFlow", -- GitLab From eed3ddc7c0f16e86bc7960df6e1da18c0e3c8ab9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 21:38:23 +0200 Subject: [PATCH 087/317] Renames stages --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb49ae2d..57d2b293 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------------- # Init base stage - will be cloned as intermediate build env -FROM ubuntu:22.04 AS otbtf-base +FROM ubuntu:22.04 AS base-stage WORKDIR /tmp ### System packages @@ -23,7 +23,7 @@ RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$N # ---------------------------------------------------------------------------- # Tmp builder stage - dangling cache should persist until "docker builder prune" -FROM otbtf-base AS builder +FROM base-stage AS build-stage # A smaller value may be used to limit bazel or to avoid OOM errors while building OTB ARG CPU_RATIO=1 @@ -148,7 +148,7 @@ RUN for f in /src/otbtf/python/*.py; do if [ -x $f ]; then ln -s $f /opt/otbtf/b # ---------------------------------------------------------------------------- # Final stage -FROM otbtf-base +FROM build-stage as final-stage LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" # Copy files from intermediate stage -- GitLab From 21fb6fd6fb53440ea57749c5494a1662a3850a00 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 21:44:28 +0200 Subject: [PATCH 088/317] Fix bad stage name --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57d2b293..d96edb83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -148,12 +148,12 @@ RUN for f in /src/otbtf/python/*.py; do if [ -x $f ]; then ln -s $f /opt/otbtf/b # ---------------------------------------------------------------------------- # Final stage -FROM build-stage as final-stage +FROM build-stage AS final-stage 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 /src /src +COPY --from=build-stage /opt/otbtf /opt/otbtf +COPY --from=build-stage /src /src # System-wide ENV ENV PATH="/opt/otbtf/bin:$PATH" -- GitLab From bd8433edcd609d5e7b9786a6495f09d967738725 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 23:09:41 +0200 Subject: [PATCH 089/317] Add opt to cache-from statement, yaml files in dockerignore --- .dockerignore | 3 +++ .gitlab-ci.yml | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2ca1beb2..599b0072 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,5 @@ .git python/__pycache__ +.gitlab-ci.yml +.readthedocs.yaml +mkdocs.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7e6f6a5..18fffc73 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,7 +51,7 @@ docker_image: script: - > docker buildx build --push -t $BRANCH_IMAGE - --cache-from $CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE --cache-to type=registry,ref=$CACHE_IMAGE,mode=max --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." @@ -243,12 +243,12 @@ deploy_cpu: # cpu - > docker buildx build --push -t $IMAGE_CPU - --cache-from $CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE . # cpu-dev - > docker buildx build --push -t $IMAGE_CPUDEV - --cache-from $CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE --build-arg KEEP_SRC_OTB=true . # push images on dockerhub @@ -270,13 +270,13 @@ deploy_gpu: # gpu - > docker buildx build --push -t $IMAGE_GPU - --cache-from $CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE --build-arg WITH_CUDA=true . # gpu-dev - > docker buildx build --push -t $IMAGE_GPUDEV - --cache-from $CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true . # push gpu-* images on dockerhub -- GitLab From 13c95b9d0dea8932e98b4ce67e791cf78a1a084b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 23:13:35 +0200 Subject: [PATCH 090/317] Try fix cache image manifest --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18fffc73..5a9da9f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,7 +52,7 @@ docker_image: - > docker buildx build --push -t $BRANCH_IMAGE --cache-from type=registry,ref=$CACHE_IMAGE - --cache-to type=registry,ref=$CACHE_IMAGE,mode=max + --cache-to type=registry,ref=$CACHE_IMAGE,mode=max,oci-mediatypes=true,image-manifest=true --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." -- GitLab From 9b7ea1a0377c6e4fb50ef9f8fdd0be667695d572 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 23:28:43 +0200 Subject: [PATCH 091/317] Add chown cmd to COPY statement (fix data duplication) --- Dockerfile | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index d96edb83..d6bc567c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -151,9 +151,15 @@ RUN for f in /src/otbtf/python/*.py; do if [ -x $f ]; then ln -s $f /opt/otbtf/b FROM build-stage AS final-stage LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" -# Copy files from intermediate stage -COPY --from=build-stage /opt/otbtf /opt/otbtf -COPY --from=build-stage /src /src +# Default user, directory and command (bash will be the default entrypoint) +RUN useradd -s /bin/bash -m otbuser +# Admin rights without password (potential security issue) +ARG SUDO=true +RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi + +# Copy built files from intermediate stage +COPY --from=build-stage --chown otbuser:otbuser /opt/otbtf /opt/otbtf +COPY --from=build-stage --chown otbuser:otbuser /src /src # System-wide ENV ENV PATH="/opt/otbtf/bin:$PATH" @@ -161,19 +167,8 @@ ENV LD_LIBRARY_PATH="/opt/otbtf/lib:$LD_LIBRARY_PATH" ENV PYTHONPATH="/opt/otbtf/lib/python3/dist-packages:/opt/otbtf/lib/otb/python" ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" RUN pip install -e /src/otbtf - -# Default user, directory and command (bash will be the default entrypoint) -RUN useradd -s /bin/bash -m otbuser WORKDIR /home/otbuser -# Admin rights without password -ARG SUDO=true -RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi - -# Set directories ownership to otbuser -RUN chown -R otbuser:otbuser /src/otbtf /opt/otbtf -RUN if [ -d "/src/otb" ]; then chown -R otbuser:otbuser /src/otb; fi - # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 USER otbuser # User-only ENV -- GitLab From 7ed39ba5f9ecf79a19bd0c00f72785f0ea9c52e5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 23:33:50 +0200 Subject: [PATCH 092/317] Add missing "=" to COPY --chown --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d6bc567c..c3c59f2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -158,8 +158,8 @@ ARG SUDO=true RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi # Copy built files from intermediate stage -COPY --from=build-stage --chown otbuser:otbuser /opt/otbtf /opt/otbtf -COPY --from=build-stage --chown otbuser:otbuser /src /src +COPY --from=build-stage --chown=otbuser:otbuser /opt/otbtf /opt/otbtf +COPY --from=build-stage --chown=otbuser:otbuser /src /src # System-wide ENV ENV PATH="/opt/otbtf/bin:$PATH" -- GitLab From 0f7c9063c78862e0b862dac437e864e1e1a8e532 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Wed, 16 Oct 2024 23:54:30 +0200 Subject: [PATCH 093/317] Fix for BZL_CONFIGS variable GPU + XLA --- Dockerfile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index c3c59f2d..daf30e41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,9 +38,9 @@ RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3 ### TF ARG TF=v2.18.0-rc1 -ARG WITH_XLA=true -ARG WITH_MKL=false ARG WITH_CUDA=false +ARG WITH_MKL=false +ARG WITH_XLA=true # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ @@ -58,15 +58,15 @@ RUN git config --global advice.detachedHead false RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git \ && cd tensorflow \ && export PATH="$PATH:/opt/otbtf/bin" \ - && export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/otbtf/lib" \ + && export LD_LIBRARY_PATH="/opt/otbtf/lib" \ && export TMP=/tmp/bazel \ && export PYTHON_BIN_PATH=$(which python3) \ && export PYTHON_LIB_PATH=$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])') \ && export TF_PYTHON_VERSION=$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])') \ && export BZL_CONFIGS="--config=release_cpu_linux" \ - && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ - && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" ) \ + && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ + && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ @@ -107,7 +107,6 @@ RUN cd /src/otb/otb \ && echo "" > Modules/Core/Edge/test/CMakeLists.txt \ && echo "" > Modules/Core/ImageBase/test/CMakeLists.txt \ && echo "" > Modules/Learning/DempsterShafer/test/CMakeLists.txt \ - && cd .. \ && mkdir -p build \ && cd build \ @@ -130,7 +129,7 @@ RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf ARG KEEP_SRC_OTB=false RUN cd /src/otb/build/OTB/build \ - && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otbtf/lib \ + && export LD_LIBRARY_PATH=/opt/otbtf/lib \ && export PATH=$PATH:/opt/otbtf/bin \ && cmake /src/otb/otb \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ @@ -163,7 +162,7 @@ COPY --from=build-stage --chown=otbuser:otbuser /src /src # System-wide ENV ENV PATH="/opt/otbtf/bin:$PATH" -ENV LD_LIBRARY_PATH="/opt/otbtf/lib:$LD_LIBRARY_PATH" +ENV LD_LIBRARY_PATH="/opt/otbtf/lib" ENV PYTHONPATH="/opt/otbtf/lib/python3/dist-packages:/opt/otbtf/lib/otb/python" ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" RUN pip install -e /src/otbtf -- GitLab From 9909ed555ab9473c2ddfde76456511bbd8f4c410 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 00:01:04 +0200 Subject: [PATCH 094/317] Fix misplaced comment --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index daf30e41..d8344a2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -150,7 +150,7 @@ RUN for f in /src/otbtf/python/*.py; do if [ -x $f ]; then ln -s $f /opt/otbtf/b FROM build-stage AS final-stage LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" -# Default user, directory and command (bash will be the default entrypoint) +# Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 RUN useradd -s /bin/bash -m otbuser # Admin rights without password (potential security issue) ARG SUDO=true @@ -168,7 +168,7 @@ ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" RUN pip install -e /src/otbtf WORKDIR /home/otbuser -# Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 +# Default user, directory and command (bash will be the default entrypoint) USER otbuser # User-only ENV ENV PATH="/home/otbuser/.local/bin:$PATH" -- GitLab From 067f9762a8f9e6226cb9e4180d2eb998b5a97934 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 00:29:13 +0200 Subject: [PATCH 095/317] Freeze ubuntu version + bump tf rc2 --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8344a2a..c4c6cc5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ ##### OTBTF configurable Dockerfile with multi-stage build # ---------------------------------------------------------------------------- -# Init base stage - will be cloned as intermediate build env -FROM ubuntu:22.04 AS base-stage +# Init base stage - used for intermediate build env and final image + +# Freeze ubuntu version to avoid suprise rebuild +FROM ubuntu:jammy-20240911.1 AS base-stage + WORKDIR /tmp ### System packages @@ -37,7 +40,7 @@ RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libomp-18-dev RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3 ### TF -ARG TF=v2.18.0-rc1 +ARG TF=v2.18.0-rc2 ARG WITH_CUDA=false ARG WITH_MKL=false ARG WITH_XLA=true -- GitLab From 3f1fabd8fd086b986f214100e2e5b2e25af9cdb4 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 00:40:46 +0200 Subject: [PATCH 096/317] Freeze numpy version + SUDO off by default --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4c6cc5a..18365637 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,11 +17,11 @@ RUN apt-get update -y && apt-get upgrade -y \ ### Python3 environment RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip -# Upgrade pip -RUN pip install --no-cache-dir pip --upgrade +# Upgrade pip and wheel +RUN pip install --no-cache-dir -U pip wheel # Numpy 2 support in TF is planned for 2.18, but isn't supported by most libraries for now -ARG NUMPY_SPEC="<2" -RUN pip install --no-cache-dir -U wheel mock six future tqdm deprecated "numpy$NUMPY_SPEC" packaging requests \ +ARG NUMPY="1.26.4" +RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing # ---------------------------------------------------------------------------- -- GitLab From 9df909077482b1563ba374d710295654a8192cda Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 00:41:33 +0200 Subject: [PATCH 097/317] Default to SUDO=false --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 18365637..d7139a1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,9 @@ RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 18 ENV CC=/usr/bin/clang-18 ENV CXX=/usr/bin/clang++-18 ENV BAZEL_COMPILER=/usr/bin/clang-18 -RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libomp-18-dev && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update -y && apt-get upgrade -y \ + && apt-get install -y libomp-18-dev \ + && apt-get clean && rm -rf /var/lib/apt/lists/* RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3 @@ -156,7 +158,7 @@ LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 RUN useradd -s /bin/bash -m otbuser # Admin rights without password (potential security issue) -ARG SUDO=true +ARG SUDO=false RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi # Copy built files from intermediate stage -- GitLab From 928e238acb979df061be513f27267149943ea791 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 00:57:46 +0200 Subject: [PATCH 098/317] Remove need for sudo in CI yml files --- .gitlab-ci.yml | 2 -- apt-dependencies.txt | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5a9da9f7..a4550b3c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,7 +83,6 @@ codespell: cppcheck: extends: .static_analysis_base script: - - sudo apt update && sudo apt install cppcheck -y - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . .doc_base: @@ -126,7 +125,6 @@ ctest: extends: .tests_base stage: Test script: - - sudo apt update && sudo apt install -y git-lfs - cd /src/otb/otb && git lfs fetch --all && git lfs pull - cd $OTB_BUILD/ - ctest -L OTBTensorflow diff --git a/apt-dependencies.txt b/apt-dependencies.txt index d19fd58e..79fe0819 100644 --- a/apt-dependencies.txt +++ b/apt-dependencies.txt @@ -2,10 +2,12 @@ apt-transport-https ca-certificates curl cmake +cppcheck file g++ gcc git +git-lfs gpg libc6-dev libtool @@ -23,6 +25,7 @@ software-properties-common swig unzip vim +virtualenv wget sudo zip -- GitLab From 0d97fb13119c48ee7a35c85bfc519bc5a69cdfec Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 01:10:24 +0200 Subject: [PATCH 099/317] Always use bazel --verbose_failures --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d7139a1c..ca439f0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,8 +53,8 @@ RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/rele && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" -# You could add --remote_cache=http://... here -ARG BZL_OPTIONS="--verbose_failures" +# You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time +ARG BZL_OPTIONS # Build and install TF wheels WORKDIR /src/tf @@ -72,7 +72,7 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi && ( ! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ - && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS" \ + && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS --verbose_failures" \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ -- GitLab From a80e6bf0b0fa6c92277956bdaa08296be2ac88b9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 12:35:34 +0200 Subject: [PATCH 100/317] Add files to dockerignore --- .dockerignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.dockerignore b/.dockerignore index 599b0072..a4dfa454 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,6 @@ python/__pycache__ .gitlab-ci.yml .readthedocs.yaml mkdocs.yml +doc/* +README.md +RELEASE_NOTES.txt -- GitLab From 036a2b578c53269cae6ff70b72afc37b9d7106a9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 12:35:48 +0200 Subject: [PATCH 101/317] Fix wrong base for final stage --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ca439f0c..79b883ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -152,7 +152,7 @@ RUN for f in /src/otbtf/python/*.py; do if [ -x $f ]; then ln -s $f /opt/otbtf/b # ---------------------------------------------------------------------------- # Final stage -FROM build-stage AS final-stage +FROM base-stage AS final-stage LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 -- GitLab From 9a3b18665b810b445de9f5dfc1798e5915ae0fac Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 12:40:29 +0200 Subject: [PATCH 102/317] Add separate cache image for gpu --- .gitlab-ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4550b3c..076f96c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,8 @@ variables: BUILDX_NO_DEFAULT_ATTESTATIONS: 1 BUILDX_BUILDER: container DOCKER_DRIVER: overlay2 - CACHE_IMAGE: $CI_REGISTRY_IMAGE:cache + CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu + CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME DEV_IMAGE: $CI_REGISTRY_IMAGE:cpu-basic-dev-testing CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION @@ -51,8 +52,8 @@ docker_image: script: - > docker buildx build --push -t $BRANCH_IMAGE - --cache-from type=registry,ref=$CACHE_IMAGE - --cache-to type=registry,ref=$CACHE_IMAGE,mode=max,oci-mediatypes=true,image-manifest=true + --cache-from type=registry,ref=$CACHE_IMAGE_CPU + --cache-to type=registry,ref=$CACHE_IMAGE_CPU,mode=max,oci-mediatypes=true,image-manifest=true --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" "." @@ -241,12 +242,12 @@ deploy_cpu: # cpu - > docker buildx build --push -t $IMAGE_CPU - --cache-from type=registry,ref=$CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE_CPU . # cpu-dev - > docker buildx build --push -t $IMAGE_CPUDEV - --cache-from type=registry,ref=$CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE_CPU --build-arg KEEP_SRC_OTB=true . # push images on dockerhub @@ -268,13 +269,16 @@ deploy_gpu: # gpu - > docker buildx build --push -t $IMAGE_GPU - --cache-from type=registry,ref=$CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE_CPU + --cache-from type=registry,ref=$CACHE_IMAGE_GPU + --cache-to type=registry,ref=$CACHE_IMAGE_GPU,mode=max,oci-mediatypes=true,image-manifest=true --build-arg WITH_CUDA=true . # gpu-dev - > docker buildx build --push -t $IMAGE_GPUDEV - --cache-from type=registry,ref=$CACHE_IMAGE + --cache-from type=registry,ref=$CACHE_IMAGE_CPU + --cache-from type=registry,ref=$CACHE_IMAGE_GPU --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true . # push gpu-* images on dockerhub -- GitLab From cfdc549336263f94154d869646e0a35f639202a0 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 12:49:04 +0200 Subject: [PATCH 103/317] Do not docker ignore README and RELEASE_NOTES --- .dockerignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index a4dfa454..ee7534dd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,5 +4,3 @@ python/__pycache__ .readthedocs.yaml mkdocs.yml doc/* -README.md -RELEASE_NOTES.txt -- GitLab From 1570b70c51be390c1d616371cb817bbe4bdee448 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 13:36:22 +0200 Subject: [PATCH 104/317] Try fix git lfs --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 076f96c3..68048438 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,6 +126,7 @@ ctest: extends: .tests_base stage: Test script: + - git lfs install - cd /src/otb/otb && git lfs fetch --all && git lfs pull - cd $OTB_BUILD/ - ctest -L OTBTensorflow -- GitLab From a9e9297c8b4b4547cc00c3d3470e879e35b92a69 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 13:36:45 +0200 Subject: [PATCH 105/317] Fix command git-lfs install --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 68048438..0e0aa2e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,7 +126,7 @@ ctest: extends: .tests_base stage: Test script: - - git lfs install + - git-lfs install - cd /src/otb/otb && git lfs fetch --all && git lfs pull - cd $OTB_BUILD/ - ctest -L OTBTensorflow -- GitLab From 0379c2f442888c6e7ae9eec3acd6e29202ef75f2 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 13:59:49 +0200 Subject: [PATCH 106/317] Test git-lfs as it should be installed in image --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e0aa2e3..076f96c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,7 +126,6 @@ ctest: extends: .tests_base stage: Test script: - - git-lfs install - cd /src/otb/otb && git lfs fetch --all && git lfs pull - cd $OTB_BUILD/ - ctest -L OTBTensorflow -- GitLab From f1f3f47e855b6c9ef21c5ca14a92948af4811419 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 15:40:29 +0200 Subject: [PATCH 107/317] Try force rebuild base-stage --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 79b883ce..89a569d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,8 @@ FROM ubuntu:jammy-20240911.1 AS base-stage WORKDIR /tmp ### System packages -COPY apt-dependencies.txt ./ ARG DEBIAN_FRONTEND=noninteractive +COPY apt-dependencies.txt ./ RUN apt-get update -y && apt-get upgrade -y \ && cat apt-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* -- GitLab From ceab6607cf60bcc7d6c33b2cbaf9bc90c6245fe7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 18:30:15 +0200 Subject: [PATCH 108/317] Try ubuntu 24 --- .gitlab-ci.yml | 1 + Dockerfile | 71 +++++++++++++++++--------------------------- apt-dependencies.txt | 50 +++++++++++++++++-------------- 3 files changed, 57 insertions(+), 65 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 076f96c3..65c2276d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ variables: API_TEST_TMP: /tmp/api_tests_tmp DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 + BUILDKIT_PROGRESS: plain BUILDX_NO_DEFAULT_ATTESTATIONS: 1 BUILDX_BUILDER: container DOCKER_DRIVER: overlay2 diff --git a/Dockerfile b/Dockerfile index 89a569d1..c2cfe129 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ ##### OTBTF configurable Dockerfile with multi-stage build - # ---------------------------------------------------------------------------- # Init base stage - used for intermediate build env and final image # Freeze ubuntu version to avoid suprise rebuild -FROM ubuntu:jammy-20240911.1 AS base-stage +FROM ubuntu:noble-20241011 AS base-stage WORKDIR /tmp @@ -15,14 +14,11 @@ RUN apt-get update -y && apt-get upgrade -y \ && cat apt-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* -### Python3 environment -RUN ln -s /usr/bin/python3 /usr/local/bin/python && ln -s /usr/bin/pip3 /usr/local/bin/pip -# Upgrade pip and wheel -RUN pip install --no-cache-dir -U pip wheel -# Numpy 2 support in TF is planned for 2.18, but isn't supported by most libraries for now -ARG NUMPY="1.26.4" -RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests \ - && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing +ENV PYTHON_VERSION=3.12 +ENV VIRTUAL_ENV=/opt/otbtf/venv +ENV PATH="$VIRTUAL_ENV/bin:/opt/otbtf/bin:$PATH" +ENV PYTHON_SITE_PACKAGES="$VIRTUAL_ENV/lib/python$PYTHON_VERSION/site-packages" +ENV LD_LIBRARY_PATH="/opt/otbtf/lib" # ---------------------------------------------------------------------------- # Tmp builder stage - dangling cache should persist until "docker builder prune" @@ -30,16 +26,13 @@ FROM base-stage AS build-stage # A smaller value may be used to limit bazel or to avoid OOM errors while building OTB ARG CPU_RATIO=1 -# Install Clang+LLVM 18 -RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 18 -ENV CC=/usr/bin/clang-18 -ENV CXX=/usr/bin/clang++-18 -ENV BAZEL_COMPILER=/usr/bin/clang-18 -RUN apt-get update -y && apt-get upgrade -y \ - && apt-get install -y libomp-18-dev \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /src/tf /opt/otbtf/bin /opt/otbtf/include /opt/otbtf/lib/python3 +### Python venv and packages +RUN virtualenv $VIRTUAL_ENV +RUN pip install --no-cache-dir -U pip wheel +# Numpy 2 support in TF is planned for 2.18, but isn't supported by most libraries for now +ARG NUMPY="1.26.4" +RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests \ + && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing ### TF ARG TF=v2.18.0-rc2 @@ -47,6 +40,8 @@ ARG WITH_CUDA=false ARG WITH_MKL=false ARG WITH_XLA=true +RUN mkdir -p /opt/otbtf/{bin,lib,include} + # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ && chmod +x /opt/otbtf/bin/bazelisk \ @@ -62,12 +57,9 @@ ARG ZIP_COMP_FILES=false RUN git config --global advice.detachedHead false RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git \ && cd tensorflow \ - && export PATH="$PATH:/opt/otbtf/bin" \ - && export LD_LIBRARY_PATH="/opt/otbtf/lib" \ && export TMP=/tmp/bazel \ - && export PYTHON_BIN_PATH=$(which python3) \ - && export PYTHON_LIB_PATH=$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])') \ - && export TF_PYTHON_VERSION=$($PYTHON_BIN_PATH -c 'import sys; print(sys.version[:4])') \ + && export PYTHON_BIN_PATH=$(which python) \ + && export TF_PYTHON_VERSION=$PYTHON_VERSION \ && export BZL_CONFIGS="--config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ @@ -76,24 +68,21 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ - && pip3 install --no-cache-dir --prefix=/opt/otbtf ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ - && ln -s /opt/otbtf/local/lib/python3.*/* /opt/otbtf/lib/python3 \ - && 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 \ + && pip install --no-cache-dir ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ + && ln -s $(find /opt/otbtf/venv -type d -wholename "*/tensorflow/include") /opt/otbtf/include/tf \ && cp tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ && ( ! $ZIP_COMP_FILES || 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* bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl ) \ && rm -rf bazel-* /src/tf /root/.cache/ /tmp/* ### OTB +WORKDIR /src/otb + ARG OTB=release-9.1 ARG OTBTESTS=false ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ -RUN mkdir /src/otb -WORKDIR /src/otb - # SuperBuild OTB RUN apt-get update -y \ && apt-get install --reinstall ca-certificates -y \ @@ -134,15 +123,15 @@ RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf ARG KEEP_SRC_OTB=false RUN cd /src/otb/build/OTB/build \ - && export LD_LIBRARY_PATH=/opt/otbtf/lib \ - && export PATH=$PATH:/opt/otbtf/bin \ && cmake /src/otb/otb \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ - -DOTB_WRAP_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 \ - -DOTB_USE_TENSORFLOW=ON -DModule_OTBTensorflow=ON \ + -DOTB_WRAP_PYTHON=ON \ + -DPYTHON_EXECUTABLE=$(wich python) \ + -DOTB_USE_TENSORFLOW=ON \ + -DModule_OTBTensorflow=ON \ -Dtensorflow_include_dir=/opt/otbtf/include/tf \ - -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=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_cc.so.2 \ + -DTENSORFLOW_FRAMEWORK_LIB=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_framework.so.2 \ && make install -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && ( $KEEP_SRC_OTB || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* @@ -166,17 +155,13 @@ COPY --from=build-stage --chown=otbuser:otbuser /opt/otbtf /opt/otbtf COPY --from=build-stage --chown=otbuser:otbuser /src /src # System-wide ENV -ENV PATH="/opt/otbtf/bin:$PATH" -ENV LD_LIBRARY_PATH="/opt/otbtf/lib" -ENV PYTHONPATH="/opt/otbtf/lib/python3/dist-packages:/opt/otbtf/lib/otb/python" +ENV PYTHONPATH="/opt/otbtf/lib/otb/python:$PYTHONPATH" ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" RUN pip install -e /src/otbtf WORKDIR /home/otbuser # Default user, directory and command (bash will be the default entrypoint) USER otbuser -# User-only ENV -ENV PATH="/home/otbuser/.local/bin:$PATH" # Test python imports RUN python -c "import tensorflow" diff --git a/apt-dependencies.txt b/apt-dependencies.txt index 79fe0819..b36e9bff 100644 --- a/apt-dependencies.txt +++ b/apt-dependencies.txt @@ -1,31 +1,37 @@ apt-transport-https ca-certificates -curl -cmake -cppcheck -file -g++ -gcc -git -git-lfs -gpg -libc6-dev -libtool lsb-release -make +software-properties-common +gpg +file +sudo +zip +unzip +curl +wget +vim nano -patch -patchelf -pkg-config + python3-dev python3-pip python3-setuptools python3-venv -software-properties-common -swig -unzip -vim virtualenv -wget -sudo -zip + +pkg-config +git +git-lfs +libtool +libc6-dev +swig +cppcheck +cmake +make +patch +patchelf +g++ +gcc + +clang-18 +llvm-18 +libomp-18-dev -- GitLab From 715f9d25ae1a76d5ddd758f46288c49cd979a915 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 17 Oct 2024 18:39:03 +0200 Subject: [PATCH 109/317] Fix mkdir cmd --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c2cfe129..6f457ed5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,7 @@ ARG WITH_CUDA=false ARG WITH_MKL=false ARG WITH_XLA=true -RUN mkdir -p /opt/otbtf/{bin,lib,include} +RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include # Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ -- GitLab From 4ac8d27e3bd8b0320719fc2084f30202f513b760 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 20:09:54 +0200 Subject: [PATCH 110/317] Move LLVM and Clang outside of final image --- Dockerfile | 10 ++++++++-- apt-dependencies.txt => system-dependencies.txt | 15 +++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) rename apt-dependencies.txt => system-dependencies.txt (80%) diff --git a/Dockerfile b/Dockerfile index 6f457ed5..e8ede45e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,14 @@ ARG NUMPY="1.26.4" RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing -### TF +### TensorFlow +WORKDIR /src/tf + +# Clang + LLVM +RUN apt-get update \ + && apt-get install clang-18 llvm-18 libomp-18-dev \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + ARG TF=v2.18.0-rc2 ARG WITH_CUDA=false ARG WITH_MKL=false @@ -52,7 +59,6 @@ ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package ARG BZL_OPTIONS # Build and install TF wheels -WORKDIR /src/tf ARG ZIP_COMP_FILES=false RUN git config --global advice.detachedHead false RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git \ diff --git a/apt-dependencies.txt b/system-dependencies.txt similarity index 80% rename from apt-dependencies.txt rename to system-dependencies.txt index b36e9bff..16a3c67c 100644 --- a/apt-dependencies.txt +++ b/system-dependencies.txt @@ -1,7 +1,6 @@ apt-transport-https ca-certificates lsb-release -software-properties-common gpg file sudo @@ -12,12 +11,6 @@ wget vim nano -python3-dev -python3-pip -python3-setuptools -python3-venv -virtualenv - pkg-config git git-lfs @@ -32,6 +25,8 @@ patchelf g++ gcc -clang-18 -llvm-18 -libomp-18-dev +python3-dev +python3-pip +python3-setuptools +python3-venv +virtualenv -- GitLab From 26f35d88a7af1d90cdb1af0faddaa23403c4218e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 20:10:06 +0200 Subject: [PATCH 111/317] Try fix bazel build with missing env var --- Dockerfile | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index e8ede45e..9564c36d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,16 +9,16 @@ WORKDIR /tmp ### System packages ARG DEBIAN_FRONTEND=noninteractive -COPY apt-dependencies.txt ./ +COPY system-dependencies.txt ./ RUN apt-get update -y && apt-get upgrade -y \ - && cat apt-dependencies.txt | xargs apt-get install --no-install-recommends -y \ + && cat system-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* ENV PYTHON_VERSION=3.12 ENV VIRTUAL_ENV=/opt/otbtf/venv ENV PATH="$VIRTUAL_ENV/bin:/opt/otbtf/bin:$PATH" ENV PYTHON_SITE_PACKAGES="$VIRTUAL_ENV/lib/python$PYTHON_VERSION/site-packages" -ENV LD_LIBRARY_PATH="/opt/otbtf/lib" +ENV LD_LIBRARY_PATH=/opt/otbtf/lib # ---------------------------------------------------------------------------- # Tmp builder stage - dangling cache should persist until "docker builder prune" @@ -65,12 +65,13 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi && cd tensorflow \ && export TMP=/tmp/bazel \ && export PYTHON_BIN_PATH=$(which python) \ + && export PYTHON_LIB_PATH=$PYTHON_SITE_PACKAGES \ && export TF_PYTHON_VERSION=$PYTHON_VERSION \ && export BZL_CONFIGS="--config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ - && BZL_CMD="build $BZL_TARGETS $BZL_OPTIONS $BZL_CONFIGS --verbose_failures" \ + && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS --verbose_failures $BZL_OPTIONS" \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ @@ -142,31 +143,34 @@ RUN cd /src/otb/build/OTB/build \ && ( $KEEP_SRC_OTB || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* +# Install OTBTF python lib +RUN pip install -e /src/otbtf + # 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 +# Final stage from a clean base FROM base-stage AS final-stage LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" +# System-wide ENV +ENV PYTHONPATH="/opt/otbtf/lib/otb/python" +ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" + # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 RUN useradd -s /bin/bash -m otbuser -# Admin rights without password (potential security issue) -ARG SUDO=false -RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi # Copy built files from intermediate stage COPY --from=build-stage --chown=otbuser:otbuser /opt/otbtf /opt/otbtf COPY --from=build-stage --chown=otbuser:otbuser /src /src -# System-wide ENV -ENV PYTHONPATH="/opt/otbtf/lib/otb/python:$PYTHONPATH" -ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" -RUN pip install -e /src/otbtf -WORKDIR /home/otbuser +# Admin rights without password (not recommended, use `docker run -u root` instead) +ARG SUDO=false +RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi # Default user, directory and command (bash will be the default entrypoint) +WORKDIR /home/otbuser USER otbuser # Test python imports -- GitLab From c16f5e4d437e0bb962ae671b5a4acdb52799ea42 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 20:16:15 +0200 Subject: [PATCH 112/317] Add missing --yes opt for apt-get cmd --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9564c36d..dcfced25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ WORKDIR /src/tf # Clang + LLVM RUN apt-get update \ - && apt-get install clang-18 llvm-18 libomp-18-dev \ + && apt-get install --no-install-recommends -y clang-18 llvm-18 libomp-18-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* ARG TF=v2.18.0-rc2 -- GitLab From 58a4b63ee554a64e5c8f3006c7dd62bfa4235fcf Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 20:28:28 +0200 Subject: [PATCH 113/317] Add missing package lld --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dcfced25..bb241b17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ WORKDIR /src/tf # Clang + LLVM RUN apt-get update \ - && apt-get install --no-install-recommends -y clang-18 llvm-18 libomp-18-dev \ + && apt-get install --no-install-recommends -y clang-18 llvm-18 libomp-18-dev lld-18 \ && apt-get clean && rm -rf /var/lib/apt/lists/* ARG TF=v2.18.0-rc2 -- GitLab From fb47a480725045f1227ab9e2f7df25eb293b258e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 22:22:12 +0200 Subject: [PATCH 114/317] Add missing env OTB_INSTALL_DIR --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index bb241b17..f7f9e8e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -155,8 +155,9 @@ FROM base-stage AS final-stage LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" # System-wide ENV -ENV PYTHONPATH="/opt/otbtf/lib/otb/python" -ENV OTB_APPLICATION_PATH="/opt/otbtf/lib/otb/applications" +ENV OTB_INSTALL_DIR=/opt/otbtf +ENV PYTHONPATH=/opt/otbtf/lib/otb/python +ENV OTB_APPLICATION_PATH=/opt/otbtf/lib/otb/applications # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 RUN useradd -s /bin/bash -m otbuser -- GitLab From d02e6ab01e8cd976531e34f030a371c5af5baad6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 17 Oct 2024 22:22:34 +0200 Subject: [PATCH 115/317] Add wheel name and var PY=3.12 --- Dockerfile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index f7f9e8e5..4079ce04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,10 +14,10 @@ RUN apt-get update -y && apt-get upgrade -y \ && cat system-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* -ENV PYTHON_VERSION=3.12 +ENV PY=3.12 ENV VIRTUAL_ENV=/opt/otbtf/venv ENV PATH="$VIRTUAL_ENV/bin:/opt/otbtf/bin:$PATH" -ENV PYTHON_SITE_PACKAGES="$VIRTUAL_ENV/lib/python$PYTHON_VERSION/site-packages" +ENV PYTHON_SITE_PACKAGES="$VIRTUAL_ENV/lib/python$PY/site-packages" ENV LD_LIBRARY_PATH=/opt/otbtf/lib # ---------------------------------------------------------------------------- @@ -64,14 +64,12 @@ RUN git config --global advice.detachedHead false RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git \ && cd tensorflow \ && export TMP=/tmp/bazel \ - && export PYTHON_BIN_PATH=$(which python) \ - && export PYTHON_LIB_PATH=$PYTHON_SITE_PACKAGES \ - && export TF_PYTHON_VERSION=$PYTHON_VERSION \ - && export BZL_CONFIGS="--config=release_cpu_linux" \ - && ( ! $WITH_CUDA || export BZL_CONFIGS="--config=release_gpu_linux --config=cuda_clang --config=cuda_wheel" ) \ + && export TF_PYTHON_VERSION=$PY \ + && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ + && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ - && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS --verbose_failures $BZL_OPTIONS" \ + && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ @@ -87,6 +85,7 @@ WORKDIR /src/otb ARG OTB=release-9.1 ARG OTBTESTS=false + ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ -- GitLab From 044ff1a4217e0a5a64695a200d1653562f5bddfb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 18 Oct 2024 00:52:12 +0200 Subject: [PATCH 116/317] Trying new CI rules --- .gitlab-ci.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 65c2276d..2347baa2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,8 +25,14 @@ services: - name: docker:dind workflow: + auto_cancel: + on_new_commit: interruptible rules: - - if: $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ # Execute jobs in merge request context, or commit in master branch + # Execute jobs in merge request context, or commit in master branch + - if: $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ + # Ignore pipeline for filthy commits + - if: $CI_COMMIT_MESSAGE =~ /^(Draft|WIP|wip)/ + when: never stages: - Build @@ -99,6 +105,11 @@ cppcheck: pages_test: extends: .doc_base + only: + changes: + - doc/* + - mkdocs.yml + - .readthedocs.yaml except: - master script: @@ -139,6 +150,9 @@ ctest: .applications_test_base: extends: .tests_base + rules: + - if: $CI_MERGE_REQUEST_ID + when: manual stage: Applications Test before_script: - pip install pytest pytest-cov pytest-order -- GitLab From 604faebed8e318e4374f95c1d86cfb60bed9e20a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 18 Oct 2024 00:53:42 +0200 Subject: [PATCH 117/317] Drop find in tf include link command --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4079ce04..78884652 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,7 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ && pip install --no-cache-dir ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ - && ln -s $(find /opt/otbtf/venv -type d -wholename "*/tensorflow/include") /opt/otbtf/include/tf \ + && ln -s $PYTHON_SITE_PACKAGES/tensorflow/include /opt/otbtf/include/tf \ && cp tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ && ( ! $ZIP_COMP_FILES || 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* bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl ) \ -- GitLab From d4c478b03eeced787fdc6c5fc03b7ef36effde13 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 10:49:30 +0200 Subject: [PATCH 118/317] Bump version 4.4 --- doc/docker_use.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/docker_use.md b/doc/docker_use.md index 0001d148..9e6bc3f1 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -26,10 +26,10 @@ versions <= 4.3.0 and [forgemia.inra.fr](https://forgemia.inra.fr/orfeo-toolbox/ | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:4.3.2-cpu** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU | no | | -| **mdl4eo/otbtf:4.3.2-cpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | CPU (dev) | yes | | -| **mdl4eo/otbtf:4.3.2-gpu** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU | no | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| -| **mdl4eo/otbtf:4.3.2-gpu-dev** | Ubuntu Jammy | r2.17 | 9.1.0 | GPU (dev) | yes | 5.2,6.1,7.0,7.5,8.0,8.6,8.9,9.0| +| **mdl4eo/otbtf:4.4.0-cpu** | Ubuntu Jammy | r2.18 | 9.1.0 | CPU | no | | +| **mdl4eo/otbtf:4.4.0-cpu-dev** | Ubuntu Jammy | r2.18 | 9.1.0 | CPU (dev) | yes | | +| **mdl4eo/otbtf:4.4.0-gpu** | Ubuntu Jammy | r2.18 | 9.1.0 | GPU | no | sm_60,sm_70,sm_80,sm_89,compute_90 | +| **mdl4eo/otbtf:4.4.0-gpu-dev** | Ubuntu Jammy | r2.18 | 9.1.0 | GPU (dev) | yes | sm_60,sm_70,sm_80,sm_89,compute_90| The list of older releases is available [here](#older-images). -- GitLab From d0f79b816d8161df6b480ca20ec0e26f6f08be3b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 10:49:45 +0200 Subject: [PATCH 119/317] Back to ubuntu jammy, but now with virtualenv --- Dockerfile | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 78884652..81d011e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # Init base stage - used for intermediate build env and final image # Freeze ubuntu version to avoid suprise rebuild -FROM ubuntu:noble-20241011 AS base-stage +FROM ubuntu:jammy-20240911.1 AS base-stage WORKDIR /tmp @@ -14,7 +14,7 @@ RUN apt-get update -y && apt-get upgrade -y \ && cat system-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* -ENV PY=3.12 +ENV PY=3.10 ENV VIRTUAL_ENV=/opt/otbtf/venv ENV PATH="$VIRTUAL_ENV/bin:/opt/otbtf/bin:$PATH" ENV PYTHON_SITE_PACKAGES="$VIRTUAL_ENV/lib/python$PY/site-packages" @@ -38,8 +38,12 @@ RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY WORKDIR /src/tf # Clang + LLVM -RUN apt-get update \ - && apt-get install --no-install-recommends -y clang-18 llvm-18 libomp-18-dev lld-18 \ +RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 18 +ENV CC=/usr/bin/clang-18 +ENV CXX=/usr/bin/clang++-18 +ENV BAZEL_COMPILER=/usr/bin/clang-18 +RUN apt-get update -y && apt-get upgrade -y \ + && apt-get install -y lld-18 libomp-18-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* ARG TF=v2.18.0-rc2 @@ -49,7 +53,7 @@ ARG WITH_XLA=true RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include -# Install bazelisk (will read .bazelversion and download the right bazel binary - latest by default) +# Install bazelisk: will read .bazelversion and download the right bazel binary RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ && chmod +x /opt/otbtf/bin/bazelisk \ && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel @@ -58,7 +62,7 @@ ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package # You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time ARG BZL_OPTIONS -# Build and install TF wheels +# Build and install TF wheel ARG ZIP_COMP_FILES=false RUN git config --global advice.detachedHead false RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git \ @@ -108,7 +112,7 @@ RUN cd /src/otb/otb \ && echo "" > Modules/Core/ImageBase/test/CMakeLists.txt \ && echo "" > Modules/Learning/DempsterShafer/test/CMakeLists.txt \ && cd .. \ - && mkdir -p build \ + && mkdir -p build /tmp/SuperBuild-downloads \ && cd build \ && cmake ../otb/SuperBuild \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ @@ -121,7 +125,9 @@ RUN cd /src/otb/otb \ -DOTB_BUILD_Segmentation=ON \ -DOTB_BUILD_StereoProcessing=ON \ $($OTBTESTS && echo "-DBUILD_TESTING=ON") \ - && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") + -DDOWNLOAD_LOCATION=/tmp/SuperBuild-downloads \ + && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ + && rm -rf /tmp/SuperBuild-downloads # Rebuild OTB with OTBTF module COPY . /src/otbtf @@ -142,7 +148,7 @@ RUN cd /src/otb/build/OTB/build \ && ( $KEEP_SRC_OTB || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* -# Install OTBTF python lib +# Install OTBTF python module RUN pip install -e /src/otbtf # Symlink executable python files in PATH -- GitLab From 2debd3ddd3a86121e46b13670aa71284de5bfdf6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 10:55:51 +0200 Subject: [PATCH 120/317] Add missing ubuntu pkg --- system-dependencies.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/system-dependencies.txt b/system-dependencies.txt index 16a3c67c..53388447 100644 --- a/system-dependencies.txt +++ b/system-dependencies.txt @@ -1,6 +1,7 @@ apt-transport-https ca-certificates lsb-release +software-properties-common gpg file sudo -- GitLab From 197ad51ebde22ae6de6164b2514b48e55012e7b8 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 13:23:40 +0200 Subject: [PATCH 121/317] Add missing python path for osgeo / gdal --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 81d011e8..06f8fee4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -161,7 +161,7 @@ LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" # System-wide ENV ENV OTB_INSTALL_DIR=/opt/otbtf -ENV PYTHONPATH=/opt/otbtf/lib/otb/python +ENV PYTHONPATH=/opt/otbtf/lib/otb/python:/opt/otbtf/lib/python3/dist-packages/ ENV OTB_APPLICATION_PATH=/opt/otbtf/lib/otb/applications # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 -- GitLab From f25af23de70e251070d12bc9c43c428e41f8eb42 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 13:27:21 +0200 Subject: [PATCH 122/317] Fix typo --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 06f8fee4..a604ed30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -138,7 +138,7 @@ RUN cd /src/otb/build/OTB/build \ && cmake /src/otb/otb \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ -DOTB_WRAP_PYTHON=ON \ - -DPYTHON_EXECUTABLE=$(wich python) \ + -DPYTHON_EXECUTABLE=$(which python) \ -DOTB_USE_TENSORFLOW=ON \ -DModule_OTBTensorflow=ON \ -Dtensorflow_include_dir=/opt/otbtf/include/tf \ -- GitLab From 361e0301d1d564af97fc418a109e059971aa263d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 13:37:56 +0200 Subject: [PATCH 123/317] Update release notes --- RELEASE_NOTES.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 2beeb575..75d6e4b1 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,12 +1,13 @@ Version 4.4.0 (?? ??? ????) ---------------------------------------------------------------- * Bump OTB version to 9.1.0 -* Bump TensorFlow to 2.18.0 +* Bump TensorFlow version to 2.18.0 +* Move python pip install to virtualenv /opt/otbtf/venv * Lock numpy version < 2.0 * Upgrade TF build workflow to latest specs: - - Drop Docker build argument BASE_IMG (ubuntu22 is used for every build) - - Use official wheels bazel configs (targets --config=release_{cpu,gpu}) - - Compile with Clang LLVM18, use "HERMETIC_CUDA" 12.5 + - Drop Docker build argument BASE_IMG (ubuntu jammy is used for every build) + - Use official bazel configs (targets --config=release_{cpu,gpu}) for wheels + - Compile with LLVM Clang 18, use "HERMETIC_CUDA" 12.5 - Use default compute capabilities from .bazelrc (sm_60,sm_70,sm_80,sm_89,compute_90) - Add Docker build arguments WITH_CUDA=false, WITH_MKL=false, WITH_XLA=true - TODO: update python code for Keras 3 -- GitLab From 61b0ccbbe12071938a729c2a02b5ebf166afcb8d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 13:38:25 +0200 Subject: [PATCH 124/317] Add files to Dockerignore to avoid unnecessary rebuild --- .dockerignore | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index ee7534dd..3fa1d2fd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,7 @@ -.git -python/__pycache__ -.gitlab-ci.yml -.readthedocs.yaml -mkdocs.yml +.* +.git* +Dockerfile +**/__pycache__ doc/* +mkdocs.yml +RELEASE_NOTES.txt -- GitLab From 1ed9af017d15f6befbcfcbaa3a834e108db33c34 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 13:42:57 +0200 Subject: [PATCH 125/317] Comment otbtf python import to locate gdal --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a604ed30..71d6e50e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -181,5 +181,5 @@ USER otbuser # Test python imports RUN python -c "import tensorflow" -RUN python -c "import otbtf, tricks" -RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" +#RUN python -c "import otbtf, tricks" +#RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" -- GitLab From 604415f9589564b38bc951bbd4992e1e8cb895af Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 14:06:41 +0200 Subject: [PATCH 126/317] Fix osgeo install dir --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71d6e50e..c7aa7e96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,7 +98,9 @@ RUN apt-get update -y \ && apt-get install --reinstall ca-certificates -y \ && update-ca-certificates \ && git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git \ - && cd otb && git checkout $OTB + && cd otb \ + && git checkout $OTB \ + && rm -rf .git # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 @@ -161,7 +163,7 @@ LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" # System-wide ENV ENV OTB_INSTALL_DIR=/opt/otbtf -ENV PYTHONPATH=/opt/otbtf/lib/otb/python:/opt/otbtf/lib/python3/dist-packages/ +ENV PYTHONPATH="/opt/otbtf/lib/otb/python:/opt/otbtf/lib/python$PY/site-packages" ENV OTB_APPLICATION_PATH=/opt/otbtf/lib/otb/applications # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 @@ -181,5 +183,5 @@ USER otbuser # Test python imports RUN python -c "import tensorflow" -#RUN python -c "import otbtf, tricks" -#RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" +RUN python -c "import otbtf, tricks" +RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" -- GitLab From 4d9814ebc034f61edef1a6c60c9f797ade828851 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 14:33:58 +0200 Subject: [PATCH 127/317] Use "pull_policy: always" for $BRANCH_IMAGE --- .gitlab-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2347baa2..745fe77a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,7 +66,9 @@ docker_image: .static_analysis_base: stage: Static Analysis - image: $BRANCH_IMAGE + image: + name: $BRANCH_IMAGE + pull_policy: always allow_failure: true flake8: @@ -95,7 +97,9 @@ cppcheck: .doc_base: stage: Documentation - image: $BRANCH_IMAGE + image: + name: $BRANCH_IMAGE + pull_policy: always before_script: - pip install -r doc/doc_requirements.txt artifacts: @@ -126,7 +130,9 @@ pages: - public .tests_base: - image: $BRANCH_IMAGE + image: + name: $BRANCH_IMAGE + pull_policy: always tags: [ godzilla ] artifacts: paths: -- GitLab From 50278226ea4ed24f50dbce93a9849f785ac38d56 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 14:51:01 +0200 Subject: [PATCH 128/317] Add default: godzilla runner, branch image with always pull_policy --- .gitlab-ci.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 745fe77a..0948aa1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,10 +20,6 @@ variables: DOCKERHUB_BASE: mdl4eo/otbtf DOCKERHUB_IMAGE_BASE: ${DOCKERHUB_BASE}:${OTBTF_VERSION} -image: docker:latest -services: - - name: docker:dind - workflow: auto_cancel: on_new_commit: interruptible @@ -43,10 +39,16 @@ stages: - Update dev image - Ship -.docker_build_base: +default: tags: [ godzilla ] - allow_failure: false - timeout: 10 hours + image: + name: $BRANCH_IMAGE + pull_policy: always + +.docker_build_base: + image: docker:latest + services: + - name: docker:dind before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - docker buildx create --name container --driver=docker-container @@ -66,9 +68,6 @@ docker_image: .static_analysis_base: stage: Static Analysis - image: - name: $BRANCH_IMAGE - pull_policy: always allow_failure: true flake8: @@ -97,9 +96,6 @@ cppcheck: .doc_base: stage: Documentation - image: - name: $BRANCH_IMAGE - pull_policy: always before_script: - pip install -r doc/doc_requirements.txt artifacts: @@ -130,10 +126,6 @@ pages: - public .tests_base: - image: - name: $BRANCH_IMAGE - pull_policy: always - tags: [ godzilla ] artifacts: paths: - $ARTIFACT_TEST_DIR/*.* -- GitLab From fcc9a69bf4f8bd02f35da0679e61d5a2535920fb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 15:02:42 +0200 Subject: [PATCH 129/317] Ruuners godzilla for builds, goldenrunner for tests and stable docs and static tests --- .gitlab-ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0948aa1e..ecd996be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,12 +40,12 @@ stages: - Ship default: - tags: [ godzilla ] image: name: $BRANCH_IMAGE pull_policy: always .docker_build_base: + tags: [ godzilla ] image: docker:latest services: - name: docker:dind @@ -67,6 +67,7 @@ docker_image: "." .static_analysis_base: + tags: [ stable ] stage: Static Analysis allow_failure: true @@ -95,6 +96,7 @@ cppcheck: - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . .doc_base: + tags: [ stable ] stage: Documentation before_script: - pip install -r doc/doc_requirements.txt @@ -126,6 +128,7 @@ pages: - public .tests_base: + tags: [ goldenrunner ] artifacts: paths: - $ARTIFACT_TEST_DIR/*.* @@ -148,9 +151,9 @@ ctest: .applications_test_base: extends: .tests_base - rules: - - if: $CI_MERGE_REQUEST_ID - when: manual + #rules: + # - if: $CI_MERGE_REQUEST_ID + # when: manual stage: Applications Test before_script: - pip install pytest pytest-cov pytest-order -- GitLab From f40bb2c5a0e7bd8c7e45c108d4b9476077360c6b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 15:18:36 +0200 Subject: [PATCH 130/317] Do not remove /src/otb/otb/.git --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c7aa7e96..0f80d93c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,8 +99,7 @@ RUN apt-get update -y \ && update-ca-certificates \ && git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git \ && cd otb \ - && git checkout $OTB \ - && rm -rf .git + && git checkout $OTB # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 -- GitLab From 761ac66b8d3c1f6c946b983d6920b69251bbfc10 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 16:17:37 +0200 Subject: [PATCH 131/317] Update docker docs --- doc/docker_build.md | 116 ++++++++++++++++++++-------------- doc/docker_troubleshooting.md | 16 ++--- doc/docker_use.md | 7 +- 3 files changed, 79 insertions(+), 60 deletions(-) diff --git a/doc/docker_build.md b/doc/docker_build.md index a1dcef01..caca36c4 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -1,79 +1,102 @@ # Build your own docker images -Docker build has to be called from the root of the repository (i.e. `docker -build .`. -You can build choose target versions using `--build-arg` : +Docker build has to be called from the root of the repository (i.e. `docker + build .`. +You can select target versions using `--build-arg`: -- **TensorFlow** : `TF` arg for the git branch or tag + *build-env-tf.sh* and -BZL_* arguments for the build configuration. `ZIP_COMP_FILES` allows you to save -compiled tf binaries if you want to install it elsewhere. -- **OrfeoToolBox** : `OTB` arg for the git branch or tag + -*tools/docker/build-flags-otb.txt* to edit cmake flags. Set `KEEP_SRC_OTB` in -order to preserve OTB git directory. +- **TensorFlow** : `TF` arg for the git branch or tag, `ZIP_COMP_FILES` + allows you to save compiled tf binaries if you want to install it elsewhere. +- **OrfeoToolBox** : `OTB` arg for the git branch or tag, set `KEEP_SRC_OTB` +in order to preserve OTB sources -### Default arguments +## Default build arguments ```bash -BASE_IMG # mandatory +# Limit CPU usage e.g. 0.75 CPU_RATIO=1 +# Can be used to install a specific numpy version NUMPY_SPEC="<2" +# Git branch or tag to checkout TF=v2.18.0 +# Build with XLA WITH_XLA=true +# Build with Intel MKL support WITH_MKL=false +# Set to true to enable Nvidia GPU support WITH_CUDA=false -OTB=release-9.1 +# Custom compute capabilities, default are defined in repo tensorflow/.bazelrc +# Currently "sm_60,sm_70,sm_80,sm_89,compute_90" +CUDA_COMPUTE_CAPABILITIES= +# Targets for bazel build cmd BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" -BZL_OPTIONS="--verbose_failures" +# Availabe for additional bazel options, e.g. --remote_cache +BZL_OPTIONS= +# Zip and save tf compiled files in /opt/otbtf, to install elsewhere ZIP_COMP_FILES=false +# Git branch or tag to checkout +OTB=release-9.1 +# Keep OTB sources KEEP_SRC_OTB=false -SUDO=true +# Enable sudo without password for "otbuser" +SUDO=false ``` -### Bazel remote cache daemon +## Bazel remote cache daemon -If you just need to rebuild with different GUI or KEEP_SRC arguments, or may -be a different branch of OTB, bazel cache will help you to rebuild everything -except TF, even if the docker cache was purged (after `docker -[system|builder] prune`). -In order to recycle the cache, bazel config and TF git tag should be exactly -the same, any change in Dockerfile or `--build-arg` would create a new build. +If you just need to rebuild with different arguments, or may be a different + branch of OTB, bazel cache will help you to rebuild everything except TF, + even if the docker cache was purged (after `docker [system|builder] prune`). +In order to recycle the cache, bazel config and TF git tag should be exactly + the same, any change in Dockerfile or `--build-arg` would create a new build. -Start a cache daemon - here with max 20GB but 10GB should be enough to save 2 -TF builds (GPU and CPU): +Start a cache daemon - 10GB should be enough to save 2 TF builds (GPU and CPU): ```bash mkdir -p $HOME/.cache/bazel-remote docker run --detach -u $UID:$GID -v $HOME/.cache/bazel-remote:/data \ - -p 9090:8080 buchgr/bazel-remote-cache --max_size=20 + -p 9090:8080 buchgr/bazel-remote-cache --max_size=10 ``` -Then just add ` --network='host'` to the docker build command, or connect -bazel to a remote server - see 'BZL_OPTIONS'. -The other way of docker is a virtual bridge, but you'll need to edit the IP -address. +Then just add ` --network='host'` to the docker build command, or connect + bazel to a remote server - see 'BZL_OPTIONS'. +The other way of docker is a virtual bridge, but you'll need to edit the IP + address. Changing the BZL_OPTIONS will invalidate docker build cache. ## Images build examples ```bash # Build for CPU using default Dockerfiles args (without AWS, HDFS or GCP # support) -docker build --network='host' --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:cpu . +docker build --network='host' -t otbtf:cpu \ + --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" . # Build for GPU -docker build --network='host' --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:gpu --build-arg WITH_CUDA=true . +docker build --network='host' -t otbtf:gpu \ + --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" \ + --build-arg WITH_CUDA=true \ + . # Build latest TF and OTB, set git branches/tags to clone -docker build --network='host' --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:gpu --build-arg WITH_CUDA=true \ +docker build --network='host' -t otbtf:gpu \ + --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" \ + --build-arg WITH_CUDA=true \ --build-arg KEEP_SRC_OTB=true \ --build-arg TF=nightly \ - --build-arg OTB=develop . + --build-arg OTB=develop \ + . ``` -### Build for another machine and save TF compiled files +### Build for another machine and save TF compiled files ```bash -docker build --network='host' -t otbtf:custom --build-arg BZL_OPTIONS="--verbose_failures --remote_cache=http://localhost:9090" -t otbtf:gpu --build-arg WITH_CUDA=true . -docker run -v $HOME:/home/otbuser/volume otbtf:custom cp /opt/otbtf/tf-v2.18.0.zip /home/otbuser/volume +docker build --network='host' -t otbtf:gpu \ + --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" \ + --build-arg WITH_CUDA=true \ + --build-arg ZIP_COMP_FILES=true \ + . + +docker run -v $HOME:/home/otbuser/volume otbtf:custom \ + cp /opt/otbtf/tf-v2.18.0.zip /home/otbuser/volume # Target machine shell cd $HOME @@ -102,13 +125,12 @@ cmake $OTB_GIT \ ``` ### Debug build - -If you fail to build, you can log into the last layer and check CMake logs. -Run `docker images`, find the latest layer ID and run a tmp container +If you fail to build, you can log into the last layer and check CMake logs. + Run `docker images`, find the latest layer ID and run a tmp container (`docker run -it d60496d9612e bash`). +**This is only possible when building with legacy docker config DOCKER_BUILDKIT=0**. You may also need to split some multi-command layers in the Dockerfile. -If you see OOM errors during SuperBuild you should decrease CPU_RATIO (e.g. -0.75). + If you see OOM errors during SuperBuild you should decrease CPU_RATIO. ## Container examples @@ -132,16 +154,14 @@ docker exec otbtf-gpu \ Enter a development ready docker image: ```bash -docker create --gpus=all -it --name otbtf-gpu-dev mdl4eo/otbtf:4.4.0-gpu -docker start -i otbtf-gpu-dev -``` - -Then, from the container shell: - -```bash -sudo -i +docker run -it --gpus=all -it --name otbtf-gpu-dev mdl4eo/otbtf:4.4.0-gpu-dev +# Then, from the container shell: cd /src/otb/otb/Modules/Remote git clone https://gitlab.irstea.fr/raffaele.gaetano/otbSelectiveHaralickTextures.git cd /src/otb/build/OTB/build cmake -DModule_OTBAppSelectiveHaralickTextures=ON /src/otb/otb && make install -j +exit +docker container ls ``` + +Then you can user `docker commit` to save this container as a new image. diff --git a/doc/docker_troubleshooting.md b/doc/docker_troubleshooting.md index 8f36cbe5..c5096717 100644 --- a/doc/docker_troubleshooting.md +++ b/doc/docker_troubleshooting.md @@ -1,24 +1,24 @@ # Docker troubleshooting -You can find plenty of help on the web about docker. -This section only provides the basics for newcomers that are eager to use -OTBTF! +You can find plenty of help on the web about docker. +This section only provides the basics for newcomers + that are eager to use OTBTF! This section is largely inspired from the -[moringa docker help](https://gitlab.irstea.fr/raffaele.gaetano/moringa/blob/develop/docker/README.md). -Big thanks to the authors. +[moringa docker help](https://gitlab.irstea.fr/raffaele.gaetano/moringa/blob/develop/docker/README.md). + Big thanks to the authors. ## Common errors ### failed call to cuInit -``` +```raw failed call to cuInit: UNKNOWN ERROR (303) / no NVIDIA GPU device is present: /dev/nvidia0 does not exist ``` -Nvidia driver is missing or disabled, make sure to add -` --gpus=all` to your docker run or create command +Nvidia driver is missing or disabled, make sure to add + ` --gpus=all` to your docker run or create command ## Useful diagnostic commands diff --git a/doc/docker_use.md b/doc/docker_use.md index 9e6bc3f1..2fbb4c60 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -42,10 +42,9 @@ The list of older releases is available [here](#older-images). ## GPU enabled docker -In Linux, this is quite straightforward. -Just follow the steps described in the -[nvidia-docker documentation](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html). -You can then use the OTBTF `gpu` tagged docker images with the **NVIDIA runtime** : +In Linux, this is quite straightforward. Just follow the steps described in the + [nvidia-docker documentation](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html). +You can then use the OTBTF `gpu` tagged docker images with the **NVIDIA runtime** : With Docker version earlier than 19.03 : -- GitLab From 84a4978920c7b1869c7c61b663f182878ad3aa9a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 16:33:55 +0200 Subject: [PATCH 132/317] Update docker docs --- doc/docker_build.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/docker_build.md b/doc/docker_build.md index caca36c4..5c295a8f 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -15,7 +15,7 @@ in order to preserve OTB sources # Limit CPU usage e.g. 0.75 CPU_RATIO=1 # Can be used to install a specific numpy version -NUMPY_SPEC="<2" +NUMPY="1.26.4" # Git branch or tag to checkout TF=v2.18.0 # Build with XLA @@ -29,7 +29,7 @@ WITH_CUDA=false CUDA_COMPUTE_CAPABILITIES= # Targets for bazel build cmd BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" -# Availabe for additional bazel options, e.g. --remote_cache +# Available for additional bazel options, e.g. --remote_cache BZL_OPTIONS= # Zip and save tf compiled files in /opt/otbtf, to install elsewhere ZIP_COMP_FILES=false -- GitLab From ef77f25ba0fc77c50c24080ab01682bbf7914329 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 16:33:58 +0200 Subject: [PATCH 133/317] Change runner tags --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ecd996be..d2073172 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -128,7 +128,6 @@ pages: - public .tests_base: - tags: [ goldenrunner ] artifacts: paths: - $ARTIFACT_TEST_DIR/*.* @@ -136,6 +135,7 @@ pages: when: on_failure ctest: + tags: [ godzilla ] extends: .tests_base stage: Test script: @@ -150,6 +150,7 @@ ctest: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR .applications_test_base: + tags: [ goldenrunner ] extends: .tests_base #rules: # - if: $CI_MERGE_REQUEST_ID -- GitLab From a20fbc69383db3df12fec7259f299bad1dcf9bb8 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 17:47:40 +0200 Subject: [PATCH 134/317] Simplify TF build commands --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f80d93c..ac0bc4de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,11 +77,13 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ - && pip install --no-cache-dir ./bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl \ + && export TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ + && pip install --no-cache-dir $TF_WHEEL \ && ln -s $PYTHON_SITE_PACKAGES/tensorflow/include /opt/otbtf/include/tf \ - && cp tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ - && ( ! $ZIP_COMP_FILES || 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* bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl ) \ + && export TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ + && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ + && ( ! $ZIP_COMP_FILES || zip -9 -j --symlinks /opt/otbtf/tf-$TF.zip $TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so* ) \ && rm -rf bazel-* /src/tf /root/.cache/ /tmp/* ### OTB -- GitLab From d9b0ec107e009c768aa9c875736178d45b9deb05 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 21:04:21 +0200 Subject: [PATCH 135/317] Add CUDA_COMPUTE_CAPABILITIES build ard --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ac0bc4de..99c59c29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,8 +48,9 @@ RUN apt-get update -y && apt-get upgrade -y \ ARG TF=v2.18.0-rc2 ARG WITH_CUDA=false -ARG WITH_MKL=false +ARG CUDA_COMPUTE_CAPABILITIES ARG WITH_XLA=true +ARG WITH_MKL=false RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include @@ -71,6 +72,7 @@ RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.gi && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ + && ([ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES") \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ @@ -164,8 +166,9 @@ LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" # System-wide ENV ENV OTB_INSTALL_DIR=/opt/otbtf -ENV PYTHONPATH="/opt/otbtf/lib/otb/python:/opt/otbtf/lib/python$PY/site-packages" ENV OTB_APPLICATION_PATH=/opt/otbtf/lib/otb/applications +# For otbApplication and osgeo modules +ENV PYTHONPATH="/opt/otbtf/lib/otb/python:/opt/otbtf/lib/python$PY/site-packages" # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 RUN useradd -s /bin/bash -m otbuser -- GitLab From d46997940748ba450cab79ab0d21b8a49e244ba6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 21:43:20 +0200 Subject: [PATCH 136/317] Use ADD instead of git clone --- Dockerfile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99c59c29..79307ad3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,10 +65,7 @@ ARG BZL_OPTIONS # Build and install TF wheel ARG ZIP_COMP_FILES=false -RUN git config --global advice.detachedHead false -RUN git clone --single-branch -b $TF https://github.com/tensorflow/tensorflow.git \ - && cd tensorflow \ - && export TMP=/tmp/bazel \ +ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ @@ -98,17 +95,12 @@ ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ # SuperBuild OTB -RUN apt-get update -y \ - && apt-get install --reinstall ca-certificates -y \ - && update-ca-certificates \ - && git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git \ - && cd otb \ - && git checkout $OTB - +ADD --keep-git-dir=true https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git#$OTB otb +# <------------------------------------------ # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 # See https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2338 -RUN cd /src/otb/otb \ +RUN cd otb \ && sed -i 's/CMAKE_CXX_STANDARD 14/CMAKE_CXX_STANDARD 17/g' CMakeLists.txt \ && echo "" > Modules/Core/ImageManipulation/test/CMakeLists.txt \ && echo "" > Modules/Core/Conversion/test/CMakeLists.txt \ -- GitLab From 43e2e955560b542004eabe1cd1582a73e84c6720 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 21:47:54 +0200 Subject: [PATCH 137/317] Try local bazel cache mount --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 79307ad3..ab4ec4f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,10 +66,12 @@ ARG BZL_OPTIONS # Build and install TF wheel ARG ZIP_COMP_FILES=false ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow +RUN --mount=type=cache,target=/root/.cache/bazel \ + cd tensorflow \ && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ - && ([ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES") \ + && ( [ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ @@ -83,7 +85,7 @@ ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow && export TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ && ( ! $ZIP_COMP_FILES || zip -9 -j --symlinks /opt/otbtf/tf-$TF.zip $TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so* ) \ - && rm -rf bazel-* /src/tf /root/.cache/ /tmp/* + && rm -rf bazel-* /src/tf ### OTB WORKDIR /src/otb -- GitLab From 24893b14c84d6e88f47d94e7406754ef85bfb54a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 21:53:16 +0200 Subject: [PATCH 138/317] Use ADD instead of wget --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ab4ec4f7..f933065f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,8 @@ RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY WORKDIR /src/tf # Clang + LLVM -RUN wget -q https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 18 +ADD https://apt.llvm.org/llvm.sh llvm.sh +RUN bash ./llvm.sh 18 ENV CC=/usr/bin/clang-18 ENV CXX=/usr/bin/clang++-18 ENV BAZEL_COMPILER=/usr/bin/clang-18 @@ -55,9 +56,8 @@ ARG WITH_MKL=false RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include # Install bazelisk: will read .bazelversion and download the right bazel binary -RUN wget -qO /opt/otbtf/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ - && chmod +x /opt/otbtf/bin/bazelisk \ - && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel +ADD https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 /opt/otbtf/bin/bazelisk +RUN chmod +x /opt/otbtf/bin/bazelisk && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time -- GitLab From 9412487809742a54d800c80cd91d910aeb5ea561 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 22:24:29 +0200 Subject: [PATCH 139/317] Separate TF and OTB build in different stages --- Dockerfile | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index f933065f..48f73c4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,13 +19,15 @@ ENV VIRTUAL_ENV=/opt/otbtf/venv ENV PATH="$VIRTUAL_ENV/bin:/opt/otbtf/bin:$PATH" ENV PYTHON_SITE_PACKAGES="$VIRTUAL_ENV/lib/python$PY/site-packages" ENV LD_LIBRARY_PATH=/opt/otbtf/lib - -# ---------------------------------------------------------------------------- -# Tmp builder stage - dangling cache should persist until "docker builder prune" -FROM base-stage AS build-stage # A smaller value may be used to limit bazel or to avoid OOM errors while building OTB ARG CPU_RATIO=1 +# ---------------------------------------------------------------------------- +### TensorFlow bazel build stage +FROM base-stage AS tf-build +WORKDIR /src/tf +RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include + ### Python venv and packages RUN virtualenv $VIRTUAL_ENV RUN pip install --no-cache-dir -U pip wheel @@ -34,9 +36,6 @@ ARG NUMPY="1.26.4" RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing -### TensorFlow -WORKDIR /src/tf - # Clang + LLVM ADD https://apt.llvm.org/llvm.sh llvm.sh RUN bash ./llvm.sh 18 @@ -46,15 +45,14 @@ ENV BAZEL_COMPILER=/usr/bin/clang-18 RUN apt-get update -y && apt-get upgrade -y \ && apt-get install -y lld-18 libomp-18-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* - + +# TF build arguments ARG TF=v2.18.0-rc2 ARG WITH_CUDA=false ARG CUDA_COMPUTE_CAPABILITIES ARG WITH_XLA=true ARG WITH_MKL=false -RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include - # Install bazelisk: will read .bazelversion and download the right bazel binary ADD https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 /opt/otbtf/bin/bazelisk RUN chmod +x /opt/otbtf/bin/bazelisk && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel @@ -87,9 +85,13 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && ( ! $ZIP_COMP_FILES || zip -9 -j --symlinks /opt/otbtf/tf-$TF.zip $TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so* ) \ && rm -rf bazel-* /src/tf -### OTB +# ---------------------------------------------------------------------------- +### OTB cmake build stage +FROM base-stage as otb-build WORKDIR /src/otb +COPY --from=tf-build /opt/otbtf /opt/otbtf + ARG OTB=release-9.1 ARG OTBTESTS=false @@ -168,8 +170,8 @@ ENV PYTHONPATH="/opt/otbtf/lib/otb/python:/opt/otbtf/lib/python$PY/site-packages RUN useradd -s /bin/bash -m otbuser # Copy built files from intermediate stage -COPY --from=build-stage --chown=otbuser:otbuser /opt/otbtf /opt/otbtf -COPY --from=build-stage --chown=otbuser:otbuser /src /src +COPY --from=otb-build --chown=otbuser:otbuser /opt/otbtf /opt/otbtf +COPY --from=otb-build --chown=otbuser:otbuser /src /src # Admin rights without password (not recommended, use `docker run -u root` instead) ARG SUDO=false -- GitLab From 92fce0a1f4e046253f5b8314c0320a2812457cfd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 22:25:29 +0200 Subject: [PATCH 140/317] Rename variable TF_BUILD_ARTIFACTS to save tf wheels in CI, rename KEEP_SRC_OTB to DEV_IMAGE --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48f73c4a..6b8116cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,7 @@ ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package ARG BZL_OPTIONS # Build and install TF wheel -ARG ZIP_COMP_FILES=false +ARG TF_BUILD_ARTIFACTS=false ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ @@ -82,7 +82,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ && export TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ - && ( ! $ZIP_COMP_FILES || zip -9 -j --symlinks /opt/otbtf/tf-$TF.zip $TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so* ) \ + && ( ! $TF_BUILD_ARTIFACTS || mkdir -p /tmp/artifacts && mv $TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so* /tmp/artifacts ) \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- @@ -134,7 +134,7 @@ RUN cd otb \ COPY . /src/otbtf RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf -ARG KEEP_SRC_OTB=false +ARG DEV_IMAGE=false RUN cd /src/otb/build/OTB/build \ && cmake /src/otb/otb \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ @@ -146,7 +146,7 @@ RUN cd /src/otb/build/OTB/build \ -DTENSORFLOW_CC_LIB=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_cc.so.2 \ -DTENSORFLOW_FRAMEWORK_LIB=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_framework.so.2 \ && make install -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ - && ( $KEEP_SRC_OTB || rm -rf /src/otb ) \ + && ( $DEV_IMAGE || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* # Install OTBTF python module -- GitLab From 7d2438bf13a5b4a14c6ce6fa9e0f3c7b7856d8fd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 22:25:51 +0200 Subject: [PATCH 141/317] Install test requirements in dev image --- .gitlab-ci.yml | 4 ---- Dockerfile | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d2073172..ea3a26ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -74,19 +74,16 @@ docker_image: flake8: extends: .static_analysis_base script: - - pip install flake8 - flake8 $OTBTF_SRC/otbtf --exclude=tensorflow_v1x pylint: extends: .static_analysis_base script: - - pip install pylint - pylint $OTBTF_SRC/otbtf --ignore=tensorflow_v1x codespell: extends: .static_analysis_base script: - - pip install codespell - codespell otbtf - codespell doc @@ -157,7 +154,6 @@ ctest: # when: manual stage: Applications Test before_script: - - pip install pytest pytest-cov pytest-order - mkdir -p $ARTIFACT_TEST_DIR - cd $CI_PROJECT_DIR diff --git a/Dockerfile b/Dockerfile index 6b8116cd..06f9a4c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -173,6 +173,9 @@ RUN useradd -s /bin/bash -m otbuser COPY --from=otb-build --chown=otbuser:otbuser /opt/otbtf /opt/otbtf COPY --from=otb-build --chown=otbuser:otbuser /src /src +# Install test packages for dev image +RUN if $DEV_IMAGE; then pip install codespell flake8 pylint pytest pytest-cov pytest-order; fi + # Admin rights without password (not recommended, use `docker run -u root` instead) ARG SUDO=false RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi -- GitLab From b0b6d6372d77b7a24f74d120fddd3d9c579a4a47 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 22:53:47 +0200 Subject: [PATCH 142/317] Update CI, remove variable OTBTESTS in favor of DEV_IMAGE --- .gitlab-ci.yml | 17 +++++++++-------- Dockerfile | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea3a26ac..257e28b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,6 +30,12 @@ workflow: - if: $CI_COMMIT_MESSAGE =~ /^(Draft|WIP|wip)/ when: never +default: + interruptible: true + image: + name: $BRANCH_IMAGE + pull_policy: always + stages: - Build - Static Analysis @@ -39,11 +45,6 @@ stages: - Update dev image - Ship -default: - image: - name: $BRANCH_IMAGE - pull_policy: always - .docker_build_base: tags: [ godzilla ] image: docker:latest @@ -63,7 +64,7 @@ docker_image: docker buildx build --push -t $BRANCH_IMAGE --cache-from type=registry,ref=$CACHE_IMAGE_CPU --cache-to type=registry,ref=$CACHE_IMAGE_CPU,mode=max,oci-mediatypes=true,image-manifest=true - --build-arg KEEP_SRC_OTB="true" --build-arg OTBTESTS="true" + --build-arg DEV_IMAGE="true" --build-arg OTBTESTS="true" "." .static_analysis_base: @@ -261,7 +262,7 @@ deploy_cpu: - > docker buildx build --push -t $IMAGE_CPUDEV --cache-from type=registry,ref=$CACHE_IMAGE_CPU - --build-arg KEEP_SRC_OTB=true + --build-arg DEV_IMAGE=true . # push images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin @@ -292,7 +293,7 @@ deploy_gpu: docker buildx build --push -t $IMAGE_GPUDEV --cache-from type=registry,ref=$CACHE_IMAGE_CPU --cache-from type=registry,ref=$CACHE_IMAGE_GPU - --build-arg WITH_CUDA=true --build-arg KEEP_SRC_OTB=true + --build-arg WITH_CUDA=true --build-arg DEV_IMAGE=true . # push gpu-* images on dockerhub - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin diff --git a/Dockerfile b/Dockerfile index 06f9a4c1..c3296518 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,6 +64,7 @@ ARG BZL_OPTIONS # Build and install TF wheel ARG TF_BUILD_ARTIFACTS=false ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow +# Save local bazel cache with docker mount RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ && export TF_PYTHON_VERSION=$PY \ @@ -93,7 +94,6 @@ WORKDIR /src/otb COPY --from=tf-build /opt/otbtf /opt/otbtf ARG OTB=release-9.1 -ARG OTBTESTS=false ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ @@ -125,7 +125,7 @@ RUN cd otb \ -DOTB_BUILD_SAR=ON \ -DOTB_BUILD_Segmentation=ON \ -DOTB_BUILD_StereoProcessing=ON \ - $($OTBTESTS && echo "-DBUILD_TESTING=ON") \ + $( ! $DEV_IMAGE || echo "-DBUILD_TESTING=ON" ) \ -DDOWNLOAD_LOCATION=/tmp/SuperBuild-downloads \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && rm -rf /tmp/SuperBuild-downloads -- GitLab From 2a454c1a6dedb07e5d0cc670ab2d85f13813a440 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 22:59:19 +0200 Subject: [PATCH 143/317] Fix Dockerfile syntax warning --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c3296518..06fbdd38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,7 +88,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ # ---------------------------------------------------------------------------- ### OTB cmake build stage -FROM base-stage as otb-build +FROM base-stage AS otb-build WORKDIR /src/otb COPY --from=tf-build /opt/otbtf /opt/otbtf -- GitLab From 8506dde6740c3b6a42637a4a2ceb2c9bfca64310 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 23:17:37 +0200 Subject: [PATCH 144/317] Hide plain progress and do not trigger pipeline on wip|WIP commit msg --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 257e28b3..c0a4a842 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ variables: API_TEST_TMP: /tmp/api_tests_tmp DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 - BUILDKIT_PROGRESS: plain + # BUILDKIT_PROGRESS: plain BUILDX_NO_DEFAULT_ATTESTATIONS: 1 BUILDX_BUILDER: container DOCKER_DRIVER: overlay2 @@ -27,7 +27,7 @@ workflow: # Execute jobs in merge request context, or commit in master branch - if: $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ # Ignore pipeline for filthy commits - - if: $CI_COMMIT_MESSAGE =~ /^(Draft|WIP|wip)/ + - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i when: never default: -- GitLab From 1fa2ad308cda29c1d6f8e6fe789d0f560514385b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 23:17:47 +0200 Subject: [PATCH 145/317] Remove useless if cmd --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 06fbdd38..966e9cb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -174,11 +174,11 @@ COPY --from=otb-build --chown=otbuser:otbuser /opt/otbtf /opt/otbtf COPY --from=otb-build --chown=otbuser:otbuser /src /src # Install test packages for dev image -RUN if $DEV_IMAGE; then pip install codespell flake8 pylint pytest pytest-cov pytest-order; fi +RUN ! $DEV_IMAGE || pip install codespell flake8 pylint pytest pytest-cov pytest-order # Admin rights without password (not recommended, use `docker run -u root` instead) ARG SUDO=false -RUN if $SUDO; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi +RUN ! $SUDO || usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # Default user, directory and command (bash will be the default entrypoint) WORKDIR /home/otbuser -- GitLab From a3e1671205f051fdcc0f08a05f47fec1aab3a4ed Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 18 Oct 2024 23:42:19 +0200 Subject: [PATCH 146/317] Add variable path to save tf build artifacts --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 966e9cb1..93f28092 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,8 @@ ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package ARG BZL_OPTIONS # Build and install TF wheel -ARG TF_BUILD_ARTIFACTS=false +ARG TF_BUILD_ARTIFACTS + ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow # Save local bazel cache with docker mount RUN --mount=type=cache,target=/root/.cache/bazel \ @@ -83,7 +84,8 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ && export TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ - && ( ! $TF_BUILD_ARTIFACTS || mkdir -p /tmp/artifacts && mv $TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so* /tmp/artifacts ) \ + && export ARTIFACTS="$TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so*" \ + && ( [ -z "$TF_BUILD_ARTIFACTS" ] || mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS ) \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- -- GitLab From daf547375240907061555c77a9923288a4b44d62 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 00:11:11 +0200 Subject: [PATCH 147/317] Try fix var TF_BUILD_ARTIFACTS --- .gitlab-ci.yml | 33 +++++++++++++++++++++++++++------ Dockerfile | 4 ++-- doc/docker_build.md | 29 +++++++++++++---------------- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0a4a842..b7d15e21 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,6 +44,7 @@ stages: - Applications Test - Update dev image - Ship + - Export TF wheels .docker_build_base: tags: [ godzilla ] @@ -238,12 +239,6 @@ deploy_cpu-dev-testing: - docker tag $BRANCH_IMAGE $DEV_IMAGE - docker push $DEV_IMAGE -.ship_base: - extends: .docker_build_base - stage: Ship - only: - - master - deploy_cpu: extends: .ship_base variables: @@ -301,3 +296,29 @@ deploy_gpu: - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST + +export_tf_wheels: + extends: .docker_build_base + stage: Export TF wheels + rules: + - when: manual + artifacts: + paths: + - cpu-build-artifacts + - gpu-build-artifacts + script: + # cpu + - > + docker buildx build --target=tf-build + --mount=type=bind,source=$(pwd)/cpu-build-artifacts,target=/tmp/artifacts + --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts + --cache-from type=registry,ref=$CACHE_IMAGE_CPU + . + # gpu + - > + docker buildx build --target=tf-build + --mount=type=bind,source=$(pwd)/gpu-build-artifacts,target=/tmp/artifacts + --build-arg WITH_CUDA=true + --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts + --cache-from type=registry,ref=$CACHE_IMAGE_GPU + . diff --git a/Dockerfile b/Dockerfile index 93f28092..25c5d169 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,7 +71,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ - && ( [ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES" ) \ + && ( [[ -z "$CUDA_COMPUTE_CAPABILITIES" ]] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ @@ -85,7 +85,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && export TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ && export ARTIFACTS="$TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so*" \ - && ( [ -z "$TF_BUILD_ARTIFACTS" ] || mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS ) \ + && ( [[ -z "$TF_BUILD_ARTIFACTS" ]] || mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS ) \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- diff --git a/doc/docker_build.md b/doc/docker_build.md index 5c295a8f..c07f94db 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -31,12 +31,12 @@ CUDA_COMPUTE_CAPABILITIES= BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # Available for additional bazel options, e.g. --remote_cache BZL_OPTIONS= -# Zip and save tf compiled files in /opt/otbtf, to install elsewhere -ZIP_COMP_FILES=false +# Path to save tf compiled wheel and libtensorflow_cc +TF_BUILD_ARTIFACTS= # Git branch or tag to checkout OTB=release-9.1 -# Keep OTB sources -KEEP_SRC_OTB=false +# Keep OTB sources and build test +DEV_IMAGE=false # Enable sudo without password for "otbuser" SUDO=false ``` @@ -80,7 +80,7 @@ docker build --network='host' -t otbtf:gpu \ docker build --network='host' -t otbtf:gpu \ --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" \ --build-arg WITH_CUDA=true \ - --build-arg KEEP_SRC_OTB=true \ + --build-arg DEV_IMAGE=true \ --build-arg TF=nightly \ --build-arg OTB=develop \ . @@ -90,30 +90,27 @@ docker build --network='host' -t otbtf:gpu \ ```bash docker build --network='host' -t otbtf:gpu \ + --mount=type=bind,source=$(pwd)/gpu-build-artifacts,target=/tmp/artifacts \ --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" \ --build-arg WITH_CUDA=true \ - --build-arg ZIP_COMP_FILES=true \ + --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts \ . -docker run -v $HOME:/home/otbuser/volume otbtf:custom \ - cp /opt/otbtf/tf-v2.18.0.zip /home/otbuser/volume - # Target machine shell -cd $HOME -unzip tf-v2.18.0.zip -sudo mkdir -p /opt/tensorflow/lib -sudo mv tf-v2.18.0/libtensorflow_cc* /opt/tensorflow/lib +cd gpu-build-artifacts/ +sudo mv libtensorflow_cc* /usr/local/lib # You may need to create a virtualenv, here TF and dependencies are installed # next to user's pip packages pip3 install -U pip wheel mock six future deprecated "numpy<2" pip3 install --no-deps keras_applications keras_preprocessing -pip3 install tf-v2.18.0/tensorflow-v2.18.0-cp310-cp310-linux_x86_64.whl +pip3 install tensorflow-v2.18.0-cp310-cp310-linux_x86_64.whl TF_WHEEL_DIR="$HOME/.local/lib/python3.10/site-packages/tensorflow" # If you installed the wheel as regular user, with root pip it should be in # /usr/local/lib/python3.*, or in your virtualenv lib/ directory -mv tf-v2.18.0/tag_constants.h $TF_WHEEL_DIR/include/tensorflow/cc/saved_model/ -# Then recompile OTB with OTBTF using libraries in /opt/tensorflow/lib and +mv tag_constants.h signature_constants.h $TF_WHEEL_DIR/include/tensorflow/cc/saved_model/ +# From a OTB git source tree +# Recompile OTB with OTBTF using libraries in /opt/tensorflow/lib and # instructions in build_from_sources.md. cmake $OTB_GIT \ -DOTB_USE_TENSORFLOW=ON \ -- GitLab From 924d95e5a6501354fbd814dd6c9115fccff67c32 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 00:14:49 +0200 Subject: [PATCH 148/317] Fix bad commit --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b7d15e21..99b3397f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -239,6 +239,12 @@ deploy_cpu-dev-testing: - docker tag $BRANCH_IMAGE $DEV_IMAGE - docker push $DEV_IMAGE +.ship_base: + extends: .docker_build_base + stage: Ship + only: + - master + deploy_cpu: extends: .ship_base variables: -- GitLab From e1c46d8c467b355c972880efbede88f01201d83a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 00:17:29 +0200 Subject: [PATCH 149/317] Fix bash conditional priority --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25c5d169..4bd873ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,7 +71,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ - && ( [[ -z "$CUDA_COMPUTE_CAPABILITIES" ]] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES" ) \ + && ( [ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ @@ -85,7 +85,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && export TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ && export ARTIFACTS="$TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so*" \ - && ( [[ -z "$TF_BUILD_ARTIFACTS" ]] || mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS ) \ + && ( [ -z "$TF_BUILD_ARTIFACTS" ] || (mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS) ) \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- -- GitLab From 8eb5c4dc8863952bdea7d364befeec0e2d9801ec Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 00:48:15 +0200 Subject: [PATCH 150/317] Restore arg OTBTESTS --- .gitlab-ci.yml | 2 +- Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 99b3397f..a4db202f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -65,7 +65,7 @@ docker_image: docker buildx build --push -t $BRANCH_IMAGE --cache-from type=registry,ref=$CACHE_IMAGE_CPU --cache-to type=registry,ref=$CACHE_IMAGE_CPU,mode=max,oci-mediatypes=true,image-manifest=true - --build-arg DEV_IMAGE="true" --build-arg OTBTESTS="true" + --build-arg DEV_IMAGE=true --build-arg OTBTESTS=true "." .static_analysis_base: diff --git a/Dockerfile b/Dockerfile index 4bd873ae..34a69e59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -96,6 +96,7 @@ WORKDIR /src/otb COPY --from=tf-build /opt/otbtf /opt/otbtf ARG OTB=release-9.1 +ARG OTBTESTS=false ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ @@ -127,7 +128,7 @@ RUN cd otb \ -DOTB_BUILD_SAR=ON \ -DOTB_BUILD_Segmentation=ON \ -DOTB_BUILD_StereoProcessing=ON \ - $( ! $DEV_IMAGE || echo "-DBUILD_TESTING=ON" ) \ + $( ! $OTBTESTS || echo "-DBUILD_TESTING=ON" ) \ -DDOWNLOAD_LOCATION=/tmp/SuperBuild-downloads \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && rm -rf /tmp/SuperBuild-downloads -- GitLab From 97468f8d291f7f56712de1fd8542f6af44809b80 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 01:32:47 +0200 Subject: [PATCH 151/317] Remove CI stage deploy_cpu-dev-testing --- .gitlab-ci.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4db202f..e2463721 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,6 @@ variables: API_TEST_TMP: /tmp/api_tests_tmp DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 - # BUILDKIT_PROGRESS: plain BUILDX_NO_DEFAULT_ATTESTATIONS: 1 BUILDX_BUILDER: container DOCKER_DRIVER: overlay2 @@ -58,8 +57,6 @@ stages: docker_image: stage: Build extends: .docker_build_base - except: - - develop script: - > docker buildx build --push -t $BRANCH_IMAGE @@ -229,16 +226,6 @@ nodata: script: - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_nodata.xml $OTBTF_SRC/test/nodata_test.py -deploy_cpu-dev-testing: - stage: Update dev image - extends: .docker_build_base - except: - - master - script: - - docker pull $BRANCH_IMAGE - - docker tag $BRANCH_IMAGE $DEV_IMAGE - - docker push $DEV_IMAGE - .ship_base: extends: .docker_build_base stage: Ship @@ -310,8 +297,8 @@ export_tf_wheels: - when: manual artifacts: paths: - - cpu-build-artifacts - - gpu-build-artifacts + - cpu-build-artifacts/ + - gpu-build-artifacts/ script: # cpu - > -- GitLab From 8eb24cd713fc8d69b4319d727765e377f7cc44b8 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 10:40:57 +0200 Subject: [PATCH 152/317] Better layer caching --- Dockerfile | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 34a69e59..6d965ada 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,14 +57,13 @@ ARG WITH_MKL=false ADD https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 /opt/otbtf/bin/bazelisk RUN chmod +x /opt/otbtf/bin/bazelisk && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel +# Build and install TF wheel +ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time ARG BZL_OPTIONS - -# Build and install TF wheel ARG TF_BUILD_ARTIFACTS -ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow # Save local bazel cache with docker mount RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ @@ -95,14 +94,10 @@ WORKDIR /src/otb COPY --from=tf-build /opt/otbtf /opt/otbtf -ARG OTB=release-9.1 -ARG OTBTESTS=false - -ENV CC=/usr/bin/gcc -ENV CXX=/usr/bin/g++ - # SuperBuild OTB +ARG OTB=release-9.1 ADD --keep-git-dir=true https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git#$OTB otb +ARG OTBTESTS=false # <------------------------------------------ # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 -- GitLab From daec08bb976380e0f23363f97eb752d3b162a2a1 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 10:43:04 +0200 Subject: [PATCH 153/317] Do not bundle python test files in final image, use local repo context instead --- .gitlab-ci.yml | 18 +++++++++--------- Dockerfile | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e2463721..591ce0e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -160,7 +160,7 @@ crc_book: extends: .applications_test_base script: - mkdir -p $CRC_BOOK_TMP - - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=$CI_PROJECT_DIR/report_tutorial.xml $OTBTF_SRC/test/tutorial_unittest.py + - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=$CI_PROJECT_DIR/report_tutorial.xml test/tutorial_unittest.py after_script: - cp $CRC_BOOK_TMP/*.* $ARTIFACT_TEST_DIR/ @@ -175,7 +175,7 @@ sr4rs: - rm -rf sr4rs - git clone https://github.com/remicres/sr4rs.git - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_sr4rs.xml $OTBTF_SRC/test/sr4rs_unittest.py + - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_sr4rs.xml test/sr4rs_unittest.py decloud: extends: .applications_test_base @@ -190,41 +190,41 @@ otbtf_api: extends: .applications_test_base script: - mkdir $API_TEST_TMP - - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_api.xml $OTBTF_SRC/test/api_unittest.py + - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_api.xml test/api_unittest.py after_script: - cp $API_TEST_TMP/*.* $ARTIFACT_TEST_DIR/ geos_enabled: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_geos_enabled.xml $OTBTF_SRC/test/geos_test.py + - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_geos_enabled.xml test/geos_test.py planetary_computer: extends: .applications_test_base script: - pip install pystac_client planetary_computer - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_pc_enabled.xml $OTBTF_SRC/test/pc_test.py + - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_pc_enabled.xml test/pc_test.py imports: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_imports.xml $OTBTF_SRC/test/imports_test.py + - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_imports.xml test/imports_test.py numpy_gdal_otb: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_numpy.xml $OTBTF_SRC/test/numpy_test.py + - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_numpy.xml test/numpy_test.py rio: extends: .applications_test_base script: - pip install rasterio --no-binary rasterio - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_rio.xml $OTBTF_SRC/test/rio_test.py + - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_rio.xml test/rio_test.py nodata: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_nodata.xml $OTBTF_SRC/test/nodata_test.py + - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_nodata.xml test/nodata_test.py .ship_base: extends: .docker_build_base diff --git a/Dockerfile b/Dockerfile index 6d965ada..4bda1299 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /tmp ### System packages ARG DEBIAN_FRONTEND=noninteractive -COPY system-dependencies.txt ./ +COPY system-dependencies.txt . RUN apt-get update -y && apt-get upgrade -y \ && cat system-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* @@ -128,11 +128,15 @@ RUN cd otb \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && rm -rf /tmp/SuperBuild-downloads -# Rebuild OTB with OTBTF module -COPY . /src/otbtf -RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf +# Copy cpp and cmake files from build context +WORKDIR /src/otbtf +COPY app include CMakeLists.txt otb-module.cmake . +RUN mkdir test +COPY test/CMakeLists.txt test/*.cxx ./test +# Rebuild OTB with OTBTF module ARG DEV_IMAGE=false +RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf RUN cd /src/otb/build/OTB/build \ && cmake /src/otb/otb \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ @@ -148,10 +152,8 @@ RUN cd /src/otb/build/OTB/build \ && rm -rf /root/.cache /tmp/* # Install OTBTF python module -RUN pip install -e /src/otbtf - -# 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 +COPY otbtf tricks README.md setup.py . +RUN pip install -e . # ---------------------------------------------------------------------------- # Final stage from a clean base -- GitLab From 3bc7a12c78eba94135f3e4d4da13bb23eb110556 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 11:17:02 +0200 Subject: [PATCH 154/317] Try fix test files location --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4bda1299..858c293e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -132,7 +132,7 @@ RUN cd otb \ WORKDIR /src/otbtf COPY app include CMakeLists.txt otb-module.cmake . RUN mkdir test -COPY test/CMakeLists.txt test/*.cxx ./test +COPY test/CMakeLists.txt test/*.cxx test/ # Rebuild OTB with OTBTF module ARG DEV_IMAGE=false @@ -141,7 +141,6 @@ RUN cd /src/otb/build/OTB/build \ && cmake /src/otb/otb \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ -DOTB_WRAP_PYTHON=ON \ - -DPYTHON_EXECUTABLE=$(which python) \ -DOTB_USE_TENSORFLOW=ON \ -DModule_OTBTensorflow=ON \ -Dtensorflow_include_dir=/opt/otbtf/include/tf \ -- GitLab From 198899862857ed3531f1f83a0dd07e34ceb7bf38 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 11:22:50 +0200 Subject: [PATCH 155/317] Try debug cmake --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 858c293e..773fcdc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -130,9 +130,10 @@ RUN cd otb \ # Copy cpp and cmake files from build context WORKDIR /src/otbtf -COPY app include CMakeLists.txt otb-module.cmake . +COPY app include CMakeLists.txt otb-module.cmake ./ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ +RUN pwd && ls -alh . # Rebuild OTB with OTBTF module ARG DEV_IMAGE=false -- GitLab From 8f88957c4c171acaa0c196a8166f3064dd1c1dac Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 11:24:33 +0200 Subject: [PATCH 156/317] Fix COPY command --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 773fcdc6..d5e012d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -130,10 +130,9 @@ RUN cd otb \ # Copy cpp and cmake files from build context WORKDIR /src/otbtf -COPY app include CMakeLists.txt otb-module.cmake ./ +COPY app/ include/ CMakeLists.txt otb-module.cmake ./ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ -RUN pwd && ls -alh . # Rebuild OTB with OTBTF module ARG DEV_IMAGE=false -- GitLab From b541950379275e8388a9170b44dc11a1de289eec Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 11:30:50 +0200 Subject: [PATCH 157/317] Fix copy command for subdirs --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d5e012d6..53d772dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -130,7 +130,9 @@ RUN cd otb \ # Copy cpp and cmake files from build context WORKDIR /src/otbtf -COPY app/ include/ CMakeLists.txt otb-module.cmake ./ +COPY app ./app +COPY include ./include +COPY CMakeLists.txt otb-module.cmake ./ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ -- GitLab From 6c2e151365b0f027e4a1f94347d20d086fc21a43 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 11:35:26 +0200 Subject: [PATCH 158/317] Debug cmake files location --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 53d772dc..ebd6c743 100644 --- a/Dockerfile +++ b/Dockerfile @@ -136,6 +136,8 @@ COPY CMakeLists.txt otb-module.cmake ./ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ +RUN ls -alrh + # Rebuild OTB with OTBTF module ARG DEV_IMAGE=false RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf @@ -153,7 +155,9 @@ RUN cd /src/otb/build/OTB/build \ && rm -rf /root/.cache /tmp/* # Install OTBTF python module -COPY otbtf tricks README.md setup.py . +COPY otbtf ./otbtf +COPY tricks ./tricks +COPY README.md setup.py . RUN pip install -e . # ---------------------------------------------------------------------------- -- GitLab From 7c6e34cafea702660275fc65f846b264e60eb620 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 11:39:13 +0200 Subject: [PATCH 159/317] Remove debug cmd --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ebd6c743..48b31377 100644 --- a/Dockerfile +++ b/Dockerfile @@ -128,7 +128,7 @@ RUN cd otb \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && rm -rf /tmp/SuperBuild-downloads -# Copy cpp and cmake files from build context +# Copy cpp and cmake files from build context (TODO: use `COPY --parents` feature when released) WORKDIR /src/otbtf COPY app ./app COPY include ./include @@ -136,8 +136,6 @@ COPY CMakeLists.txt otb-module.cmake ./ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ -RUN ls -alrh - # Rebuild OTB with OTBTF module ARG DEV_IMAGE=false RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf -- GitLab From 3d91d681802c26a2034e38ff55828e7730920543 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 11:39:19 +0200 Subject: [PATCH 160/317] Use slim python image for mkdocs build --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 591ce0e4..fe834090 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,6 +93,7 @@ cppcheck: .doc_base: tags: [ stable ] + image: python:3.10-slim stage: Documentation before_script: - pip install -r doc/doc_requirements.txt -- GitLab From a4cc93e1d08b6da80409dbcdf4c30c7ee98b08d1 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:02:33 +0200 Subject: [PATCH 161/317] Try link test data in CI, do not copy at build time --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe834090..46ca1796 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,6 +137,8 @@ ctest: stage: Test script: - cd /src/otb/otb && git lfs fetch --all && git lfs pull + - ln -s $(pwd)/test/data /src/otbtf/test/data + - ln -s $(pwd)/test/models /src/otbtf/test/models - cd $OTB_BUILD/ - ctest -L OTBTensorflow - ctest -L OTBPanSharpening -- GitLab From 19736ae99c05d80b2c0428bdef705e861ca49f7e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:10:38 +0200 Subject: [PATCH 162/317] Try ln in OTB build dir --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46ca1796..9cd7054b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,8 +137,8 @@ ctest: stage: Test script: - cd /src/otb/otb && git lfs fetch --all && git lfs pull - - ln -s $(pwd)/test/data /src/otbtf/test/data - - ln -s $(pwd)/test/models /src/otbtf/test/models + - ln -s $CI_PROJECT_DIR/test/data $OTB_BUILD/Modules/Remote/otbtf/test/data + - ln -s $CI_PROJECT_DIR/test/models $OTB_BUILD/Modules/Remote/otbtf/test/models - cd $OTB_BUILD/ - ctest -L OTBTensorflow - ctest -L OTBPanSharpening @@ -166,7 +166,7 @@ crc_book: - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=$CI_PROJECT_DIR/report_tutorial.xml test/tutorial_unittest.py after_script: - cp $CRC_BOOK_TMP/*.* $ARTIFACT_TEST_DIR/ - + sr4rs: extends: .applications_test_base script: -- GitLab From 20eafb0c31d988151a977b55d75a2ace9e362e94 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:15:34 +0200 Subject: [PATCH 163/317] Try with cp -r --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cd7054b..cf424024 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,8 +137,8 @@ ctest: stage: Test script: - cd /src/otb/otb && git lfs fetch --all && git lfs pull - - ln -s $CI_PROJECT_DIR/test/data $OTB_BUILD/Modules/Remote/otbtf/test/data - - ln -s $CI_PROJECT_DIR/test/models $OTB_BUILD/Modules/Remote/otbtf/test/models + - cp -r $CI_PROJECT_DIR/test/data $OTB_BUILD/Modules/Remote/otbtf/test/data + - cp -r $CI_PROJECT_DIR/test/models $OTB_BUILD/Modules/Remote/otbtf/test/models - cd $OTB_BUILD/ - ctest -L OTBTensorflow - ctest -L OTBPanSharpening -- GitLab From 6cad0d86acd2c36d6f378f2207adb6929137e19f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:21:05 +0200 Subject: [PATCH 164/317] Try rebuild ctest --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf424024..c9b103a9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,9 +137,10 @@ ctest: stage: Test script: - cd /src/otb/otb && git lfs fetch --all && git lfs pull - - cp -r $CI_PROJECT_DIR/test/data $OTB_BUILD/Modules/Remote/otbtf/test/data - - cp -r $CI_PROJECT_DIR/test/models $OTB_BUILD/Modules/Remote/otbtf/test/models + - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data + - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD/ + - cmake -DBUILD_TESTING=ON && make -j - ctest -L OTBTensorflow - ctest -L OTBPanSharpening - ctest -L OTBProjection -- GitLab From a75b95314e3c3c950f15ef4cbbc2923b8f6a1466 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:24:48 +0200 Subject: [PATCH 165/317] Try without cmake rerun --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9b103a9..1e090e08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -140,7 +140,6 @@ ctest: - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD/ - - cmake -DBUILD_TESTING=ON && make -j - ctest -L OTBTensorflow - ctest -L OTBPanSharpening - ctest -L OTBProjection -- GitLab From 411f0c3a1b2dd2005845cc41263cff34d8f8a88e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:31:47 +0200 Subject: [PATCH 166/317] Run all tests in godzilla runner --- .gitlab-ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e090e08..05294066 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -125,6 +125,7 @@ pages: - public .tests_base: + tags: [ godzilla ] artifacts: paths: - $ARTIFACT_TEST_DIR/*.* @@ -132,7 +133,6 @@ pages: when: on_failure ctest: - tags: [ godzilla ] extends: .tests_base stage: Test script: @@ -149,7 +149,6 @@ ctest: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR .applications_test_base: - tags: [ goldenrunner ] extends: .tests_base #rules: # - if: $CI_MERGE_REQUEST_ID @@ -170,10 +169,10 @@ crc_book: sr4rs: extends: .applications_test_base script: - - wget -O sr4rs_sentinel2_bands4328_france2020_savedmodel.zip + - wget -qO sr4rs_sentinel2_bands4328_france2020_savedmodel.zip https://nextcloud.inrae.fr/s/EZL2JN7SZyDK8Cf/download/sr4rs_sentinel2_bands4328_france2020_savedmodel.zip - unzip -o sr4rs_sentinel2_bands4328_france2020_savedmodel.zip - - wget -O sr4rs_data.zip https://nextcloud.inrae.fr/s/kDms9JrRMQE2Q5z/download + - wget -qO sr4rs_data.zip https://nextcloud.inrae.fr/s/kDms9JrRMQE2Q5z/download - unzip -o sr4rs_data.zip - rm -rf sr4rs - git clone https://github.com/remicres/sr4rs.git @@ -185,7 +184,7 @@ decloud: script: - git clone https://github.com/CNES/decloud.git - pip install -r $PWD/decloud/docker/requirements.txt - - wget https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download -O file.zip && unzip file.zip + - wget -q https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download -O file.zip && unzip file.zip - export DECLOUD_DATA_DIR="$PWD/decloud_data" - pytest decloud/tests/train_from_tfrecords_unittest.py -- GitLab From 1290697e377643d8b2802a8bd75c667e47fd3f71 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:34:49 +0200 Subject: [PATCH 167/317] Single command for codespell --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 05294066..f325b217 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,8 +83,7 @@ pylint: codespell: extends: .static_analysis_base script: - - codespell otbtf - - codespell doc + - codespell otbtf doc cppcheck: extends: .static_analysis_base -- GitLab From df5ac028b9bd79b95de0a668c703078648fff4b7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 12:53:43 +0200 Subject: [PATCH 168/317] Ensure gitlab can see junit test reports --- .gitlab-ci.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f325b217..aed4846d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,8 +126,11 @@ pages: .tests_base: tags: [ godzilla ] artifacts: + reports: + junit: report_*.xml paths: - $ARTIFACT_TEST_DIR/*.* + expire_in: 1 week when: on_failure @@ -161,7 +164,7 @@ crc_book: extends: .applications_test_base script: - mkdir -p $CRC_BOOK_TMP - - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=$CI_PROJECT_DIR/report_tutorial.xml test/tutorial_unittest.py + - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=report_tutorial.xml test/tutorial_unittest.py after_script: - cp $CRC_BOOK_TMP/*.* $ARTIFACT_TEST_DIR/ @@ -176,7 +179,7 @@ sr4rs: - rm -rf sr4rs - git clone https://github.com/remicres/sr4rs.git - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_sr4rs.xml test/sr4rs_unittest.py + - python -m pytest --junitxml=report_sr4rs.xml test/sr4rs_unittest.py decloud: extends: .applications_test_base @@ -191,41 +194,41 @@ otbtf_api: extends: .applications_test_base script: - mkdir $API_TEST_TMP - - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_api.xml test/api_unittest.py + - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py after_script: - cp $API_TEST_TMP/*.* $ARTIFACT_TEST_DIR/ geos_enabled: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_geos_enabled.xml test/geos_test.py + - python -m pytest --junitxml=report_geos_enabled.xml test/geos_test.py planetary_computer: extends: .applications_test_base script: - pip install pystac_client planetary_computer - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_pc_enabled.xml test/pc_test.py + - python -m pytest --junitxml=report_pc_enabled.xml test/pc_test.py imports: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_imports.xml test/imports_test.py + - python -m pytest --junitxml=report_imports.xml test/imports_test.py numpy_gdal_otb: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_numpy.xml test/numpy_test.py + - python -m pytest --junitxml=report_numpy.xml test/numpy_test.py rio: extends: .applications_test_base script: - pip install rasterio --no-binary rasterio - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_rio.xml test/rio_test.py + - python -m pytest --junitxml=report_rio.xml test/rio_test.py nodata: extends: .applications_test_base script: - - python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_nodata.xml test/nodata_test.py + - python -m pytest --junitxml=report_nodata.xml test/nodata_test.py .ship_base: extends: .docker_build_base -- GitLab From ccf4c281462d178d0403ea7a15ca10c8d4224edb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 13:25:43 +0200 Subject: [PATCH 169/317] Add ctest output junit --- .gitlab-ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aed4846d..62b0e297 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,11 +142,7 @@ ctest: - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD/ - - ctest -L OTBTensorflow - - ctest -L OTBPanSharpening - - ctest -L OTBProjection - - ctest -L OTBTransform - - ctest -L OTBIOGDAL + - ctest --output-junit=report_ctest.xml -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBProjection|OTBTransform|OTBIOGDAL" after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR -- GitLab From 3005431a432f551cbda45f4cff879baf03df6ba4 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 13:26:28 +0200 Subject: [PATCH 170/317] Remove duplciated string pattern --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62b0e297..b84ce189 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,7 +142,7 @@ ctest: - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD/ - - ctest --output-junit=report_ctest.xml -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBProjection|OTBTransform|OTBIOGDAL" + - ctest --output-junit=report_ctest.xml -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBTransform|OTBIOGDAL" after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR -- GitLab From 578dfe525b61b3a80acf3a359f95e70b14461375 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 13:45:02 +0200 Subject: [PATCH 171/317] Fix path for missing ctest junit artifact --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b84ce189..e5670cf9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,7 +142,7 @@ ctest: - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD/ - - ctest --output-junit=report_ctest.xml -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBTransform|OTBIOGDAL" + - ctest --output-junit=$CI_PROJECT_DIR/report_ctest.xml -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBTransform|OTBIOGDAL" after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR -- GitLab From 706a19bdf851fb20b074a448f76defb27a1e6888 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 13:49:38 +0200 Subject: [PATCH 172/317] Try fix missing artifact for ctest --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e5670cf9..ae3a7fe2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -141,8 +141,8 @@ ctest: - cd /src/otb/otb && git lfs fetch --all && git lfs pull - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - - cd $OTB_BUILD/ - - ctest --output-junit=$CI_PROJECT_DIR/report_ctest.xml -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBTransform|OTBIOGDAL" + - cd $CI_PROJECT_DIR + - ctest $OTB_BUILD -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBTransform|OTBIOGDAL" --output-junit=report_ctest.xml after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR -- GitLab From c152f008480cb47689e4a07c8f5ef942515e9713 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 13:57:10 +0200 Subject: [PATCH 173/317] Try fix ctest command --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae3a7fe2..c2ee1b07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,12 +137,15 @@ pages: ctest: extends: .tests_base stage: Test + variables: + OTB_TEST_UNITS: "Tensorflow|PanSharpening|Projection|Transform|IOGDAL" script: - cd /src/otb/otb && git lfs fetch --all && git lfs pull - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $CI_PROJECT_DIR - - ctest $OTB_BUILD -L "OTBTensorflow|OTBPanSharpening|OTBProjection|OTBTransform|OTBIOGDAL" --output-junit=report_ctest.xml + - export + - ctest --test-dir $OTB_BUILD -L $OTB_TEST_UNITS --output-junit=report_ctest.xml after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR -- GitLab From 1d1a2f859dd2396e8eec653884e727f89e727bd4 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 13:57:38 +0200 Subject: [PATCH 174/317] Remove empty export --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2ee1b07..0505a388 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -144,7 +144,6 @@ ctest: - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $CI_PROJECT_DIR - - export - ctest --test-dir $OTB_BUILD -L $OTB_TEST_UNITS --output-junit=report_ctest.xml after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR -- GitLab From b52be3046f153590d5e1bef3491ae650ec638b05 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 14:19:36 +0200 Subject: [PATCH 175/317] Use variables for nextcloud datasets --- .gitlab-ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0505a388..cf53825f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -168,11 +168,13 @@ crc_book: sr4rs: extends: .applications_test_base + variables: + DATASET_S2: https://nextcloud.inrae.fr/s/EZL2JN7SZyDK8Cf/download/sr4rs_sentinel2_bands4328_france2020_savedmodel.zip + DATASET_SR4RS: https://nextcloud.inrae.fr/s/kDms9JrRMQE2Q5z/download script: - - wget -qO sr4rs_sentinel2_bands4328_france2020_savedmodel.zip - https://nextcloud.inrae.fr/s/EZL2JN7SZyDK8Cf/download/sr4rs_sentinel2_bands4328_france2020_savedmodel.zip + - wget -qO sr4rs_sentinel2_bands4328_france2020_savedmodel.zip $DATASET_S2 - unzip -o sr4rs_sentinel2_bands4328_france2020_savedmodel.zip - - wget -qO sr4rs_data.zip https://nextcloud.inrae.fr/s/kDms9JrRMQE2Q5z/download + - wget -qO sr4rs_data.zip $DATASET_SR4RS - unzip -o sr4rs_data.zip - rm -rf sr4rs - git clone https://github.com/remicres/sr4rs.git @@ -181,10 +183,12 @@ sr4rs: decloud: extends: .applications_test_base + variables: + DATASET_DECLOUD: https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download script: - git clone https://github.com/CNES/decloud.git - pip install -r $PWD/decloud/docker/requirements.txt - - wget -q https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download -O file.zip && unzip file.zip + - wget -q $DATASET_DECLOUD -O file.zip && unzip file.zip - export DECLOUD_DATA_DIR="$PWD/decloud_data" - pytest decloud/tests/train_from_tfrecords_unittest.py -- GitLab From 765fe92be61ad928de3e3982ad050e3f359de823 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 14:19:52 +0200 Subject: [PATCH 176/317] Try find missing junit artifacts --- .gitlab-ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf53825f..b716067f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -143,10 +143,15 @@ ctest: - cd /src/otb/otb && git lfs fetch --all && git lfs pull - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - - cd $CI_PROJECT_DIR - - ctest --test-dir $OTB_BUILD -L $OTB_TEST_UNITS --output-junit=report_ctest.xml + - cd $OTB_BUILD + - ctest -L $OTB_TEST_UNITS --output-junit=report_ctest.xml + - ls after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR + - ls $ARTIFACT_TEST_DIR + artifacts: + reports: + junit: $ARTIFACT_TEST_DIR/report_ctest.xml .applications_test_base: extends: .tests_base -- GitLab From abe0a8d78d050599503204c397fba5f49dac801f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 14:32:56 +0200 Subject: [PATCH 177/317] Try find missing file --- .gitlab-ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b716067f..4ce946c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -138,6 +138,7 @@ ctest: extends: .tests_base stage: Test variables: + CTEST_OUTPUT_ON_FAILURE: 1 OTB_TEST_UNITS: "Tensorflow|PanSharpening|Projection|Transform|IOGDAL" script: - cd /src/otb/otb && git lfs fetch --all && git lfs pull @@ -145,13 +146,10 @@ ctest: - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD - ctest -L $OTB_TEST_UNITS --output-junit=report_ctest.xml - - ls + - export JUNIT_OUTPUT=$(find . -type f -name report_ctest.xml) + - cp -v $JUNIT_OUTPUT $CI_PROJECT_DIR after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR - - ls $ARTIFACT_TEST_DIR - artifacts: - reports: - junit: $ARTIFACT_TEST_DIR/report_ctest.xml .applications_test_base: extends: .tests_base -- GitLab From 4512a34627545a94ab6c19e33b190f54ddd94393 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 14:54:49 +0200 Subject: [PATCH 178/317] Try fix missing ctest junit output --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ce946c0..fa4b8f2b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -145,9 +145,7 @@ ctest: - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD - - ctest -L $OTB_TEST_UNITS --output-junit=report_ctest.xml - - export JUNIT_OUTPUT=$(find . -type f -name report_ctest.xml) - - cp -v $JUNIT_OUTPUT $CI_PROJECT_DIR + - ctest -L $OTB_TEST_UNITS --output-junit $CI_PROJECT_DIR/report_ctest.xml after_script: - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR -- GitLab From 445d3ebe40c3055ab233f9abd0d731404b1385e8 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 16:30:25 +0200 Subject: [PATCH 179/317] Move variables --- .gitlab-ci.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa4b8f2b..77ef38cb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,10 @@ variables: OTBTF_VERSION: 4.4.0 - OTB_BUILD: /src/otb/build/OTB/build # Local OTB build directory - OTBTF_SRC: /src/otbtf # Local OTBTF source directory - OTB_TEST_DIR: $OTB_BUILD/Testing/Temporary # OTB testing directory - ARTIFACT_TEST_DIR: $CI_PROJECT_DIR/testing - CRC_BOOK_TMP: /tmp/crc_book_tests_tmp - API_TEST_TMP: /tmp/api_tests_tmp + OTBTF_SRC: /src/otbtf # OTBTF source directory path in image DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 BUILDX_NO_DEFAULT_ATTESTATIONS: 1 BUILDX_BUILDER: container - DOCKER_DRIVER: overlay2 CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME @@ -125,6 +119,8 @@ pages: .tests_base: tags: [ godzilla ] + variables: + ARTIFACT_TEST_DIR: $CI_PROJECT_DIR/testing artifacts: reports: junit: report_*.xml @@ -140,6 +136,7 @@ ctest: variables: CTEST_OUTPUT_ON_FAILURE: 1 OTB_TEST_UNITS: "Tensorflow|PanSharpening|Projection|Transform|IOGDAL" + OTB_BUILD: /src/otb/build/OTB/build script: - cd /src/otb/otb && git lfs fetch --all && git lfs pull - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data @@ -147,7 +144,7 @@ ctest: - cd $OTB_BUILD - ctest -L $OTB_TEST_UNITS --output-junit $CI_PROJECT_DIR/report_ctest.xml after_script: - - cp -r $OTB_TEST_DIR $ARTIFACT_TEST_DIR + - cp -r $OTB_BUILD/Testing/Temporary $ARTIFACT_TEST_DIR .applications_test_base: extends: .tests_base @@ -161,6 +158,8 @@ ctest: crc_book: extends: .applications_test_base + variables: + CRC_BOOK_TMP: /tmp/crc_book_tests_tmp script: - mkdir -p $CRC_BOOK_TMP - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=report_tutorial.xml test/tutorial_unittest.py @@ -195,6 +194,8 @@ decloud: otbtf_api: extends: .applications_test_base + variables: + API_TEST_TMP: /tmp/api_tests_tmp script: - mkdir $API_TEST_TMP - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py -- GitLab From 4ed119ff10a92d4aa7671c4a8e40f5da7e66a25c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 16:33:16 +0200 Subject: [PATCH 180/317] Update tests for keras 3 --- .../examples/tensorflow_v2x/deterministic/l2_norm.py | 11 ++++++----- .../tensorflow_v2x/deterministic/scalar_prod.py | 12 ++++++------ otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 2 +- otbtf/ops.py | 5 +++-- test/models/model5.py | 2 +- test/nodata_test.py | 4 ++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py b/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py index b23d86cb..59e2b0a4 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py @@ -14,14 +14,15 @@ otbcli_TensorflowModelServe \ ``` """ -import tensorflow as tf +import keras + # Input -x = tf.keras.Input(shape=[None, None, None], name="x") # [1, h, w, N] +x = keras.Input(shape=[None, None, None], name="x") # [1, h, w, N] # Compute norm on the last axis -y = tf.norm(x, axis=-1) +y = keras.ops.norm(x, axis=-1) # Create model -model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}) -model.save("l2_norm_savedmodel") +model = keras.Model(inputs={"x": x}, outputs={"y": y}) +model.export("l2_norm_savedmodel") diff --git a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py index 57127c5e..419afe2e 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py @@ -16,15 +16,15 @@ OTB_TF_NSOURCES=2 otbcli_TensorflowModelServe \ ``` """ -import tensorflow as tf +import keras # Input -x1 = tf.keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] -x2 = tf.keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] +x1 = keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] +x2 = keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] # Compute scalar product -y = tf.reduce_sum(tf.multiply(x1, x2), axis=-1) +y = keras.ops.reduce_sum(tf.keras.ops.multiply(x1, x2), axis=-1) # Create model -model = tf.keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) -model.save("scalar_product_savedmodel") +model = keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) +model.export("scalar_product_savedmodel") diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index fcd14a20..c1dcb53c 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -215,4 +215,4 @@ def train(params, ds_train, ds_valid, ds_test): model.evaluate(ds_test, batch_size=params.batch_size) # Save trained model as SavedModel - model.save(params.model_dir) + model.export(params.model_dir) diff --git a/otbtf/ops.py b/otbtf/ops.py index ef5c52b9..139b1064 100644 --- a/otbtf/ops.py +++ b/otbtf/ops.py @@ -26,6 +26,7 @@ and train deep nets. """ from typing import List, Tuple, Any import tensorflow as tf +import keras Tensor = Any @@ -44,5 +45,5 @@ def one_hot(labels: Tensor, nb_classes: int): one-hot encoded vector (shape [x, y, nb_classes]) """ - labels_xy = tf.squeeze(tf.cast(labels, tf.int32), axis=-1) # shape [x, y] - return tf.one_hot(labels_xy, depth=nb_classes) # shape [x, y, nb_classes] + labels_xy = keras.ops.squeeze(keras.ops.cast(labels, tf.int32), axis=-1) # shape [x, y] + return keras.ops.one_hot(labels_xy, depth=nb_classes) # shape [x, y, nb_classes] diff --git a/test/models/model5.py b/test/models/model5.py index cc17d52e..35546492 100644 --- a/test/models/model5.py +++ b/test/models/model5.py @@ -21,5 +21,5 @@ y4 = tf.reshape(x, shape=(b, h, w, 1)) # [b, h, w, 1] # Create model model = tf.keras.Model(inputs={"x": x}, outputs={"y1": y1, "y2": y2, "y3": y3, "y4": y4}) -model.save("model5") +model.export("model5") diff --git a/test/nodata_test.py b/test/nodata_test.py index c3892153..55138d11 100644 --- a/test/nodata_test.py +++ b/test/nodata_test.py @@ -29,9 +29,9 @@ class NodataInferenceTest(unittest.TestCase): # Create model x = tf.keras.Input(shape=[None, None, None], name="x") - y = tf.norm(x, axis=-1) + y = tf.keras.ops.norm(x, axis=-1) model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}) - model.save(sm_dir) + model.export(sm_dir) # Input image: f(x, y) = x * y if x > y else 0 bmx = otbApplication.Registry.CreateApplication("BandMathX") -- GitLab From 0eed9596717a1761fc52ce5d6e8fd42fedc59bf4 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 16:55:55 +0200 Subject: [PATCH 181/317] Try fix tests with keras 3 --- .../tensorflow_v2x/fcnn/fcnn_model.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index c1dcb53c..a51ccbef 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -4,6 +4,7 @@ Implementation of a small U-Net like model import logging import tensorflow as tf +import keras from otbtf.model import ModelBase @@ -51,7 +52,7 @@ class FCNNModel(ModelBase): Returns: dict of normalized inputs, ready to be used from `get_outputs()` """ - return {INPUT_NAME: tf.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} + return {INPUT_NAME: keras.ops.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} def get_outputs(self, normalized_inputs: dict) -> dict: """ @@ -71,7 +72,7 @@ class FCNNModel(ModelBase): norm_inp = normalized_inputs[INPUT_NAME] def _conv(inp, depth, name): - conv_op = tf.keras.layers.Conv2D( + conv_op = keras.layers.Conv2D( filters=depth, kernel_size=3, strides=2, @@ -82,7 +83,7 @@ class FCNNModel(ModelBase): return conv_op(inp) def _tconv(inp, depth, name, activation="relu"): - tconv_op = tf.keras.layers.Conv2DTranspose( + tconv_op = keras.layers.Conv2DTranspose( filters=depth, kernel_size=3, strides=2, @@ -110,7 +111,7 @@ class FCNNModel(ModelBase): # command. # # Do not confuse **the name of the output layers** (i.e. the "name" - # property of the tf.keras.layer that is used to generate an output + # property of the keras.layer that is used to generate an output # tensor) and **the key of the output tensor**, in the dict returned # from `MyModel.get_output()`. They are two identifiers with a # different purpose: @@ -120,7 +121,7 @@ class FCNNModel(ModelBase): # fit the targets to model outputs during training process, but it # can also be used to access the tensors as tf/keras objects, for # instance to display previews images in TensorBoard. - softmax_op = tf.keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) + softmax_op = keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) predictions = softmax_op(out_tconv4) # note that we could also add additional outputs, for instance the @@ -158,8 +159,8 @@ def dataset_preprocessing_fn(examples: dict): """ return { INPUT_NAME: examples["input_xs_patches"], - TARGET_NAME: tf.one_hot( - tf.squeeze(tf.cast(examples["labels_patches"], tf.int32), axis=-1), + TARGET_NAME: keras.ops.one_hot( + keras.ops.squeeze(keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1), depth=N_CLASSES ) } @@ -191,15 +192,15 @@ def train(params, ds_train, ds_valid, ds_test): # useless outputs (e.g. metrics computed over extra outputs). model.compile( loss={ - TARGET_NAME: tf.keras.losses.CategoricalCrossentropy() + TARGET_NAME: keras.losses.CategoricalCrossentropy() }, - optimizer=tf.keras.optimizers.Adam( + optimizer=keras.optimizers.Adam( learning_rate=params.learning_rate ), metrics={ TARGET_NAME: [ - tf.keras.metrics.Precision(class_id=1), - tf.keras.metrics.Recall(class_id=1) + keras.metrics.Precision(class_id=1), + keras.metrics.Recall(class_id=1) ] } ) -- GitLab From 510fc53484bc206a82f84d9190ccaa51dd092cc5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 17:35:38 +0200 Subject: [PATCH 182/317] Use keras directly instead of tf.keras + fix keras.ops.one_hot + autoformat --- .../deterministic/scalar_prod.py | 3 +- .../tensorflow_v2x/fcnn/fcnn_model.py | 29 +++++++++---------- otbtf/layers.py | 11 +++---- otbtf/model.py | 11 +++---- otbtf/ops.py | 6 ++-- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py index 419afe2e..1d5be347 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py @@ -16,6 +16,7 @@ OTB_TF_NSOURCES=2 otbcli_TensorflowModelServe \ ``` """ + import keras # Input @@ -23,7 +24,7 @@ x1 = keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] x2 = keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] # Compute scalar product -y = keras.ops.reduce_sum(tf.keras.ops.multiply(x1, x2), axis=-1) +y = keras.ops.reduce_sum(keras.ops.multiply(x1, x2), axis=-1) # Create model model = keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index a51ccbef..48fc9284 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -1,6 +1,7 @@ """ Implementation of a small U-Net like model """ + import logging import tensorflow as tf @@ -9,9 +10,9 @@ import keras from otbtf.model import ModelBase logging.basicConfig( - format='%(asctime)s %(levelname)-8s %(message)s', + format="%(asctime)s %(levelname)-8s %(message)s", level=logging.INFO, - datefmt='%Y-%m-%d %H:%M:%S' + datefmt="%Y-%m-%d %H:%M:%S", ) # Number of classes estimated by the model @@ -78,7 +79,7 @@ class FCNNModel(ModelBase): strides=2, activation="relu", padding="same", - name=name + name=name, ) return conv_op(inp) @@ -89,7 +90,7 @@ class FCNNModel(ModelBase): strides=2, activation=activation, padding="same", - name=name + name=name, ) return tconv_op(inp) @@ -160,9 +161,11 @@ def dataset_preprocessing_fn(examples: dict): return { INPUT_NAME: examples["input_xs_patches"], TARGET_NAME: keras.ops.one_hot( - keras.ops.squeeze(keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1), - depth=N_CLASSES - ) + keras.ops.squeeze( + keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1 + ), + depth=N_CLASSES, + ), } @@ -191,18 +194,14 @@ def train(params, ds_train, ds_valid, ds_test): # This ensures a better optimization control, and also avoids lots of # useless outputs (e.g. metrics computed over extra outputs). model.compile( - loss={ - TARGET_NAME: keras.losses.CategoricalCrossentropy() - }, - optimizer=keras.optimizers.Adam( - learning_rate=params.learning_rate - ), + loss={TARGET_NAME: keras.losses.CategoricalCrossentropy()}, + optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ TARGET_NAME: [ keras.metrics.Precision(class_id=1), - keras.metrics.Recall(class_id=1) + keras.metrics.Recall(class_id=1), ] - } + }, ) # Summarize the model (in CLI) diff --git a/otbtf/layers.py b/otbtf/layers.py index ef65ec1c..028ba9a1 100644 --- a/otbtf/layers.py +++ b/otbtf/layers.py @@ -25,13 +25,14 @@ The utils module provides some useful keras layers to build deep nets. """ from typing import List, Tuple, Any import tensorflow as tf +import keras Tensor = Any Scalars = List[float] | Tuple[float] -class DilatedMask(tf.keras.layers.Layer): +class DilatedMask(keras.layers.Layer): """Layer to dilate a binary mask.""" def __init__(self, nodata_value: float, radius: int, name: str = None): """ @@ -70,7 +71,7 @@ class DilatedMask(tf.keras.layers.Layer): return tf.cast(conv2d_out, tf.uint8) -class ApplyMask(tf.keras.layers.Layer): +class ApplyMask(keras.layers.Layer): """Layer to apply a binary mask to one input.""" def __init__(self, out_nodata: float, name: str = None): """ @@ -95,7 +96,7 @@ class ApplyMask(tf.keras.layers.Layer): return tf.where(mask == 1, float(self.out_nodata), inp) -class ScalarsTile(tf.keras.layers.Layer): +class ScalarsTile(keras.layers.Layer): """ Layer to duplicate some scalars in a whole array. Simple example with only one scalar = 0.152: @@ -127,7 +128,7 @@ class ScalarsTile(tf.keras.layers.Layer): return tf.tile(inp, [1, tf.shape(ref)[1], tf.shape(ref)[2], 1]) -class Argmax(tf.keras.layers.Layer): +class Argmax(keras.layers.Layer): """ Layer to compute the argmax of a tensor. @@ -165,7 +166,7 @@ class Argmax(tf.keras.layers.Layer): return argmax -class Max(tf.keras.layers.Layer): +class Max(keras.layers.Layer): """ Layer to compute the max of a tensor. diff --git a/otbtf/model.py b/otbtf/model.py index 9958510b..99426a6c 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -27,6 +27,7 @@ from typing import List, Dict, Any import abc import logging import tensorflow as tf +import keras Tensor = Any TensorsDict = Dict[str, Tensor] @@ -116,7 +117,7 @@ class ModelBase(abc.ABC): if len(new_shape) > 2: new_shape[0] = None new_shape[1] = None - placeholder = tf.keras.Input(shape=new_shape, name=key) + placeholder = keras.Input(shape=new_shape, name=key) logging.info("New shape for input %s: %s", key, new_shape) model_inputs.update({key: placeholder}) return model_inputs @@ -192,14 +193,14 @@ class ModelBase(abc.ABC): out_key, crop, extra_output_name ) cropped = out_tensor[:, crop:-crop, crop:-crop, :] - identity = tf.keras.layers.Activation( + identity = keras.layers.Activation( 'linear', name=extra_output_name ) extra_outputs[extra_output_key] = identity(cropped) return extra_outputs - def create_network(self) -> tf.keras.Model: + def create_network(self) -> keras.Model: """ This method returns the Keras model. This needs to be called **inside** the strategy.scope(). Can be reimplemented depending on the @@ -230,7 +231,7 @@ class ModelBase(abc.ABC): outputs.update(postprocessed_outputs) # Return the keras model - return tf.keras.Model( + return keras.Model( inputs=inputs, outputs=outputs, name=self.__class__.__name__ @@ -265,7 +266,7 @@ class ModelBase(abc.ABC): # When multiworker strategy, only plot if the worker is chief if not strategy or _is_chief(strategy): - tf.keras.utils.plot_model( + keras.utils.plot_model( self.model, output_path, show_shapes=show_shapes ) diff --git a/otbtf/ops.py b/otbtf/ops.py index 139b1064..5a473562 100644 --- a/otbtf/ops.py +++ b/otbtf/ops.py @@ -45,5 +45,7 @@ def one_hot(labels: Tensor, nb_classes: int): one-hot encoded vector (shape [x, y, nb_classes]) """ - labels_xy = keras.ops.squeeze(keras.ops.cast(labels, tf.int32), axis=-1) # shape [x, y] - return keras.ops.one_hot(labels_xy, depth=nb_classes) # shape [x, y, nb_classes] + # shape [x, y] + labels_xy = keras.ops.squeeze(keras.ops.cast(labels, tf.int32), axis=-1) + # shape [x, y, nb_classes] + return keras.ops.one_hot(labels_xy, nb_classes) -- GitLab From 020d3bac968596d3467bd7e96ea4f5e4a2126165 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 18:07:29 +0200 Subject: [PATCH 183/317] Fix bad argument depth in keras.ops.one_hot --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 48fc9284..53024015 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -164,7 +164,7 @@ def dataset_preprocessing_fn(examples: dict): keras.ops.squeeze( keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1 ), - depth=N_CLASSES, + N_CLASSES, ), } -- GitLab From b98f8d5912239ce24c15d8c60e0bb8a9a5de66aa Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 19:05:38 +0200 Subject: [PATCH 184/317] Fix docs job --- .gitlab-ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cffd611e..38e69dd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -98,12 +98,12 @@ cppcheck: script: - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . -pages: +build_docs: tags: [ stable ] image: python:3.10-slim stage: Documentation variables: - PTH: "public_test" + PTH: public_test rules: - changes: - doc/**/* @@ -112,14 +112,15 @@ pages: - .readthedocs.yaml - if: $CI_COMMIT_REF_NAME == /master/ variables: - PTH: "public" + PTH: public before_script: - pip install -r doc/doc_requirements.txt script: - mkdocs build --site-dir $PTH artifacts: paths: - - $PTH + - public + - public_test .tests_base: tags: [ godzilla ] -- GitLab From 877e104b35fa5d6d6a2e03b94975c0a23e9575e2 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 19:30:11 +0200 Subject: [PATCH 185/317] Fix for keras 3 (AttributeError: 'KerasHistory' object has no attribute 'layer') --- otbtf/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otbtf/model.py b/otbtf/model.py index 99426a6c..83013fff 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -186,7 +186,7 @@ class ModelBase(abc.ABC): for crop in self.inference_cropping: extra_output_key = cropped_tensor_name(out_key, crop) extra_output_name = cropped_tensor_name( - out_tensor._keras_history.layer.name, crop + out_tensor._keras_history.operation.name, crop ) logging.info( "Adding extra output for tensor %s with crop %s (%s)", -- GitLab From e8ec6637f427c43467d52e7acf8eec004ae955e1 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 19:51:21 +0200 Subject: [PATCH 186/317] Use godzilla runner everywhere --- .gitlab-ci.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 38e69dd6..2fc277b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,6 +24,7 @@ workflow: when: never default: + tags: [ godzilla ] interruptible: true image: name: $BRANCH_IMAGE @@ -35,12 +36,10 @@ stages: - Documentation - Test - Applications Test - - Update dev image - Ship - - Export TF wheels + - Export TensorFlow .docker_build_base: - tags: [ godzilla ] image: docker:latest services: - name: docker:dind @@ -60,7 +59,6 @@ docker_image: "." .static_analysis_base: - tags: [ stable ] stage: Static Analysis allow_failure: true @@ -123,7 +121,6 @@ build_docs: - public_test .tests_base: - tags: [ godzilla ] rules: - changes: - app/**/* @@ -251,8 +248,8 @@ nodata: .ship_base: extends: .docker_build_base stage: Ship - only: - - tags + rules: + - if: $CI_COMMIT_TAG deploy_cpu: extends: .ship_base @@ -314,7 +311,7 @@ deploy_gpu: export_tf_wheels: extends: .docker_build_base - stage: Export TF wheels + stage: Export TensorFlow rules: - when: manual artifacts: -- GitLab From 04d03f3c3d4d1d7b59a056ce679739e2dc6a0460 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 20:16:53 +0200 Subject: [PATCH 187/317] Fix tf metrics for keras 3 in fcnn model example --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 53024015..7327f69f 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -194,14 +194,12 @@ def train(params, ds_train, ds_valid, ds_test): # This ensures a better optimization control, and also avoids lots of # useless outputs (e.g. metrics computed over extra outputs). model.compile( - loss={TARGET_NAME: keras.losses.CategoricalCrossentropy()}, + loss=keras.losses.CategoricalCrossentropy(), optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), - metrics={ - TARGET_NAME: [ - keras.metrics.Precision(class_id=1), - keras.metrics.Recall(class_id=1), - ] - }, + metrics=[ + keras.metrics.Precision(class_id=1), + keras.metrics.Recall(class_id=1), + ], ) # Summarize the model (in CLI) -- GitLab From a14608044110947bea4ad443ac907c0d1874027e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 21:12:56 +0200 Subject: [PATCH 188/317] Reverse changes to keras code for another MR --- otbtf/examples/tensorflow_v1x/__init__.py | 10 ++-- .../tensorflow_v2x/deterministic/l2_norm.py | 11 ++-- .../deterministic/scalar_prod.py | 13 +++-- .../tensorflow_v2x/fcnn/fcnn_model.py | 50 ++++++++++--------- otbtf/layers.py | 11 ++-- otbtf/model.py | 13 +++-- otbtf/ops.py | 7 +-- 7 files changed, 55 insertions(+), 60 deletions(-) diff --git a/otbtf/examples/tensorflow_v1x/__init__.py b/otbtf/examples/tensorflow_v1x/__init__.py index 796e4cbd..c77256a4 100644 --- a/otbtf/examples/tensorflow_v1x/__init__.py +++ b/otbtf/examples/tensorflow_v1x/__init__.py @@ -38,7 +38,7 @@ Predicted label is a single pixel, for an input patch of size 16x16 (for an inpu The learning rate of the training operator can be adjusted using the *lr* placeholder. The following figure summarizes this architecture. -<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_cnn.png" /> +<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_cnn.png" /> ## Generate the model @@ -143,7 +143,7 @@ otbcli_TensorflowModelServe \\ The `create_savedmodel_simple_fcn.py` script enables you to create a fully convolutional model which does not use any stride. -<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_fcnn.png" /> +<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_fcnn.png" /> Thanks to that, once trained this model can be applied on the image to produce a landcover map at the same resolution as the input image, in a fully @@ -208,7 +208,7 @@ available parameters. Let's train the M3 model from time series (TS) and Very High Resolution Satellite (VHRS) patches images. -<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/model_training.png" /> +<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/model_training.png" /> First, tell OTBTF that we want two sources: one for time series + one for VHR image @@ -255,7 +255,7 @@ otbcli_TensorflowModelTrain \\ Let's produce a land cover map using the M3 model from time series (TS) and Very High Resolution Satellite image (VHRS) -<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/classif_map.png" /> +<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/classif_map.png" /> Since we provide time series as the reference source (*source1*), the output classes are estimated at the same resolution. This model can be run in @@ -363,7 +363,7 @@ See: Gaetano, R., Ienco, D., Ose, K., & Cresson, R. (2018). *A two-branch CNN architecture for land cover classification of PAN and MS imagery*. Remote Sensing, 10(11), 1746. -<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_pxs_fcn.png" /> +<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_pxs_fcn.png" /> Use `create_savedmodel_pxs_fcn.py` to generate this model. diff --git a/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py b/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py index 59e2b0a4..b23d86cb 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py @@ -14,15 +14,14 @@ otbcli_TensorflowModelServe \ ``` """ -import keras - +import tensorflow as tf # Input -x = keras.Input(shape=[None, None, None], name="x") # [1, h, w, N] +x = tf.keras.Input(shape=[None, None, None], name="x") # [1, h, w, N] # Compute norm on the last axis -y = keras.ops.norm(x, axis=-1) +y = tf.norm(x, axis=-1) # Create model -model = keras.Model(inputs={"x": x}, outputs={"y": y}) -model.export("l2_norm_savedmodel") +model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}) +model.save("l2_norm_savedmodel") diff --git a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py index 1d5be347..57127c5e 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py @@ -16,16 +16,15 @@ OTB_TF_NSOURCES=2 otbcli_TensorflowModelServe \ ``` """ - -import keras +import tensorflow as tf # Input -x1 = keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] -x2 = keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] +x1 = tf.keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] +x2 = tf.keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] # Compute scalar product -y = keras.ops.reduce_sum(keras.ops.multiply(x1, x2), axis=-1) +y = tf.reduce_sum(tf.multiply(x1, x2), axis=-1) # Create model -model = keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) -model.export("scalar_product_savedmodel") +model = tf.keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) +model.save("scalar_product_savedmodel") diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 7327f69f..fcd14a20 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -1,18 +1,16 @@ """ Implementation of a small U-Net like model """ - import logging import tensorflow as tf -import keras from otbtf.model import ModelBase logging.basicConfig( - format="%(asctime)s %(levelname)-8s %(message)s", + format='%(asctime)s %(levelname)-8s %(message)s', level=logging.INFO, - datefmt="%Y-%m-%d %H:%M:%S", + datefmt='%Y-%m-%d %H:%M:%S' ) # Number of classes estimated by the model @@ -53,7 +51,7 @@ class FCNNModel(ModelBase): Returns: dict of normalized inputs, ready to be used from `get_outputs()` """ - return {INPUT_NAME: keras.ops.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} + return {INPUT_NAME: tf.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} def get_outputs(self, normalized_inputs: dict) -> dict: """ @@ -73,24 +71,24 @@ class FCNNModel(ModelBase): norm_inp = normalized_inputs[INPUT_NAME] def _conv(inp, depth, name): - conv_op = keras.layers.Conv2D( + conv_op = tf.keras.layers.Conv2D( filters=depth, kernel_size=3, strides=2, activation="relu", padding="same", - name=name, + name=name ) return conv_op(inp) def _tconv(inp, depth, name, activation="relu"): - tconv_op = keras.layers.Conv2DTranspose( + tconv_op = tf.keras.layers.Conv2DTranspose( filters=depth, kernel_size=3, strides=2, activation=activation, padding="same", - name=name, + name=name ) return tconv_op(inp) @@ -112,7 +110,7 @@ class FCNNModel(ModelBase): # command. # # Do not confuse **the name of the output layers** (i.e. the "name" - # property of the keras.layer that is used to generate an output + # property of the tf.keras.layer that is used to generate an output # tensor) and **the key of the output tensor**, in the dict returned # from `MyModel.get_output()`. They are two identifiers with a # different purpose: @@ -122,7 +120,7 @@ class FCNNModel(ModelBase): # fit the targets to model outputs during training process, but it # can also be used to access the tensors as tf/keras objects, for # instance to display previews images in TensorBoard. - softmax_op = keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) + softmax_op = tf.keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) predictions = softmax_op(out_tconv4) # note that we could also add additional outputs, for instance the @@ -160,12 +158,10 @@ def dataset_preprocessing_fn(examples: dict): """ return { INPUT_NAME: examples["input_xs_patches"], - TARGET_NAME: keras.ops.one_hot( - keras.ops.squeeze( - keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1 - ), - N_CLASSES, - ), + TARGET_NAME: tf.one_hot( + tf.squeeze(tf.cast(examples["labels_patches"], tf.int32), axis=-1), + depth=N_CLASSES + ) } @@ -194,12 +190,18 @@ def train(params, ds_train, ds_valid, ds_test): # This ensures a better optimization control, and also avoids lots of # useless outputs (e.g. metrics computed over extra outputs). model.compile( - loss=keras.losses.CategoricalCrossentropy(), - optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), - metrics=[ - keras.metrics.Precision(class_id=1), - keras.metrics.Recall(class_id=1), - ], + loss={ + TARGET_NAME: tf.keras.losses.CategoricalCrossentropy() + }, + optimizer=tf.keras.optimizers.Adam( + learning_rate=params.learning_rate + ), + metrics={ + TARGET_NAME: [ + tf.keras.metrics.Precision(class_id=1), + tf.keras.metrics.Recall(class_id=1) + ] + } ) # Summarize the model (in CLI) @@ -213,4 +215,4 @@ def train(params, ds_train, ds_valid, ds_test): model.evaluate(ds_test, batch_size=params.batch_size) # Save trained model as SavedModel - model.export(params.model_dir) + model.save(params.model_dir) diff --git a/otbtf/layers.py b/otbtf/layers.py index 028ba9a1..ef65ec1c 100644 --- a/otbtf/layers.py +++ b/otbtf/layers.py @@ -25,14 +25,13 @@ The utils module provides some useful keras layers to build deep nets. """ from typing import List, Tuple, Any import tensorflow as tf -import keras Tensor = Any Scalars = List[float] | Tuple[float] -class DilatedMask(keras.layers.Layer): +class DilatedMask(tf.keras.layers.Layer): """Layer to dilate a binary mask.""" def __init__(self, nodata_value: float, radius: int, name: str = None): """ @@ -71,7 +70,7 @@ class DilatedMask(keras.layers.Layer): return tf.cast(conv2d_out, tf.uint8) -class ApplyMask(keras.layers.Layer): +class ApplyMask(tf.keras.layers.Layer): """Layer to apply a binary mask to one input.""" def __init__(self, out_nodata: float, name: str = None): """ @@ -96,7 +95,7 @@ class ApplyMask(keras.layers.Layer): return tf.where(mask == 1, float(self.out_nodata), inp) -class ScalarsTile(keras.layers.Layer): +class ScalarsTile(tf.keras.layers.Layer): """ Layer to duplicate some scalars in a whole array. Simple example with only one scalar = 0.152: @@ -128,7 +127,7 @@ class ScalarsTile(keras.layers.Layer): return tf.tile(inp, [1, tf.shape(ref)[1], tf.shape(ref)[2], 1]) -class Argmax(keras.layers.Layer): +class Argmax(tf.keras.layers.Layer): """ Layer to compute the argmax of a tensor. @@ -166,7 +165,7 @@ class Argmax(keras.layers.Layer): return argmax -class Max(keras.layers.Layer): +class Max(tf.keras.layers.Layer): """ Layer to compute the max of a tensor. diff --git a/otbtf/model.py b/otbtf/model.py index 83013fff..9958510b 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -27,7 +27,6 @@ from typing import List, Dict, Any import abc import logging import tensorflow as tf -import keras Tensor = Any TensorsDict = Dict[str, Tensor] @@ -117,7 +116,7 @@ class ModelBase(abc.ABC): if len(new_shape) > 2: new_shape[0] = None new_shape[1] = None - placeholder = keras.Input(shape=new_shape, name=key) + placeholder = tf.keras.Input(shape=new_shape, name=key) logging.info("New shape for input %s: %s", key, new_shape) model_inputs.update({key: placeholder}) return model_inputs @@ -186,21 +185,21 @@ class ModelBase(abc.ABC): for crop in self.inference_cropping: extra_output_key = cropped_tensor_name(out_key, crop) extra_output_name = cropped_tensor_name( - out_tensor._keras_history.operation.name, crop + out_tensor._keras_history.layer.name, crop ) logging.info( "Adding extra output for tensor %s with crop %s (%s)", out_key, crop, extra_output_name ) cropped = out_tensor[:, crop:-crop, crop:-crop, :] - identity = keras.layers.Activation( + identity = tf.keras.layers.Activation( 'linear', name=extra_output_name ) extra_outputs[extra_output_key] = identity(cropped) return extra_outputs - def create_network(self) -> keras.Model: + def create_network(self) -> tf.keras.Model: """ This method returns the Keras model. This needs to be called **inside** the strategy.scope(). Can be reimplemented depending on the @@ -231,7 +230,7 @@ class ModelBase(abc.ABC): outputs.update(postprocessed_outputs) # Return the keras model - return keras.Model( + return tf.keras.Model( inputs=inputs, outputs=outputs, name=self.__class__.__name__ @@ -266,7 +265,7 @@ class ModelBase(abc.ABC): # When multiworker strategy, only plot if the worker is chief if not strategy or _is_chief(strategy): - keras.utils.plot_model( + tf.keras.utils.plot_model( self.model, output_path, show_shapes=show_shapes ) diff --git a/otbtf/ops.py b/otbtf/ops.py index 5a473562..ef5c52b9 100644 --- a/otbtf/ops.py +++ b/otbtf/ops.py @@ -26,7 +26,6 @@ and train deep nets. """ from typing import List, Tuple, Any import tensorflow as tf -import keras Tensor = Any @@ -45,7 +44,5 @@ def one_hot(labels: Tensor, nb_classes: int): one-hot encoded vector (shape [x, y, nb_classes]) """ - # shape [x, y] - labels_xy = keras.ops.squeeze(keras.ops.cast(labels, tf.int32), axis=-1) - # shape [x, y, nb_classes] - return keras.ops.one_hot(labels_xy, nb_classes) + labels_xy = tf.squeeze(tf.cast(labels, tf.int32), axis=-1) # shape [x, y] + return tf.one_hot(labels_xy, depth=nb_classes) # shape [x, y, nb_classes] -- GitLab From a740c7f62a6ac90c7fef1b0d47f0caef5b57e72e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 21:13:33 +0200 Subject: [PATCH 189/317] Revert keras 3 related changes --- test/models/model5.py | 2 +- test/nodata_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/models/model5.py b/test/models/model5.py index 35546492..cc17d52e 100644 --- a/test/models/model5.py +++ b/test/models/model5.py @@ -21,5 +21,5 @@ y4 = tf.reshape(x, shape=(b, h, w, 1)) # [b, h, w, 1] # Create model model = tf.keras.Model(inputs={"x": x}, outputs={"y1": y1, "y2": y2, "y3": y3, "y4": y4}) -model.export("model5") +model.save("model5") diff --git a/test/nodata_test.py b/test/nodata_test.py index 55138d11..c3892153 100644 --- a/test/nodata_test.py +++ b/test/nodata_test.py @@ -29,9 +29,9 @@ class NodataInferenceTest(unittest.TestCase): # Create model x = tf.keras.Input(shape=[None, None, None], name="x") - y = tf.keras.ops.norm(x, axis=-1) + y = tf.norm(x, axis=-1) model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}) - model.export(sm_dir) + model.save(sm_dir) # Input image: f(x, y) = x * y if x > y else 0 bmx = otbApplication.Registry.CreateApplication("BandMathX") -- GitLab From 33231b75f9f55bf1b2213e69da9615a8db082103 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 19 Oct 2024 21:16:55 +0200 Subject: [PATCH 190/317] Update links to forgemia url --- otbtf/examples/tensorflow_v1x/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/otbtf/examples/tensorflow_v1x/__init__.py b/otbtf/examples/tensorflow_v1x/__init__.py index c77256a4..796e4cbd 100644 --- a/otbtf/examples/tensorflow_v1x/__init__.py +++ b/otbtf/examples/tensorflow_v1x/__init__.py @@ -38,7 +38,7 @@ Predicted label is a single pixel, for an input patch of size 16x16 (for an inpu The learning rate of the training operator can be adjusted using the *lr* placeholder. The following figure summarizes this architecture. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_cnn.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_cnn.png" /> ## Generate the model @@ -143,7 +143,7 @@ otbcli_TensorflowModelServe \\ The `create_savedmodel_simple_fcn.py` script enables you to create a fully convolutional model which does not use any stride. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_fcnn.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_fcnn.png" /> Thanks to that, once trained this model can be applied on the image to produce a landcover map at the same resolution as the input image, in a fully @@ -208,7 +208,7 @@ available parameters. Let's train the M3 model from time series (TS) and Very High Resolution Satellite (VHRS) patches images. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/model_training.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/model_training.png" /> First, tell OTBTF that we want two sources: one for time series + one for VHR image @@ -255,7 +255,7 @@ otbcli_TensorflowModelTrain \\ Let's produce a land cover map using the M3 model from time series (TS) and Very High Resolution Satellite image (VHRS) -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/classif_map.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/classif_map.png" /> Since we provide time series as the reference source (*source1*), the output classes are estimated at the same resolution. This model can be run in @@ -363,7 +363,7 @@ See: Gaetano, R., Ienco, D., Ose, K., & Cresson, R. (2018). *A two-branch CNN architecture for land cover classification of PAN and MS imagery*. Remote Sensing, 10(11), 1746. -<img src ="https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/savedmodel_simple_pxs_fcn.png" /> +<img src ="https://forgemia.inra.fr/orfeo-toolbox/otbtf/-/raw/develop/doc/images/savedmodel_simple_pxs_fcn.png" /> Use `create_savedmodel_pxs_fcn.py` to generate this model. -- GitLab From 2c79521f340b48ad906853ffa976cdfe9902c330 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 20 Oct 2024 15:15:49 +0200 Subject: [PATCH 191/317] Update code to keras 3 --- .../tensorflow_v2x/deterministic/l2_norm.py | 11 ++-- .../deterministic/scalar_prod.py | 13 ++--- .../tensorflow_v2x/fcnn/fcnn_model.py | 50 +++++++++---------- otbtf/layers.py | 11 ++-- otbtf/model.py | 13 ++--- otbtf/ops.py | 7 ++- 6 files changed, 55 insertions(+), 50 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py b/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py index b23d86cb..59e2b0a4 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/l2_norm.py @@ -14,14 +14,15 @@ otbcli_TensorflowModelServe \ ``` """ -import tensorflow as tf +import keras + # Input -x = tf.keras.Input(shape=[None, None, None], name="x") # [1, h, w, N] +x = keras.Input(shape=[None, None, None], name="x") # [1, h, w, N] # Compute norm on the last axis -y = tf.norm(x, axis=-1) +y = keras.ops.norm(x, axis=-1) # Create model -model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}) -model.save("l2_norm_savedmodel") +model = keras.Model(inputs={"x": x}, outputs={"y": y}) +model.export("l2_norm_savedmodel") diff --git a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py index 57127c5e..1d5be347 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py @@ -16,15 +16,16 @@ OTB_TF_NSOURCES=2 otbcli_TensorflowModelServe \ ``` """ -import tensorflow as tf + +import keras # Input -x1 = tf.keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] -x2 = tf.keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] +x1 = keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] +x2 = keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] # Compute scalar product -y = tf.reduce_sum(tf.multiply(x1, x2), axis=-1) +y = keras.ops.reduce_sum(keras.ops.multiply(x1, x2), axis=-1) # Create model -model = tf.keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) -model.save("scalar_product_savedmodel") +model = keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) +model.export("scalar_product_savedmodel") diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index fcd14a20..7327f69f 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -1,16 +1,18 @@ """ Implementation of a small U-Net like model """ + import logging import tensorflow as tf +import keras from otbtf.model import ModelBase logging.basicConfig( - format='%(asctime)s %(levelname)-8s %(message)s', + format="%(asctime)s %(levelname)-8s %(message)s", level=logging.INFO, - datefmt='%Y-%m-%d %H:%M:%S' + datefmt="%Y-%m-%d %H:%M:%S", ) # Number of classes estimated by the model @@ -51,7 +53,7 @@ class FCNNModel(ModelBase): Returns: dict of normalized inputs, ready to be used from `get_outputs()` """ - return {INPUT_NAME: tf.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} + return {INPUT_NAME: keras.ops.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} def get_outputs(self, normalized_inputs: dict) -> dict: """ @@ -71,24 +73,24 @@ class FCNNModel(ModelBase): norm_inp = normalized_inputs[INPUT_NAME] def _conv(inp, depth, name): - conv_op = tf.keras.layers.Conv2D( + conv_op = keras.layers.Conv2D( filters=depth, kernel_size=3, strides=2, activation="relu", padding="same", - name=name + name=name, ) return conv_op(inp) def _tconv(inp, depth, name, activation="relu"): - tconv_op = tf.keras.layers.Conv2DTranspose( + tconv_op = keras.layers.Conv2DTranspose( filters=depth, kernel_size=3, strides=2, activation=activation, padding="same", - name=name + name=name, ) return tconv_op(inp) @@ -110,7 +112,7 @@ class FCNNModel(ModelBase): # command. # # Do not confuse **the name of the output layers** (i.e. the "name" - # property of the tf.keras.layer that is used to generate an output + # property of the keras.layer that is used to generate an output # tensor) and **the key of the output tensor**, in the dict returned # from `MyModel.get_output()`. They are two identifiers with a # different purpose: @@ -120,7 +122,7 @@ class FCNNModel(ModelBase): # fit the targets to model outputs during training process, but it # can also be used to access the tensors as tf/keras objects, for # instance to display previews images in TensorBoard. - softmax_op = tf.keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) + softmax_op = keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) predictions = softmax_op(out_tconv4) # note that we could also add additional outputs, for instance the @@ -158,10 +160,12 @@ def dataset_preprocessing_fn(examples: dict): """ return { INPUT_NAME: examples["input_xs_patches"], - TARGET_NAME: tf.one_hot( - tf.squeeze(tf.cast(examples["labels_patches"], tf.int32), axis=-1), - depth=N_CLASSES - ) + TARGET_NAME: keras.ops.one_hot( + keras.ops.squeeze( + keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1 + ), + N_CLASSES, + ), } @@ -190,18 +194,12 @@ def train(params, ds_train, ds_valid, ds_test): # This ensures a better optimization control, and also avoids lots of # useless outputs (e.g. metrics computed over extra outputs). model.compile( - loss={ - TARGET_NAME: tf.keras.losses.CategoricalCrossentropy() - }, - optimizer=tf.keras.optimizers.Adam( - learning_rate=params.learning_rate - ), - metrics={ - TARGET_NAME: [ - tf.keras.metrics.Precision(class_id=1), - tf.keras.metrics.Recall(class_id=1) - ] - } + loss=keras.losses.CategoricalCrossentropy(), + optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), + metrics=[ + keras.metrics.Precision(class_id=1), + keras.metrics.Recall(class_id=1), + ], ) # Summarize the model (in CLI) @@ -215,4 +213,4 @@ def train(params, ds_train, ds_valid, ds_test): model.evaluate(ds_test, batch_size=params.batch_size) # Save trained model as SavedModel - model.save(params.model_dir) + model.export(params.model_dir) diff --git a/otbtf/layers.py b/otbtf/layers.py index ef65ec1c..028ba9a1 100644 --- a/otbtf/layers.py +++ b/otbtf/layers.py @@ -25,13 +25,14 @@ The utils module provides some useful keras layers to build deep nets. """ from typing import List, Tuple, Any import tensorflow as tf +import keras Tensor = Any Scalars = List[float] | Tuple[float] -class DilatedMask(tf.keras.layers.Layer): +class DilatedMask(keras.layers.Layer): """Layer to dilate a binary mask.""" def __init__(self, nodata_value: float, radius: int, name: str = None): """ @@ -70,7 +71,7 @@ class DilatedMask(tf.keras.layers.Layer): return tf.cast(conv2d_out, tf.uint8) -class ApplyMask(tf.keras.layers.Layer): +class ApplyMask(keras.layers.Layer): """Layer to apply a binary mask to one input.""" def __init__(self, out_nodata: float, name: str = None): """ @@ -95,7 +96,7 @@ class ApplyMask(tf.keras.layers.Layer): return tf.where(mask == 1, float(self.out_nodata), inp) -class ScalarsTile(tf.keras.layers.Layer): +class ScalarsTile(keras.layers.Layer): """ Layer to duplicate some scalars in a whole array. Simple example with only one scalar = 0.152: @@ -127,7 +128,7 @@ class ScalarsTile(tf.keras.layers.Layer): return tf.tile(inp, [1, tf.shape(ref)[1], tf.shape(ref)[2], 1]) -class Argmax(tf.keras.layers.Layer): +class Argmax(keras.layers.Layer): """ Layer to compute the argmax of a tensor. @@ -165,7 +166,7 @@ class Argmax(tf.keras.layers.Layer): return argmax -class Max(tf.keras.layers.Layer): +class Max(keras.layers.Layer): """ Layer to compute the max of a tensor. diff --git a/otbtf/model.py b/otbtf/model.py index 9958510b..83013fff 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -27,6 +27,7 @@ from typing import List, Dict, Any import abc import logging import tensorflow as tf +import keras Tensor = Any TensorsDict = Dict[str, Tensor] @@ -116,7 +117,7 @@ class ModelBase(abc.ABC): if len(new_shape) > 2: new_shape[0] = None new_shape[1] = None - placeholder = tf.keras.Input(shape=new_shape, name=key) + placeholder = keras.Input(shape=new_shape, name=key) logging.info("New shape for input %s: %s", key, new_shape) model_inputs.update({key: placeholder}) return model_inputs @@ -185,21 +186,21 @@ class ModelBase(abc.ABC): for crop in self.inference_cropping: extra_output_key = cropped_tensor_name(out_key, crop) extra_output_name = cropped_tensor_name( - out_tensor._keras_history.layer.name, crop + out_tensor._keras_history.operation.name, crop ) logging.info( "Adding extra output for tensor %s with crop %s (%s)", out_key, crop, extra_output_name ) cropped = out_tensor[:, crop:-crop, crop:-crop, :] - identity = tf.keras.layers.Activation( + identity = keras.layers.Activation( 'linear', name=extra_output_name ) extra_outputs[extra_output_key] = identity(cropped) return extra_outputs - def create_network(self) -> tf.keras.Model: + def create_network(self) -> keras.Model: """ This method returns the Keras model. This needs to be called **inside** the strategy.scope(). Can be reimplemented depending on the @@ -230,7 +231,7 @@ class ModelBase(abc.ABC): outputs.update(postprocessed_outputs) # Return the keras model - return tf.keras.Model( + return keras.Model( inputs=inputs, outputs=outputs, name=self.__class__.__name__ @@ -265,7 +266,7 @@ class ModelBase(abc.ABC): # When multiworker strategy, only plot if the worker is chief if not strategy or _is_chief(strategy): - tf.keras.utils.plot_model( + keras.utils.plot_model( self.model, output_path, show_shapes=show_shapes ) diff --git a/otbtf/ops.py b/otbtf/ops.py index ef5c52b9..5a473562 100644 --- a/otbtf/ops.py +++ b/otbtf/ops.py @@ -26,6 +26,7 @@ and train deep nets. """ from typing import List, Tuple, Any import tensorflow as tf +import keras Tensor = Any @@ -44,5 +45,7 @@ def one_hot(labels: Tensor, nb_classes: int): one-hot encoded vector (shape [x, y, nb_classes]) """ - labels_xy = tf.squeeze(tf.cast(labels, tf.int32), axis=-1) # shape [x, y] - return tf.one_hot(labels_xy, depth=nb_classes) # shape [x, y, nb_classes] + # shape [x, y] + labels_xy = keras.ops.squeeze(keras.ops.cast(labels, tf.int32), axis=-1) + # shape [x, y, nb_classes] + return keras.ops.one_hot(labels_xy, nb_classes) -- GitLab From 259c8d67d6dcb9ddb44ff89b74d1b9cadb9962c1 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 20 Oct 2024 16:51:22 +0200 Subject: [PATCH 192/317] Better docker layers order + test bazel cache --- Dockerfile | 60 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48b31377..9523bfa9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,11 +23,23 @@ ENV LD_LIBRARY_PATH=/opt/otbtf/lib ARG CPU_RATIO=1 # ---------------------------------------------------------------------------- -### TensorFlow bazel build stage +### Builder stage: bazel clang tensorflow FROM base-stage AS tf-build WORKDIR /src/tf RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include +# Clang + LLVM +ARG LLVM=18 + +ADD https://apt.llvm.org/llvm.sh llvm.sh +RUN bash ./llvm.sh $LLVM +ENV CC=/usr/bin/clang-$LLVM +ENV CXX=/usr/bin/clang++-$LLVM +ENV BAZEL_COMPILER="/usr/bin/clang-$LLVM" +RUN apt-get update -y && apt-get upgrade -y \ + && apt-get install -y lld-$LLVM libomp-$LLVM-dev \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + ### Python venv and packages RUN virtualenv $VIRTUAL_ENV RUN pip install --no-cache-dir -U pip wheel @@ -35,16 +47,6 @@ RUN pip install --no-cache-dir -U pip wheel ARG NUMPY="1.26.4" RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests \ && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing - -# Clang + LLVM -ADD https://apt.llvm.org/llvm.sh llvm.sh -RUN bash ./llvm.sh 18 -ENV CC=/usr/bin/clang-18 -ENV CXX=/usr/bin/clang++-18 -ENV BAZEL_COMPILER=/usr/bin/clang-18 -RUN apt-get update -y && apt-get upgrade -y \ - && apt-get install -y lld-18 libomp-18-dev \ - && apt-get clean && rm -rf /var/lib/apt/lists/* # TF build arguments ARG TF=v2.18.0-rc2 @@ -88,7 +90,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- -### OTB cmake build stage +### Builder stage: cmake gcc otb FROM base-stage AS otb-build WORKDIR /src/otb @@ -136,7 +138,7 @@ COPY CMakeLists.txt otb-module.cmake ./ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ -# Rebuild OTB with OTBTF module +# Build OTBTF cpp ARG DEV_IMAGE=false RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf RUN cd /src/otb/build/OTB/build \ @@ -152,14 +154,8 @@ RUN cd /src/otb/build/OTB/build \ && ( $DEV_IMAGE || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* -# Install OTBTF python module -COPY otbtf ./otbtf -COPY tricks ./tricks -COPY README.md setup.py . -RUN pip install -e . - # ---------------------------------------------------------------------------- -# Final stage from a clean base +# Final stage: copy binaries from middle layers and install python module FROM base-stage AS final-stage LABEL maintainer="Remi Cresson <remi.cresson[at]inrae[dot]fr>" @@ -172,22 +168,28 @@ ENV PYTHONPATH="/opt/otbtf/lib/otb/python:/opt/otbtf/lib/python$PY/site-packages # Add a standard user - this won't prevent ownership issues with volumes if you're not UID 1000 RUN useradd -s /bin/bash -m otbuser -# Copy built files from intermediate stage +# Admin rights without password (not recommended, use `docker run -u root` instead) +ARG SUDO=false +RUN ! $SUDO || usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +# Allow user to install packages in prefix /opt/otbtf and venv without being root COPY --from=otb-build --chown=otbuser:otbuser /opt/otbtf /opt/otbtf COPY --from=otb-build --chown=otbuser:otbuser /src /src +USER otbuser + +# Install OTBTF python module +WORKDIR /src/otbtf +COPY otbtf /otbtf +COPY tricks ./tricks +COPY README.md setup.py . +RUN pip install -e . # Install test packages for dev image RUN ! $DEV_IMAGE || pip install codespell flake8 pylint pytest pytest-cov pytest-order -# Admin rights without password (not recommended, use `docker run -u root` instead) -ARG SUDO=false -RUN ! $SUDO || usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers - -# Default user, directory and command (bash will be the default entrypoint) WORKDIR /home/otbuser -USER otbuser # Test python imports -RUN python -c "import tensorflow" -RUN python -c "import otbtf, tricks" +RUN python -c "import tensorflow ; import keras" RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" +RUN python -c "from osgeo import gdal ; import otbtf ; import tricks" -- GitLab From f857651f5aafc6a5e9298fcecc1bb35ccf777947 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 20 Oct 2024 16:55:51 +0200 Subject: [PATCH 193/317] Add missing dot in path --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9523bfa9..1624abdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -179,7 +179,7 @@ USER otbuser # Install OTBTF python module WORKDIR /src/otbtf -COPY otbtf /otbtf +COPY otbtf ./otbtf COPY tricks ./tricks COPY README.md setup.py . RUN pip install -e . -- GitLab From 5f92d3da9bd63b314cc490aa5f286fe5c93c333e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 20 Oct 2024 17:04:34 +0200 Subject: [PATCH 194/317] Add var CUDA_CC to set compute capabilities + test runner bazel cache cleaned --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1624abdf..77f4f50c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,7 +51,8 @@ RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY # TF build arguments ARG TF=v2.18.0-rc2 ARG WITH_CUDA=false -ARG CUDA_COMPUTE_CAPABILITIES +# Custom compute capabilities, else use default one from .bazelrc +ARG CUDA_CC ARG WITH_XLA=true ARG WITH_MKL=false @@ -72,7 +73,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ - && ( [ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_COMPUTE_CAPABILITIES" ) \ + && ( [ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ -- GitLab From 25d5f3c00a79fdd1df8faff8a9347d9d64252a2b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 20 Oct 2024 17:04:59 +0200 Subject: [PATCH 195/317] Fix renamed variable --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 77f4f50c..2a76c704 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,7 +73,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ - && ( [ -z "$CUDA_COMPUTE_CAPABILITIES" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC" ) \ + && ( [ -z "$CUDA_CC" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC" ) \ && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ -- GitLab From 97643e18234bb70ffb8db595a236bcc9aaa2057e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 09:46:18 +0200 Subject: [PATCH 196/317] Get OTBTF_VERSION from commit tag --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2fc277b3..ce63a14a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,12 @@ variables: - OTBTF_VERSION: 4.4.0 - OTBTF_SRC: /src/otbtf # OTBTF source directory path in image - DATADIR: $CI_PROJECT_DIR/test/data DOCKER_BUILDKIT: 1 - BUILDX_NO_DEFAULT_ATTESTATIONS: 1 BUILDX_BUILDER: container + BUILDX_NO_DEFAULT_ATTESTATIONS: 1 + OTBTF_SRC: /src/otbtf # OTBTF source directory path in image CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME DEV_IMAGE: $CI_REGISTRY_IMAGE:cpu-basic-dev-testing - CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION - DOCKERHUB_BASE: mdl4eo/otbtf - DOCKERHUB_IMAGE_BASE: ${DOCKERHUB_BASE}:${OTBTF_VERSION} workflow: auto_cancel: @@ -250,6 +245,11 @@ nodata: stage: Ship rules: - if: $CI_COMMIT_TAG + variables: + OTBTF_VERSION: $CI_COMMIT_TAG + DOCKERHUB_BASE: mdl4eo/otbtf + CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION + DOCKERHUB_IMAGE_BASE: ${DOCKERHUB_BASE}:${OTBTF_VERSION} deploy_cpu: extends: .ship_base -- GitLab From fa3e35bad10f9d41c8eced75c83975eb7513f47c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 09:47:05 +0200 Subject: [PATCH 197/317] Build TF release 2.18 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a76c704..4fdf3a9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,7 @@ RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing # TF build arguments -ARG TF=v2.18.0-rc2 +ARG TF=v2.18.0 ARG WITH_CUDA=false # Custom compute capabilities, else use default one from .bazelrc ARG CUDA_CC @@ -193,4 +193,4 @@ WORKDIR /home/otbuser # Test python imports RUN python -c "import tensorflow ; import keras" RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" -RUN python -c "from osgeo import gdal ; import otbtf ; import tricks" +RUN python -c "import otbtf ; import tricks" -- GitLab From 986b2683f24570487052abc7fc48469147af7f39 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 11:17:44 +0200 Subject: [PATCH 198/317] Remove deprecated keras packages --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4fdf3a9a..9cf25536 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,8 +45,7 @@ RUN virtualenv $VIRTUAL_ENV RUN pip install --no-cache-dir -U pip wheel # Numpy 2 support in TF is planned for 2.18, but isn't supported by most libraries for now ARG NUMPY="1.26.4" -RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests \ - && pip install --no-cache-dir --no-deps keras_applications keras_preprocessing +RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests # TF build arguments ARG TF=v2.18.0 -- GitLab From 7dfba01a16c5c51000058671f324e48014836868 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 12:00:27 +0200 Subject: [PATCH 199/317] Purge removed images from table in docs --- doc/docker_use.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/doc/docker_use.md b/doc/docker_use.md index 0a4cfeb2..4150c0ff 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -140,44 +140,30 @@ Here you can find the list of older releases of OTBTF: | **mdl4eo/otbtf:3.3.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.0-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.0-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.2-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.2-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.2-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.2-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.2-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.2-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.3-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.3-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.3-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.3.3-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.3-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.3.3-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.4.0-cpu** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.4.0-cpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.4.0-gpu** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:3.4.0-gpu-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.4.0-gpu-opt** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:3.4.0-gpu-opt-dev** | Ubuntu Focal | r2.8 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.0.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.0.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.0.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.0.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.0.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.0.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.1.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.1.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.1.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.1.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.2.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.2.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.2.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.2.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.2.1-cpu** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.2.1-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.2.1-gpu** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| @@ -200,5 +186,3 @@ Here you can find the list of older releases of OTBTF: | **mdl4eo/otbtf:4.3.1-cpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.3.1-gpu** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| | **mdl4eo/otbtf:4.3.1-gpu-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **registry.forgemia.inra.fr/orfeo-toolbox/otbtf:4.3.1-gpu-opt-dev** | Ubuntu Jammy | r2.14 | 9.0.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -- GitLab From 84364b9564b47296718f24490978a56769c08bbe Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 12:00:55 +0200 Subject: [PATCH 200/317] Do not use git lfs fetch all branches, just pull --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ce63a14a..9819d176 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -144,7 +144,7 @@ ctest: OTB_TEST_UNITS: "Tensorflow|PanSharpening|Projection|Transform|IOGDAL" OTB_BUILD: /src/otb/build/OTB/build script: - - cd /src/otb/otb && git lfs fetch --all && git lfs pull + - cd /src/otb/otb && git lfs pull - ln -s $CI_PROJECT_DIR/test/data $OTBTF_SRC/test/data - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD -- GitLab From e543beaad0e97e53021f9e09988aea4d8261b4b6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 12:06:29 +0200 Subject: [PATCH 201/317] Try fix build on tag --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9819d176..652f7624 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,8 +12,8 @@ workflow: auto_cancel: on_new_commit: interruptible rules: - # Execute jobs in merge request context, or commit in master branch - - if: $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ + # Execute jobs on tags, in merge request context or commit in master branch + - if: $CI_COMMIT_TAG || $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ # Ignore pipeline for filthy commits - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i when: never -- GitLab From 29e8a29c9995602b55a0e2c1edb33e4b26c3014e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 13:40:30 +0200 Subject: [PATCH 202/317] Update CI workflow and rules --- .gitlab-ci.yml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 652f7624..e0edf6db 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,9 +11,14 @@ variables: workflow: auto_cancel: on_new_commit: interruptible + # Execute in merge request context or commit in master branch rules: - # Execute jobs on tags, in merge request context or commit in master branch - - if: $CI_COMMIT_TAG || $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ + - if: $CI_COMMIT_TAG + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + # Avoid duplicated pipelines in MR context + - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS + when: never + - if: $CI_COMMIT_REF_PROTECTED == "true" # Ignore pipeline for filthy commits - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i when: never @@ -44,6 +49,9 @@ stages: docker_image: stage: Build + only: + - merge_requests + - develop extends: .docker_build_base script: - > @@ -56,6 +64,8 @@ docker_image: .static_analysis_base: stage: Static Analysis allow_failure: true + only: + - merge_requests flake8: extends: .static_analysis_base @@ -116,6 +126,8 @@ build_docs: - public_test .tests_base: + only: + - merge_requests rules: - changes: - app/**/* @@ -272,11 +284,11 @@ deploy_cpu: --build-arg DEV_IMAGE=true . # push images on dockerhub - - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - - docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU - - docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV + #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + #- docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU + #- docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV # latest = cpu image - - docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST + #- docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST deploy_gpu: extends: .ship_base @@ -303,11 +315,11 @@ deploy_gpu: --build-arg WITH_CUDA=true --build-arg DEV_IMAGE=true . # push gpu-* images on dockerhub - - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - - docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU - - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV + #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + #- docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU + #- docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image - - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST + #- docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST export_tf_wheels: extends: .docker_build_base -- GitLab From e5c38c2ebcdfbfe908222a37953cfcd4e973c5d6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 13:48:36 +0200 Subject: [PATCH 203/317] Ship only on tags, test only in MR --- .gitlab-ci.yml | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0edf6db..261554b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,35 +69,22 @@ docker_image: flake8: extends: .static_analysis_base - rules: - - changes: - - otbtf/**/* script: - flake8 $OTBTF_SRC/otbtf --exclude=tensorflow_v1x pylint: extends: .static_analysis_base - rules: - - changes: - - otbtf/**/* script: - pylint $OTBTF_SRC/otbtf --ignore=tensorflow_v1x codespell: rules: - - changes: - - otbtf/**/* - - "**/*.md" extends: .static_analysis_base script: - codespell otbtf doc README.md cppcheck: extends: .static_analysis_base - rules: - - changes: - - app/**/* - - include/**/* script: - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . @@ -128,16 +115,6 @@ build_docs: .tests_base: only: - merge_requests - rules: - - changes: - - app/**/* - - include/**/* - - "**/*.py" - - "**/CMakeLists.txt" - - Dockerfile - - .gitlab-ci.yml - - otb-module.cmake - - setup.py variables: ARTIFACT_TEST_DIR: $CI_PROJECT_DIR/testing artifacts: @@ -255,8 +232,8 @@ nodata: .ship_base: extends: .docker_build_base stage: Ship - rules: - - if: $CI_COMMIT_TAG + only: + - tags variables: OTBTF_VERSION: $CI_COMMIT_TAG DOCKERHUB_BASE: mdl4eo/otbtf -- GitLab From 38018d1beae9dbefc6662e69495d796679b08f46 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 14:05:21 +0200 Subject: [PATCH 204/317] Fix missing variable DATADIR --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 261554b2..5758c996 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,8 @@ variables: DOCKER_BUILDKIT: 1 BUILDX_BUILDER: container BUILDX_NO_DEFAULT_ATTESTATIONS: 1 - OTBTF_SRC: /src/otbtf # OTBTF source directory path in image + OTBTF_SRC: /src/otbtf # OTBTF source directory path in image* + DATADIR: $CI_PROJECT_DIR/test/data CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME -- GitLab From 412056c4267a59046ca90dd054a55d737e48c7c5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 17:16:43 +0200 Subject: [PATCH 205/317] Fix boolean build argument interpreted as string --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9cf25536..5fc2ec66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,10 +71,10 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ && export TF_PYTHON_VERSION=$PY \ && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ - && ( ! $WITH_CUDA || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ + && ( [ "$WITH_CUDA" != "true" ] || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ && ( [ -z "$CUDA_CC" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC" ) \ - && ( ! $WITH_MKL || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ - && ( ! $WITH_XLA || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ + && ( [ "$WITH_MKL" != "true" ] || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ + && ( [ "$WITH_XLA" != "true" ] || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ @@ -125,7 +125,7 @@ RUN cd otb \ -DOTB_BUILD_SAR=ON \ -DOTB_BUILD_Segmentation=ON \ -DOTB_BUILD_StereoProcessing=ON \ - $( ! $OTBTESTS || echo "-DBUILD_TESTING=ON" ) \ + $( [ "$OTBTESTS" != "true" ] || echo "-DBUILD_TESTING=ON" ) \ -DDOWNLOAD_LOCATION=/tmp/SuperBuild-downloads \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && rm -rf /tmp/SuperBuild-downloads @@ -170,7 +170,7 @@ RUN useradd -s /bin/bash -m otbuser # Admin rights without password (not recommended, use `docker run -u root` instead) ARG SUDO=false -RUN ! $SUDO || usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers +RUN [ "$SUDO" != "true" ] || usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # Allow user to install packages in prefix /opt/otbtf and venv without being root COPY --from=otb-build --chown=otbuser:otbuser /opt/otbtf /opt/otbtf @@ -185,7 +185,7 @@ COPY README.md setup.py . RUN pip install -e . # Install test packages for dev image -RUN ! $DEV_IMAGE || pip install codespell flake8 pylint pytest pytest-cov pytest-order +RUN [ "$DEV_IMAGE" != "true" ] || pip install codespell flake8 pylint pytest pytest-cov pytest-order WORKDIR /home/otbuser -- GitLab From 8b76ecff3c860a60695e7714a665fbbe233675f2 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 17:26:48 +0200 Subject: [PATCH 206/317] Remove unused var --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5758c996..70215c7a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,6 @@ variables: CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME - DEV_IMAGE: $CI_REGISTRY_IMAGE:cpu-basic-dev-testing workflow: auto_cancel: -- GitLab From a7d617fe063baa6e9e5a3ee5694ef043888e5737 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 19:34:03 +0200 Subject: [PATCH 207/317] Try fix conditional run cmd --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5fc2ec66..64c2dd6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -151,7 +151,7 @@ RUN cd /src/otb/build/OTB/build \ -DTENSORFLOW_CC_LIB=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_cc.so.2 \ -DTENSORFLOW_FRAMEWORK_LIB=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_framework.so.2 \ && make install -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ - && ( $DEV_IMAGE || rm -rf /src/otb ) \ + && ( [ "$DEV_IMAGE" = "true" ] || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* # ---------------------------------------------------------------------------- @@ -170,7 +170,7 @@ RUN useradd -s /bin/bash -m otbuser # Admin rights without password (not recommended, use `docker run -u root` instead) ARG SUDO=false -RUN [ "$SUDO" != "true" ] || usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers +RUN if [ "$SUDO" = "true" ] ; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi # Allow user to install packages in prefix /opt/otbtf and venv without being root COPY --from=otb-build --chown=otbuser:otbuser /opt/otbtf /opt/otbtf @@ -185,7 +185,7 @@ COPY README.md setup.py . RUN pip install -e . # Install test packages for dev image -RUN [ "$DEV_IMAGE" != "true" ] || pip install codespell flake8 pylint pytest pytest-cov pytest-order +RUN if [ "$DEV_IMAGE" = "true" ] ; then pip install codespell flake8 pylint pytest pytest-cov pytest-order; fi WORKDIR /home/otbuser -- GitLab From 02ea13e0aec70ebf0a6bcce266b798e948f63974 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 19:39:42 +0200 Subject: [PATCH 208/317] CI for default branch --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70215c7a..876c9aba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,14 +11,14 @@ variables: workflow: auto_cancel: on_new_commit: interruptible - # Execute in merge request context or commit in master branch rules: + # Execute on tags, MR or default branch - if: $CI_COMMIT_TAG - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Avoid duplicated pipelines in MR context - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - - if: $CI_COMMIT_REF_PROTECTED == "true" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Ignore pipeline for filthy commits - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i when: never -- GitLab From 05ee25f4c385b201e36d04b9b1c853aba279bf54 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 25 Oct 2024 20:01:00 +0200 Subject: [PATCH 209/317] Fix boolean condition for RUN --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 64c2dd6e..3266f993 100644 --- a/Dockerfile +++ b/Dockerfile @@ -170,7 +170,7 @@ RUN useradd -s /bin/bash -m otbuser # Admin rights without password (not recommended, use `docker run -u root` instead) ARG SUDO=false -RUN if [ "$SUDO" = "true" ] ; then usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; fi +RUN ! $SUDO || usermod -a -G sudo otbuser && echo "otbuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # Allow user to install packages in prefix /opt/otbtf and venv without being root COPY --from=otb-build --chown=otbuser:otbuser /opt/otbtf /opt/otbtf @@ -185,7 +185,7 @@ COPY README.md setup.py . RUN pip install -e . # Install test packages for dev image -RUN if [ "$DEV_IMAGE" = "true" ] ; then pip install codespell flake8 pylint pytest pytest-cov pytest-order; fi +RUN ! $DEV_IMAGE || pip install codespell flake8 pylint pytest pytest-cov pytest-order WORKDIR /home/otbuser -- GitLab From b515110db1414e0c046813aa66a7e4e27c221d30 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 13:03:34 +0200 Subject: [PATCH 210/317] Fix bash conditional using if, remove parenthesis --- Dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3266f993..6b613bf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,24 +69,24 @@ ARG TF_BUILD_ARTIFACTS # Save local bazel cache with docker mount RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ - && export TF_PYTHON_VERSION=$PY \ - && export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ - && ( [ "$WITH_CUDA" != "true" ] || export BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ) \ - && ( [ -z "$CUDA_CC" ] || export BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC" ) \ - && ( [ "$WITH_MKL" != "true" ] || export BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ) \ - && ( [ "$WITH_XLA" != "true" ] || export BZL_CONFIGS="$BZL_CONFIGS --config=xla" ) \ + && TF_PYTHON_VERSION=$PY \ + && BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ + && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ; fi \ + && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ + && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ + && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ - && export TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ + && TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ && pip install --no-cache-dir $TF_WHEEL \ && ln -s $PYTHON_SITE_PACKAGES/tensorflow/include /opt/otbtf/include/tf \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ - && export TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ + && TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ - && export ARTIFACTS="$TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so*" \ - && ( [ -z "$TF_BUILD_ARTIFACTS" ] || (mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS) ) \ + && ARTIFACTS="$TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so*" \ + && if [ -n "$TF_BUILD_ARTIFACTS" ] ; then mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS ; fi \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- -- GitLab From 9031dbcd8b07d35d402a55ce22ed815fdcda96fb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 13:03:39 +0200 Subject: [PATCH 211/317] Remove useless var --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 876c9aba..55270021 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,7 +58,7 @@ docker_image: docker buildx build --push -t $BRANCH_IMAGE --cache-from type=registry,ref=$CACHE_IMAGE_CPU --cache-to type=registry,ref=$CACHE_IMAGE_CPU,mode=max,oci-mediatypes=true,image-manifest=true - --build-arg DEV_IMAGE=true --build-arg OTBTESTS=true + --build-arg DEV_IMAGE=true "." .static_analysis_base: -- GitLab From 7b1a1904577364360d4e0008b6ff865843ae4a88 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 13:31:11 +0200 Subject: [PATCH 212/317] Ensure the right python version is used --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6b613bf2..f9b027f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,13 +69,13 @@ ARG TF_BUILD_ARTIFACTS # Save local bazel cache with docker mount RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ - && TF_PYTHON_VERSION=$PY \ && BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ; fi \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ + && export HERMETIC_PYTHON_VERSION=$PY \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ @@ -145,6 +145,7 @@ RUN cd /src/otb/build/OTB/build \ && cmake /src/otb/otb \ -DCMAKE_INSTALL_PREFIX=/opt/otbtf \ -DOTB_WRAP_PYTHON=ON \ + -DPython_EXECUTABLE=$(which python) \ -DOTB_USE_TENSORFLOW=ON \ -DModule_OTBTensorflow=ON \ -Dtensorflow_include_dir=/opt/otbtf/include/tf \ -- GitLab From 586a066d400d0ec333b827e27a03d16009876c09 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 13:37:20 +0200 Subject: [PATCH 213/317] Update CI rules --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55270021..73881a64 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,14 +95,16 @@ build_docs: variables: PTH: public_test rules: + - if: $CI_MERGE_REQUEST_ID + when: manual + - if: $CI_COMMIT_REF_NAME == /master/ + variables: + PTH: public - changes: - doc/**/* - "*.{md,txt}" - mkdocs.yml - .readthedocs.yaml - - if: $CI_COMMIT_REF_NAME == /master/ - variables: - PTH: public before_script: - pip install -r doc/doc_requirements.txt script: @@ -143,9 +145,7 @@ ctest: .applications_test_base: extends: .tests_base - #rules: - # - if: $CI_MERGE_REQUEST_ID - # when: manual + #when: manual stage: Applications Test before_script: - mkdir -p $ARTIFACT_TEST_DIR -- GitLab From 59d9333077c6ff924eed2968f09afabfb003c6cc Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 13:45:30 +0200 Subject: [PATCH 214/317] Remove var OTBTESTS in favor of DEV_IMAGE --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f9b027f6..7284daa1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,7 +99,8 @@ COPY --from=tf-build /opt/otbtf /opt/otbtf # SuperBuild OTB ARG OTB=release-9.1 ADD --keep-git-dir=true https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git#$OTB otb -ARG OTBTESTS=false +ARG DEV_IMAGE=false + # <------------------------------------------ # This is a dirty hack for release 4.0.0alpha # We have to wait that OTB moves from C++14 to C++17 @@ -125,7 +126,7 @@ RUN cd otb \ -DOTB_BUILD_SAR=ON \ -DOTB_BUILD_Segmentation=ON \ -DOTB_BUILD_StereoProcessing=ON \ - $( [ "$OTBTESTS" != "true" ] || echo "-DBUILD_TESTING=ON" ) \ + $( [ "$DEV_IMAGE" != "true" ] || echo "-DBUILD_TESTING=ON" ) \ -DDOWNLOAD_LOCATION=/tmp/SuperBuild-downloads \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && rm -rf /tmp/SuperBuild-downloads @@ -139,7 +140,6 @@ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ # Build OTBTF cpp -ARG DEV_IMAGE=false RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf RUN cd /src/otb/build/OTB/build \ && cmake /src/otb/otb \ -- GitLab From b0cb6efbabc5a9074ca6e828ddde5f4207f6ccbb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 13:48:17 +0200 Subject: [PATCH 215/317] Try keep OTB build layer, build tests in second layer with OTBTF module --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7284daa1..9b81e549 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,7 +99,6 @@ COPY --from=tf-build /opt/otbtf /opt/otbtf # SuperBuild OTB ARG OTB=release-9.1 ADD --keep-git-dir=true https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git#$OTB otb -ARG DEV_IMAGE=false # <------------------------------------------ # This is a dirty hack for release 4.0.0alpha @@ -126,7 +125,6 @@ RUN cd otb \ -DOTB_BUILD_SAR=ON \ -DOTB_BUILD_Segmentation=ON \ -DOTB_BUILD_StereoProcessing=ON \ - $( [ "$DEV_IMAGE" != "true" ] || echo "-DBUILD_TESTING=ON" ) \ -DDOWNLOAD_LOCATION=/tmp/SuperBuild-downloads \ && make -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && rm -rf /tmp/SuperBuild-downloads @@ -140,6 +138,7 @@ RUN mkdir test COPY test/CMakeLists.txt test/*.cxx test/ # Build OTBTF cpp +ARG DEV_IMAGE=false RUN ln -s /src/otbtf /src/otb/otb/Modules/Remote/otbtf RUN cd /src/otb/build/OTB/build \ && cmake /src/otb/otb \ @@ -151,6 +150,7 @@ RUN cd /src/otb/build/OTB/build \ -Dtensorflow_include_dir=/opt/otbtf/include/tf \ -DTENSORFLOW_CC_LIB=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_cc.so.2 \ -DTENSORFLOW_FRAMEWORK_LIB=$PYTHON_SITE_PACKAGES/tensorflow/libtensorflow_framework.so.2 \ + $( [ "$DEV_IMAGE" != "true" ] || echo "-DBUILD_TESTING=ON" ) \ && make install -j $(python -c "import os; print(round( os.cpu_count() * $CPU_RATIO ))") \ && ( [ "$DEV_IMAGE" = "true" ] || rm -rf /src/otb ) \ && rm -rf /root/.cache /tmp/* -- GitLab From 0ff72418481e767ebb33b1d55125bdb722aabf24 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 16:11:42 +0200 Subject: [PATCH 216/317] Update CI workflow --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 73881a64..d4ba8766 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -88,7 +88,7 @@ cppcheck: script: - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . -build_docs: +docs: tags: [ stable ] image: python:3.10-slim stage: Documentation @@ -115,6 +115,7 @@ build_docs: - public_test .tests_base: + needs: ["docker_image"] only: - merge_requests variables: @@ -301,6 +302,7 @@ deploy_gpu: export_tf_wheels: extends: .docker_build_base stage: Export TensorFlow + needs: ["deploy_cpu", "deploy_gpu"] rules: - when: manual artifacts: -- GitLab From 299a39706eae5f08ade37acf9764a813d6cfaa98 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 16:14:26 +0200 Subject: [PATCH 217/317] Update dockerignore --- .dockerignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3fa1d2fd..acbfeefe 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,7 @@ -.* -.git* +.git Dockerfile **/__pycache__ +.readthedocs.yaml doc/* mkdocs.yml RELEASE_NOTES.txt -- GitLab From 602a61e4769272455e404b6d29a99e883bd9d88f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 16:22:00 +0200 Subject: [PATCH 218/317] Fix jobs inter dependencies --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4ba8766..b240503e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,6 +63,7 @@ docker_image: .static_analysis_base: stage: Static Analysis + needs: [] allow_failure: true only: - merge_requests @@ -300,7 +301,7 @@ deploy_gpu: #- docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST export_tf_wheels: - extends: .docker_build_base + extends: .ship_base stage: Export TensorFlow needs: ["deploy_cpu", "deploy_gpu"] rules: -- GitLab From 19ab8c1e34ca385edc37e01d6541ddcf1268f7bd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 16:23:02 +0200 Subject: [PATCH 219/317] Try fix rule for manual job --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b240503e..6ea4c350 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -304,8 +304,7 @@ export_tf_wheels: extends: .ship_base stage: Export TensorFlow needs: ["deploy_cpu", "deploy_gpu"] - rules: - - when: manual + when: manual artifacts: paths: - cpu-build-artifacts/ -- GitLab From 0867ce3b780f7d1f55a54c773e44ccf45dc653dc Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 16:39:18 +0200 Subject: [PATCH 220/317] Update CI rules --- .gitlab-ci.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ea4c350..0019b24e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,13 +12,13 @@ workflow: auto_cancel: on_new_commit: interruptible rules: - # Execute on tags, MR or default branch + # Execute on tags, MR or protected branches - if: $CI_COMMIT_TAG - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Avoid duplicated pipelines in MR context - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - if: $CI_COMMIT_REF_PROTECTED == "true" # Ignore pipeline for filthy commits - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i when: never @@ -90,14 +90,13 @@ cppcheck: - cd $OTBTF_SRC/ && cppcheck --enable=all --error-exitcode=1 -I include/ --suppress=missingInclude --suppress=unusedFunction . docs: + stage: Documentation tags: [ stable ] + needs: [] image: python:3.10-slim - stage: Documentation variables: PTH: public_test rules: - - if: $CI_MERGE_REQUEST_ID - when: manual - if: $CI_COMMIT_REF_NAME == /master/ variables: PTH: public @@ -147,11 +146,10 @@ ctest: .applications_test_base: extends: .tests_base - #when: manual stage: Applications Test + #when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR - - cd $CI_PROJECT_DIR crc_book: extends: .applications_test_base -- GitLab From 5d53988da9560885f49bf02e22f0a1756f8556c5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 26 Oct 2024 16:40:53 +0200 Subject: [PATCH 221/317] Ensure static analysis triggers after docker build --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0019b24e..997f6d9e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,7 +63,6 @@ docker_image: .static_analysis_base: stage: Static Analysis - needs: [] allow_failure: true only: - merge_requests -- GitLab From 41a2d166d74c7c7b40daac5ffbf30fe4d5eb0e61 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 14:42:51 +0100 Subject: [PATCH 222/317] Include cuda libs --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9b81e549..0b3a2243 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,7 +70,7 @@ ARG TF_BUILD_ARTIFACTS RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ && BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ - && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ; fi \ + && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux" ; fi \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ -- GitLab From 2970ed36628ce231f2452e0691e11577185ae735 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 14:43:15 +0100 Subject: [PATCH 223/317] Do not use git tag as docker image tag --- .gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 997f6d9e..1a6d67be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ variables: DOCKER_BUILDKIT: 1 BUILDX_BUILDER: container BUILDX_NO_DEFAULT_ATTESTATIONS: 1 + OTBTF_VERSION: 4.4.0 OTBTF_SRC: /src/otbtf # OTBTF source directory path in image* DATADIR: $CI_PROJECT_DIR/test/data CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu @@ -96,6 +97,8 @@ docs: variables: PTH: public_test rules: + - if: $CI_COMMIT_TAG + when: never - if: $CI_COMMIT_REF_NAME == /master/ variables: PTH: public @@ -234,10 +237,9 @@ nodata: only: - tags variables: - OTBTF_VERSION: $CI_COMMIT_TAG DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION - DOCKERHUB_IMAGE_BASE: ${DOCKERHUB_BASE}:${OTBTF_VERSION} + DOCKERHUB_IMAGE_BASE: $DOCKERHUB_BASE:$OTBTF_VERSION deploy_cpu: extends: .ship_base -- GitLab From 428f8fc2eb000259eda64b5a28b4c34521a0e7d4 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 14:47:34 +0100 Subject: [PATCH 224/317] Add --subcommands bazel option --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0b3a2243..399e4ba3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ - && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ + && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --subcommands --verbose_failures" \ && export HERMETIC_PYTHON_VERSION=$PY \ && echo "Build env:" && env \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ -- GitLab From 925e75448d1b4b21a401687e4f62fad8f2e9c9a4 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 14:52:50 +0100 Subject: [PATCH 225/317] Add bazel info cmd --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 399e4ba3..c6a4987f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,9 +74,10 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ - && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --subcommands --verbose_failures" \ + && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ && export HERMETIC_PYTHON_VERSION=$PY \ && echo "Build env:" && env \ + && echo "Bazel info:" && bazel info \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ && TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ -- GitLab From 46e1b83fbc57342ed16b607baf964117ff058095 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 14:59:31 +0100 Subject: [PATCH 226/317] Add bazel cquery to print config before build --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index c6a4987f..a5bfb897 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,12 +74,12 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ - && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ + && BZL_ARGS="$BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ && export HERMETIC_PYTHON_VERSION=$PY \ && echo "Build env:" && env \ - && echo "Bazel info:" && bazel info \ - && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ - && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ + && bazel cquery $BZL_ARGS \ + && echo "Starting build with cmd: \"bazel build $BZL_ARGS\"" \ + && bazel build $BZL_ARGS --jobs="HOST_CPUS*$CPU_RATIO" \ && TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ && pip install --no-cache-dir $TF_WHEEL \ && ln -s $PYTHON_SITE_PACKAGES/tensorflow/include /opt/otbtf/include/tf \ -- GitLab From fcccb4db9b4593912e87554745cd9e81ad2dcc2a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 15:03:40 +0100 Subject: [PATCH 227/317] Try quote bazel targets --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a5bfb897..e2d336ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,7 @@ RUN chmod +x /opt/otbtf/bin/bazelisk && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf # Build and install TF wheel ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow -ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" +ARG BZL_TARGETS="'//tensorflow:libtensorflow_cc.so' '//tensorflow/tools/pip_package:wheel'" # You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time ARG BZL_OPTIONS ARG TF_BUILD_ARTIFACTS -- GitLab From 12a097de821ca7820c88179ba7854203056615dd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 15:06:49 +0100 Subject: [PATCH 228/317] Bazel only cquery wheel target config --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e2d336ab..274591b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,7 @@ RUN chmod +x /opt/otbtf/bin/bazelisk && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf # Build and install TF wheel ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow -ARG BZL_TARGETS="'//tensorflow:libtensorflow_cc.so' '//tensorflow/tools/pip_package:wheel'" +ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time ARG BZL_OPTIONS ARG TF_BUILD_ARTIFACTS @@ -74,12 +74,12 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ - && BZL_ARGS="$BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ && export HERMETIC_PYTHON_VERSION=$PY \ && echo "Build env:" && env \ - && bazel cquery $BZL_ARGS \ - && echo "Starting build with cmd: \"bazel build $BZL_ARGS\"" \ - && bazel build $BZL_ARGS --jobs="HOST_CPUS*$CPU_RATIO" \ + && bazel cquery //tensorflow/tools/pip_package:wheel $BZL_CONFIGS $BZL_OPTIONS \ + && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ + && echo "Starting build with cmd: \"bazel build $BZL_CMD\"" \ + && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ && TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ && pip install --no-cache-dir $TF_WHEEL \ && ln -s $PYTHON_SITE_PACKAGES/tensorflow/include /opt/otbtf/include/tf \ -- GitLab From e71e499b62915f09f5950ccfa00324b2dd99e675 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 15:08:39 +0100 Subject: [PATCH 229/317] Update bazel cmd --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 274591b9..9617694d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -78,7 +78,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && echo "Build env:" && env \ && bazel cquery //tensorflow/tools/pip_package:wheel $BZL_CONFIGS $BZL_OPTIONS \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ - && echo "Starting build with cmd: \"bazel build $BZL_CMD\"" \ + && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ && TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ && pip install --no-cache-dir $TF_WHEEL \ -- GitLab From 8a129dfdc9e7cbc8f54d000ec8260d1d5b6e7f6d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 15:10:52 +0100 Subject: [PATCH 230/317] Add missing output to bazel cquery --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9617694d..fa389efa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,7 +76,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ && export HERMETIC_PYTHON_VERSION=$PY \ && echo "Build env:" && env \ - && bazel cquery //tensorflow/tools/pip_package:wheel $BZL_CONFIGS $BZL_OPTIONS \ + && bazel cquery //tensorflow/tools/pip_package:wheel $BZL_CONFIGS $BZL_OPTIONS --output=build \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ -- GitLab From 43d37039e04fdd35b08239d832019182ee9f77bd Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 15:15:37 +0100 Subject: [PATCH 231/317] Add bazel option --announce_rc --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fa389efa..8725383e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,8 +76,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ && export HERMETIC_PYTHON_VERSION=$PY \ && echo "Build env:" && env \ - && bazel cquery //tensorflow/tools/pip_package:wheel $BZL_CONFIGS $BZL_OPTIONS --output=build \ - && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS $BZL_OPTIONS --verbose_failures" \ + && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS --announce_rc --verbose_failures $BZL_OPTIONS" \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ && TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ -- GitLab From 5296568076eaa37dc449197cbc1f47a5f56c6683 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 15:20:01 +0100 Subject: [PATCH 232/317] Force trigger pipeline --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8725383e..fbce16ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,7 +47,7 @@ RUN pip install --no-cache-dir -U pip wheel ARG NUMPY="1.26.4" RUN pip install --no-cache-dir -U mock six future tqdm deprecated numpy==$NUMPY packaging requests -# TF build arguments +# TensorFlow build arguments ARG TF=v2.18.0 ARG WITH_CUDA=false # Custom compute capabilities, else use default one from .bazelrc @@ -59,14 +59,14 @@ ARG WITH_MKL=false ADD https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 /opt/otbtf/bin/bazelisk RUN chmod +x /opt/otbtf/bin/bazelisk && ln -s /opt/otbtf/bin/bazelisk /opt/otbtf/bin/bazel -# Build and install TF wheel +# Build and install tf wheel ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time ARG BZL_OPTIONS ARG TF_BUILD_ARTIFACTS -# Save local bazel cache with docker mount +# Run build with local bazel cache using docker mount RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ && BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ -- GitLab From a369881e1a8e750ec889a60197a5f7a1cdf59c3f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 15:24:13 +0100 Subject: [PATCH 233/317] Set versiont tag to rc --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a6d67be..783d48a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,8 @@ variables: DOCKER_BUILDKIT: 1 BUILDX_BUILDER: container BUILDX_NO_DEFAULT_ATTESTATIONS: 1 - OTBTF_VERSION: 4.4.0 - OTBTF_SRC: /src/otbtf # OTBTF source directory path in image* + OTBTF_VERSION: 4.4.0-rc1 + OTBTF_SRC: /src/otbtf # OTBTF source directory path in image DATADIR: $CI_PROJECT_DIR/test/data CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu -- GitLab From 1aa5997537d6217dcdbdacf561fd176a80d03dbe Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 16:35:24 +0100 Subject: [PATCH 234/317] Make sure to include cuda libs in wheel --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fbce16ac..e2936ce7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,7 +70,7 @@ ARG TF_BUILD_ARTIFACTS RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ && BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ - && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux" ; fi \ + && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --@local_config_cuda//cuda:include_cuda_libs=true" ; fi \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ -- GitLab From a7dddb10bd5bd8735abf840a0d1cb2163901b565 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sun, 27 Oct 2024 17:17:20 +0100 Subject: [PATCH 235/317] Install cuda via pip --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e2936ce7..1cf90419 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,7 +70,7 @@ ARG TF_BUILD_ARTIFACTS RUN --mount=type=cache,target=/root/.cache/bazel \ cd tensorflow \ && BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow_cpu --config=release_cpu_linux" \ - && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --@local_config_cuda//cuda:include_cuda_libs=true" ; fi \ + && if [ "$WITH_CUDA" = "true" ] ; then BZL_CONFIGS="--repo_env=WHEEL_NAME=tensorflow --config=release_gpu_linux --config=cuda_wheel" ; fi \ && if [ -n "$CUDA_CC" ] ; then BZL_CONFIGS="$BZL_CONFIGS --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=$CUDA_CC"; fi \ && if [ "$WITH_MKL" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=mkl" ; fi \ && if [ "$WITH_XLA" = "true" ] ; then BZL_CONFIGS="$BZL_CONFIGS --config=xla" ; fi \ @@ -79,8 +79,8 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && BZL_CMD="build $BZL_TARGETS $BZL_CONFIGS --announce_rc --verbose_failures $BZL_OPTIONS" \ && echo "Starting build with cmd: \"bazel $BZL_CMD\"" \ && bazel $BZL_CMD --jobs="HOST_CPUS*$CPU_RATIO" \ - && TF_WHEEL="bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow*.whl" \ - && pip install --no-cache-dir $TF_WHEEL \ + && TF_WHEEL=$(find bazel-bin/tensorflow/tools/pip_package/wheel_house/ -type f -name "tensorflow*.whl") \ + && pip install --no-cache-dir "$TF_WHEEL$(! $WITH_CUDA || echo '[and-cuda]')" \ && ln -s $PYTHON_SITE_PACKAGES/tensorflow/include /opt/otbtf/include/tf \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ && TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ -- GitLab From 66fee7fe6ab12c1963d9620ed5d07181edb8eaf7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 10:40:05 +0100 Subject: [PATCH 236/317] Update comments --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1cf90419..c70f8d11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,14 @@ FROM ubuntu:jammy-20240911.1 AS base-stage WORKDIR /tmp -### System packages +# System packages ARG DEBIAN_FRONTEND=noninteractive COPY system-dependencies.txt . RUN apt-get update -y && apt-get upgrade -y \ && cat system-dependencies.txt | xargs apt-get install --no-install-recommends -y \ && apt-get clean && rm -rf /var/lib/apt/lists/* +# Env required during build and for the final image ENV PY=3.10 ENV VIRTUAL_ENV=/opt/otbtf/venv ENV PATH="$VIRTUAL_ENV/bin:/opt/otbtf/bin:$PATH" @@ -23,7 +24,7 @@ ENV LD_LIBRARY_PATH=/opt/otbtf/lib ARG CPU_RATIO=1 # ---------------------------------------------------------------------------- -### Builder stage: bazel clang tensorflow +# Builder stage: bazel clang tensorflow FROM base-stage AS tf-build WORKDIR /src/tf RUN mkdir -p /opt/otbtf/bin /opt/otbtf/lib /opt/otbtf/include @@ -90,7 +91,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- -### Builder stage: cmake gcc otb +# Builder stage: cmake gcc otb FROM base-stage AS otb-build WORKDIR /src/otb -- GitLab From 360e2a44816930219af424106f4a83ad6241eb28 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 10:41:20 +0100 Subject: [PATCH 237/317] Fix CI stage tf build artifacts --- .gitlab-ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 783d48a1..26f29030 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -309,18 +309,16 @@ export_tf_wheels: - cpu-build-artifacts/ - gpu-build-artifacts/ script: - # cpu - > - docker buildx build --target=tf-build - --mount=type=bind,source=$(pwd)/cpu-build-artifacts,target=/tmp/artifacts - --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts + docker buildx build --target=tf-build -t tf-build-cpu --cache-from type=registry,ref=$CACHE_IMAGE_CPU + --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts . - # gpu + - docker run -v cpu-build-artifacts:/artifacts tf-build-cpu mv /tmp/artifacts/* /artifacts/ - > - docker buildx build --target=tf-build - --mount=type=bind,source=$(pwd)/gpu-build-artifacts,target=/tmp/artifacts + docker buildx build --target=tf-build -t tf-build-gpu + --cache-from type=registry,ref=$CACHE_IMAGE_GPU --build-arg WITH_CUDA=true --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts - --cache-from type=registry,ref=$CACHE_IMAGE_GPU . + - docker run -v gpu-build-artifacts:/artifacts tf-build-gpu mv /tmp/artifacts/* /artifacts/ -- GitLab From 5e0ed8b801a83dba00747d9379c711170b736ab8 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 12:31:17 +0100 Subject: [PATCH 238/317] Always copy tf artifacts --- .gitlab-ci.yml | 2 -- Dockerfile | 4 +--- doc/docker_build.md | 20 ++++++++------------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 26f29030..aa0e0d3e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -312,13 +312,11 @@ export_tf_wheels: - > docker buildx build --target=tf-build -t tf-build-cpu --cache-from type=registry,ref=$CACHE_IMAGE_CPU - --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts . - docker run -v cpu-build-artifacts:/artifacts tf-build-cpu mv /tmp/artifacts/* /artifacts/ - > docker buildx build --target=tf-build -t tf-build-gpu --cache-from type=registry,ref=$CACHE_IMAGE_GPU --build-arg WITH_CUDA=true - --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts . - docker run -v gpu-build-artifacts:/artifacts tf-build-gpu mv /tmp/artifacts/* /artifacts/ diff --git a/Dockerfile b/Dockerfile index c70f8d11..128c55dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,6 @@ ADD https://github.com/tensorflow/tensorflow.git#$TF tensorflow ARG BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # You can use --build-arg BZL_OPTIONS="--remote_cache=http://..." at build time ARG BZL_OPTIONS -ARG TF_BUILD_ARTIFACTS # Run build with local bazel cache using docker mount RUN --mount=type=cache,target=/root/.cache/bazel \ @@ -86,8 +85,7 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && for f in $(find -L /opt/otbtf/include/tf -wholename "*/external/*/*.so"); do ln -s $f /opt/otbtf/lib/; done \ && TF_MISSING_HEADERS="tensorflow/cc/saved_model/tag_constants.h tensorflow/cc/saved_model/signature_constants.h" \ && cp $TF_MISSING_HEADERS /opt/otbtf/include/tf/tensorflow/cc/saved_model/ \ - && ARTIFACTS="$TF_WHEEL $TF_MISSING_HEADERS bazel-bin/tensorflow/libtensorflow_cc.so*" \ - && if [ -n "$TF_BUILD_ARTIFACTS" ] ; then mkdir -p $TF_BUILD_ARTIFACTS && mv $ARTIFACTS $TF_BUILD_ARTIFACTS ; fi \ + && mkdir /tmp/artifacts && mv bazel-bin/tensorflow/libtensorflow_cc.so* $TF_WHEEL $TF_MISSING_HEADERS /tmp/artifacts \ && rm -rf bazel-* /src/tf # ---------------------------------------------------------------------------- diff --git a/doc/docker_build.md b/doc/docker_build.md index c07f94db..ccf4fc3f 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -1,13 +1,12 @@ # Build your own docker images -Docker build has to be called from the root of the repository (i.e. `docker - build .`. +Docker build has to be called from the root of the repository + (i.e. `docker build .`. You can select target versions using `--build-arg`: -- **TensorFlow** : `TF` arg for the git branch or tag, `ZIP_COMP_FILES` - allows you to save compiled tf binaries if you want to install it elsewhere. -- **OrfeoToolBox** : `OTB` arg for the git branch or tag, set `KEEP_SRC_OTB` -in order to preserve OTB sources +- **TensorFlow** : `TF` arg for the git branch or tag +- **OrfeoToolBox** : `OTB` arg for the git branch or tag, + set `KEEP_SRC_OTB` in order to preserve OTB sources ## Default build arguments @@ -31,8 +30,6 @@ CUDA_COMPUTE_CAPABILITIES= BZL_TARGETS="//tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:wheel" # Available for additional bazel options, e.g. --remote_cache BZL_OPTIONS= -# Path to save tf compiled wheel and libtensorflow_cc -TF_BUILD_ARTIFACTS= # Git branch or tag to checkout OTB=release-9.1 # Keep OTB sources and build test @@ -89,20 +86,19 @@ docker build --network='host' -t otbtf:gpu \ ### Build for another machine and save TF compiled files ```bash -docker build --network='host' -t otbtf:gpu \ - --mount=type=bind,source=$(pwd)/gpu-build-artifacts,target=/tmp/artifacts \ +docker build --network='host' --target=tf-build -t otbtf:gpu \ --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" \ --build-arg WITH_CUDA=true \ - --build-arg TF_BUILD_ARTIFACTS=/tmp/artifacts \ . # Target machine shell -cd gpu-build-artifacts/ +docker run -v gpu-build-artifacts:/artifacts otbtf:gpu mv /tmp/artifacts /artifacts sudo mv libtensorflow_cc* /usr/local/lib # You may need to create a virtualenv, here TF and dependencies are installed # next to user's pip packages pip3 install -U pip wheel mock six future deprecated "numpy<2" pip3 install --no-deps keras_applications keras_preprocessing +cd gpu-build-artifacts pip3 install tensorflow-v2.18.0-cp310-cp310-linux_x86_64.whl TF_WHEEL_DIR="$HOME/.local/lib/python3.10/site-packages/tensorflow" -- GitLab From 35df137f726682e1968fd13f7e1ac353aa0dbc8d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 22:33:04 +0100 Subject: [PATCH 239/317] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa0e0d3e..19eb0af3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -149,7 +149,7 @@ ctest: .applications_test_base: extends: .tests_base stage: Applications Test - #when: manual + when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR @@ -234,8 +234,8 @@ nodata: .ship_base: extends: .docker_build_base stage: Ship - only: - - tags + #only: + # - tags variables: DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION @@ -313,6 +313,8 @@ export_tf_wheels: docker buildx build --target=tf-build -t tf-build-cpu --cache-from type=registry,ref=$CACHE_IMAGE_CPU . + - docker images + - docker buildx ls - docker run -v cpu-build-artifacts:/artifacts tf-build-cpu mv /tmp/artifacts/* /artifacts/ - > docker buildx build --target=tf-build -t tf-build-gpu -- GitLab From 87c3310b4dda4405215078b6652bbbf11ce0b2bc Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 22:36:18 +0100 Subject: [PATCH 240/317] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 19eb0af3..43ec3561 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -303,21 +303,21 @@ export_tf_wheels: extends: .ship_base stage: Export TensorFlow needs: ["deploy_cpu", "deploy_gpu"] - when: manual + #when: manual artifacts: paths: - cpu-build-artifacts/ - gpu-build-artifacts/ script: - > - docker buildx build --target=tf-build -t tf-build-cpu + docker buildx build --load + --target=tf-build -t tf-build-cpu --cache-from type=registry,ref=$CACHE_IMAGE_CPU . - - docker images - - docker buildx ls - docker run -v cpu-build-artifacts:/artifacts tf-build-cpu mv /tmp/artifacts/* /artifacts/ - > - docker buildx build --target=tf-build -t tf-build-gpu + docker buildx build --load + --target=tf-build -t tf-build-gpu --cache-from type=registry,ref=$CACHE_IMAGE_GPU --build-arg WITH_CUDA=true . -- GitLab From 28790e987b82f02892284548742c3cbf2af31cf6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 23:01:47 +0100 Subject: [PATCH 241/317] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 43ec3561..6676172f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,9 @@ stages: - name: docker:dind before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - - docker buildx create --name container --driver=docker-container + - docker buildx create --name=container --driver=docker-container --use --bootstrap + after_script: + - docker buildx rm --keep-state container docker_image: stage: Build @@ -262,11 +264,11 @@ deploy_cpu: --build-arg DEV_IMAGE=true . # push images on dockerhub - #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - #- docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU - #- docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV + - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + - docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU + - docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV # latest = cpu image - #- docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST + - docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST deploy_gpu: extends: .ship_base @@ -293,17 +295,17 @@ deploy_gpu: --build-arg WITH_CUDA=true --build-arg DEV_IMAGE=true . # push gpu-* images on dockerhub - #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - #- docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU - #- docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV + - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + - docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU + - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image - #- docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST + - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST export_tf_wheels: extends: .ship_base stage: Export TensorFlow needs: ["deploy_cpu", "deploy_gpu"] - #when: manual + when: manual artifacts: paths: - cpu-build-artifacts/ @@ -311,13 +313,13 @@ export_tf_wheels: script: - > docker buildx build --load - --target=tf-build -t tf-build-cpu + --target tf-build -t tf-build-cpu --cache-from type=registry,ref=$CACHE_IMAGE_CPU . - docker run -v cpu-build-artifacts:/artifacts tf-build-cpu mv /tmp/artifacts/* /artifacts/ - > docker buildx build --load - --target=tf-build -t tf-build-gpu + --target tf-build -t tf-build-gpu --cache-from type=registry,ref=$CACHE_IMAGE_GPU --build-arg WITH_CUDA=true . -- GitLab From 77910c95f1ee99afecddf4e2a7ce19ba64ad9465 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 23:27:52 +0100 Subject: [PATCH 242/317] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6676172f..7c51ace4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -236,15 +236,20 @@ nodata: .ship_base: extends: .docker_build_base stage: Ship - #only: - # - tags + only: + - tags variables: DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION DOCKERHUB_IMAGE_BASE: $DOCKERHUB_BASE:$OTBTF_VERSION + before_script: + - docker buildx create --name=container --driver=docker-container --use --bootstrap + #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin deploy_cpu: extends: .ship_base + only: + - tags variables: IMAGE_CPU: $CI_REGISTRY_PUBIMG-cpu IMAGE_CPUDEV: $CI_REGISTRY_PUBIMG-cpu-dev @@ -264,14 +269,15 @@ deploy_cpu: --build-arg DEV_IMAGE=true . # push images on dockerhub - - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - - docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU - - docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV + #- docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU + #- docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV # latest = cpu image - - docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST + #- docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST deploy_gpu: extends: .ship_base + only: + - tags variables: IMAGE_GPU: $CI_REGISTRY_PUBIMG-gpu IMAGE_GPUDEV: $CI_REGISTRY_PUBIMG-gpu-dev @@ -282,30 +288,29 @@ deploy_gpu: # gpu - > docker buildx build --push -t $IMAGE_GPU - --cache-from type=registry,ref=$CACHE_IMAGE_CPU --cache-from type=registry,ref=$CACHE_IMAGE_GPU + --cache-from type=registry,ref=$CACHE_IMAGE_CPU --cache-to type=registry,ref=$CACHE_IMAGE_GPU,mode=max,oci-mediatypes=true,image-manifest=true --build-arg WITH_CUDA=true . # gpu-dev - > docker buildx build --push -t $IMAGE_GPUDEV - --cache-from type=registry,ref=$CACHE_IMAGE_CPU --cache-from type=registry,ref=$CACHE_IMAGE_GPU + --cache-from type=registry,ref=$CACHE_IMAGE_CPU --build-arg WITH_CUDA=true --build-arg DEV_IMAGE=true . # push gpu-* images on dockerhub - - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - - docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU - - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV + #- docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU + #- docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image - - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST + #- docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST export_tf_wheels: extends: .ship_base stage: Export TensorFlow - needs: ["deploy_cpu", "deploy_gpu"] - when: manual + #needs: ["deploy_cpu", "deploy_gpu"] + #when: manual artifacts: paths: - cpu-build-artifacts/ -- GitLab From 32acb664a95094a66e975c21a19cdd878b226f22 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 28 Oct 2024 23:28:42 +0100 Subject: [PATCH 243/317] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7c51ace4..4f6a7e5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -236,8 +236,6 @@ nodata: .ship_base: extends: .docker_build_base stage: Ship - only: - - tags variables: DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION -- GitLab From fca6f42f5b210b352bf6872c085c5b17a1cb3100 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 29 Oct 2024 09:45:47 +0100 Subject: [PATCH 244/317] Test list dir --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 128c55dd..7e5c31ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,6 +88,8 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && mkdir /tmp/artifacts && mv bazel-bin/tensorflow/libtensorflow_cc.so* $TF_WHEEL $TF_MISSING_HEADERS /tmp/artifacts \ && rm -rf bazel-* /src/tf +RUN ls /tmp/artifacts + # ---------------------------------------------------------------------------- # Builder stage: cmake gcc otb FROM base-stage AS otb-build -- GitLab From 1dd1d80b1185a547452fcd9a4423b245206d0184 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 29 Oct 2024 09:48:58 +0100 Subject: [PATCH 245/317] Remove new test line --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7e5c31ee..128c55dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,8 +88,6 @@ RUN --mount=type=cache,target=/root/.cache/bazel \ && mkdir /tmp/artifacts && mv bazel-bin/tensorflow/libtensorflow_cc.so* $TF_WHEEL $TF_MISSING_HEADERS /tmp/artifacts \ && rm -rf bazel-* /src/tf -RUN ls /tmp/artifacts - # ---------------------------------------------------------------------------- # Builder stage: cmake gcc otb FROM base-stage AS otb-build -- GitLab From 9f2349dca2171378e824f9690f4e2d269693e37d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 29 Oct 2024 10:01:28 +0100 Subject: [PATCH 246/317] Update CI config --- .gitlab-ci.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f6a7e5a..a05fa861 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -151,7 +151,7 @@ ctest: .applications_test_base: extends: .tests_base stage: Applications Test - when: manual + #when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR @@ -236,6 +236,8 @@ nodata: .ship_base: extends: .docker_build_base stage: Ship + #only: + # - tags variables: DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION @@ -246,8 +248,6 @@ nodata: deploy_cpu: extends: .ship_base - only: - - tags variables: IMAGE_CPU: $CI_REGISTRY_PUBIMG-cpu IMAGE_CPUDEV: $CI_REGISTRY_PUBIMG-cpu-dev @@ -274,8 +274,6 @@ deploy_cpu: deploy_gpu: extends: .ship_base - only: - - tags variables: IMAGE_GPU: $CI_REGISTRY_PUBIMG-gpu IMAGE_GPUDEV: $CI_REGISTRY_PUBIMG-gpu-dev @@ -307,8 +305,8 @@ deploy_gpu: export_tf_wheels: extends: .ship_base stage: Export TensorFlow - #needs: ["deploy_cpu", "deploy_gpu"] - #when: manual + needs: ["deploy_cpu", "deploy_gpu"] + when: manual artifacts: paths: - cpu-build-artifacts/ -- GitLab From 95e130ba351c5476678b1790614fe10696794955 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 29 Oct 2024 12:39:27 +0100 Subject: [PATCH 247/317] Update CI config --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a05fa861..d572bbaf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -119,7 +119,6 @@ docs: - public_test .tests_base: - needs: ["docker_image"] only: - merge_requests variables: @@ -135,6 +134,7 @@ docs: ctest: extends: .tests_base stage: Test + needs: ["docker_image"] variables: CTEST_OUTPUT_ON_FAILURE: 1 OTB_TEST_UNITS: "Tensorflow|PanSharpening|Projection|Transform|IOGDAL" @@ -151,6 +151,7 @@ ctest: .applications_test_base: extends: .tests_base stage: Applications Test + needs: ["ctest"] #when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR @@ -305,7 +306,6 @@ deploy_gpu: export_tf_wheels: extends: .ship_base stage: Export TensorFlow - needs: ["deploy_cpu", "deploy_gpu"] when: manual artifacts: paths: -- GitLab From b42a6e7098a31abaf9408447bfac5e3641b1bd1d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 29 Oct 2024 13:42:31 +0100 Subject: [PATCH 248/317] Try fix CI exec --- .gitlab-ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d572bbaf..1e05ac0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -132,8 +132,8 @@ docs: when: on_failure ctest: - extends: .tests_base stage: Test + extends: .tests_base needs: ["docker_image"] variables: CTEST_OUTPUT_ON_FAILURE: 1 @@ -149,8 +149,8 @@ ctest: - cp -r $OTB_BUILD/Testing/Temporary $ARTIFACT_TEST_DIR .applications_test_base: - extends: .tests_base stage: Applications Test + extends: .tests_base needs: ["ctest"] #when: manual before_script: @@ -236,18 +236,15 @@ nodata: .ship_base: extends: .docker_build_base - stage: Ship #only: # - tags variables: DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION DOCKERHUB_IMAGE_BASE: $DOCKERHUB_BASE:$OTBTF_VERSION - before_script: - - docker buildx create --name=container --driver=docker-container --use --bootstrap - #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin deploy_cpu: + stage: Ship extends: .ship_base variables: IMAGE_CPU: $CI_REGISTRY_PUBIMG-cpu @@ -268,12 +265,14 @@ deploy_cpu: --build-arg DEV_IMAGE=true . # push images on dockerhub + #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin #- docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU #- docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV # latest = cpu image #- docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST deploy_gpu: + stage: Ship extends: .ship_base variables: IMAGE_GPU: $CI_REGISTRY_PUBIMG-gpu @@ -298,15 +297,16 @@ deploy_gpu: --build-arg WITH_CUDA=true --build-arg DEV_IMAGE=true . # push gpu-* images on dockerhub + #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin #- docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU #- docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image #- docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST export_tf_wheels: - extends: .ship_base stage: Export TensorFlow - when: manual + extends: .ship_base + #when: manual artifacts: paths: - cpu-build-artifacts/ -- GitLab From af549775d7f2e94b551688bc813016f68802ae5e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 29 Oct 2024 14:10:48 +0100 Subject: [PATCH 249/317] Tmp allow failure for app tests --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e05ac0f..043b078d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -151,6 +151,7 @@ ctest: .applications_test_base: stage: Applications Test extends: .tests_base + allow_failure: true needs: ["ctest"] #when: manual before_script: -- GitLab From 64cfa116a09ec5ca36be9dec01f3cccca95fef95 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Tue, 29 Oct 2024 14:11:39 +0100 Subject: [PATCH 250/317] App tests manual job --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 043b078d..d901fb58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -151,9 +151,8 @@ ctest: .applications_test_base: stage: Applications Test extends: .tests_base - allow_failure: true needs: ["ctest"] - #when: manual + when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR -- GitLab From f62e0c37659df5928d69c1ec7cff19605de50c10 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 31 Oct 2024 12:42:18 +0100 Subject: [PATCH 251/317] Remove tf export stage from CI --- .gitlab-ci.yml | 46 +++++++++++---------------------------------- doc/docker_build.md | 14 +++++++------- 2 files changed, 18 insertions(+), 42 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d901fb58..ed233b14 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,6 @@ stages: - Test - Applications Test - Ship - - Export TensorFlow .docker_build_base: image: docker:latest @@ -152,7 +151,7 @@ ctest: stage: Applications Test extends: .tests_base needs: ["ctest"] - when: manual + #when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR @@ -236,8 +235,8 @@ nodata: .ship_base: extends: .docker_build_base - #only: - # - tags + only: + - tags variables: DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION @@ -265,11 +264,11 @@ deploy_cpu: --build-arg DEV_IMAGE=true . # push images on dockerhub - #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - #- docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU - #- docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV + - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + - docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU + - docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV # latest = cpu image - #- docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST + - docker tag $IMAGE_CPU $DOCKERHUB_LATEST && docker push $DOCKERHUB_LATEST deploy_gpu: stage: Ship @@ -297,31 +296,8 @@ deploy_gpu: --build-arg WITH_CUDA=true --build-arg DEV_IMAGE=true . # push gpu-* images on dockerhub - #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - #- docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU - #- docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV + - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + - docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU + - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image - #- docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST - -export_tf_wheels: - stage: Export TensorFlow - extends: .ship_base - #when: manual - artifacts: - paths: - - cpu-build-artifacts/ - - gpu-build-artifacts/ - script: - - > - docker buildx build --load - --target tf-build -t tf-build-cpu - --cache-from type=registry,ref=$CACHE_IMAGE_CPU - . - - docker run -v cpu-build-artifacts:/artifacts tf-build-cpu mv /tmp/artifacts/* /artifacts/ - - > - docker buildx build --load - --target tf-build -t tf-build-gpu - --cache-from type=registry,ref=$CACHE_IMAGE_GPU - --build-arg WITH_CUDA=true - . - - docker run -v gpu-build-artifacts:/artifacts tf-build-gpu mv /tmp/artifacts/* /artifacts/ + - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST && docker push $DOCKERHUB_GPULATEST diff --git a/doc/docker_build.md b/doc/docker_build.md index ccf4fc3f..50ee9c1c 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -83,35 +83,35 @@ docker build --network='host' -t otbtf:gpu \ . ``` -### Build for another machine and save TF compiled files +### Build only tensorflow C++ lib and python wheel to install outside of Docker ```bash -docker build --network='host' --target=tf-build -t otbtf:gpu \ +docker build --network='host' --target=tf-build -t tf:gpu \ --build-arg BZL_OPTIONS="--remote_cache=http://localhost:9090" \ --build-arg WITH_CUDA=true \ . # Target machine shell -docker run -v gpu-build-artifacts:/artifacts otbtf:gpu mv /tmp/artifacts /artifacts -sudo mv libtensorflow_cc* /usr/local/lib +docker run -v gpu-build-artifacts:/artifacts tf:gpu mv /tmp/artifacts /artifacts +cd gpu-build-artifacts +sudo mv libtensorflow_cc* /usr/local/lib # Or another path you may add to LD_LIBRARY_PATH # You may need to create a virtualenv, here TF and dependencies are installed # next to user's pip packages pip3 install -U pip wheel mock six future deprecated "numpy<2" pip3 install --no-deps keras_applications keras_preprocessing -cd gpu-build-artifacts pip3 install tensorflow-v2.18.0-cp310-cp310-linux_x86_64.whl TF_WHEEL_DIR="$HOME/.local/lib/python3.10/site-packages/tensorflow" # If you installed the wheel as regular user, with root pip it should be in # /usr/local/lib/python3.*, or in your virtualenv lib/ directory mv tag_constants.h signature_constants.h $TF_WHEEL_DIR/include/tensorflow/cc/saved_model/ -# From a OTB git source tree +# From an OTB git source tree # Recompile OTB with OTBTF using libraries in /opt/tensorflow/lib and # instructions in build_from_sources.md. cmake $OTB_GIT \ -DOTB_USE_TENSORFLOW=ON \ -DModule_OTBTensorflow=ON \ - -DTENSORFLOW_CC_LIB="/opt/tensorflow/lib/libtensorflow_cc.so.2" \ + -DTENSORFLOW_CC_LIB="/usr/local/lib/libtensorflow_cc.so.2" \ -Dtensorflow_include_dir="$TF_WHEEL_DIR/include" \ -DTENSORFLOW_FRAMEWORK_LIB="$TF_WHEEL_DIR/libtensorflow_framework.so.2" \ && make install -j -- GitLab From 9aae8f6a002595d7d25f875c6c42c00f025ba938 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 31 Oct 2024 12:45:34 +0100 Subject: [PATCH 252/317] Update CI config --- .gitlab-ci.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed233b14..0e584ef2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,4 @@ -variables: - DOCKER_BUILDKIT: 1 - BUILDX_BUILDER: container - BUILDX_NO_DEFAULT_ATTESTATIONS: 1 - OTBTF_VERSION: 4.4.0-rc1 - OTBTF_SRC: /src/otbtf # OTBTF source directory path in image - DATADIR: $CI_PROJECT_DIR/test/data - CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu - CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu - BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME - workflow: - auto_cancel: - on_new_commit: interruptible rules: # Execute on tags, MR or protected branches - if: $CI_COMMIT_TAG @@ -23,13 +10,8 @@ workflow: # Ignore pipeline for filthy commits - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i when: never - -default: - tags: [ godzilla ] - interruptible: true - image: - name: $BRANCH_IMAGE - pull_policy: always + auto_cancel: + on_new_commit: interruptible stages: - Build @@ -39,6 +21,24 @@ stages: - Applications Test - Ship +variables: + DOCKER_BUILDKIT: 1 + BUILDX_BUILDER: container + BUILDX_NO_DEFAULT_ATTESTATIONS: 1 + OTBTF_VERSION: 4.4.0-rc1 + OTBTF_SRC: /src/otbtf # OTBTF source directory path in image + DATADIR: $CI_PROJECT_DIR/test/data + CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu + CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu + BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + +default: + tags: [ godzilla ] + interruptible: true + image: + name: $BRANCH_IMAGE + pull_policy: always + .docker_build_base: image: docker:latest services: -- GitLab From 141e271cab7ca29c9f17a52ed6fc2594b6fed74f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 4 Nov 2024 17:57:25 +0100 Subject: [PATCH 253/317] Typo in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 128c55dd..b2cb2b5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # ---------------------------------------------------------------------------- # Init base stage - used for intermediate build env and final image -# Freeze ubuntu version to avoid suprise rebuild +# Freeze ubuntu version to avoid surprise rebuild FROM ubuntu:jammy-20240911.1 AS base-stage WORKDIR /tmp -- GitLab From fce4d4ff43c45a84dc568afe112d609454cd7e4f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 8 Nov 2024 16:11:13 +0100 Subject: [PATCH 254/317] Restore overlay2 driver variable --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e584ef2..abbca876 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,7 @@ stages: - Ship variables: + DOCKER_DRIVER: overlay2 DOCKER_BUILDKIT: 1 BUILDX_BUILDER: container BUILDX_NO_DEFAULT_ATTESTATIONS: 1 -- GitLab From 10e36edfcf7318879e3a2bbbb4a0f506ca3783de Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 8 Nov 2024 16:32:44 +0100 Subject: [PATCH 255/317] Freeze CI docker image versions and remove cache oci and image manifest opt --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index abbca876..a773991c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,9 +41,9 @@ default: pull_policy: always .docker_build_base: - image: docker:latest + image: docker:27.3.1 services: - - name: docker:dind + - name: docker:27.3.1-dind before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - docker buildx create --name=container --driver=docker-container --use --bootstrap @@ -60,7 +60,7 @@ docker_image: - > docker buildx build --push -t $BRANCH_IMAGE --cache-from type=registry,ref=$CACHE_IMAGE_CPU - --cache-to type=registry,ref=$CACHE_IMAGE_CPU,mode=max,oci-mediatypes=true,image-manifest=true + --cache-to type=registry,ref=$CACHE_IMAGE_CPU,mode=max --build-arg DEV_IMAGE=true "." @@ -286,7 +286,7 @@ deploy_gpu: docker buildx build --push -t $IMAGE_GPU --cache-from type=registry,ref=$CACHE_IMAGE_GPU --cache-from type=registry,ref=$CACHE_IMAGE_CPU - --cache-to type=registry,ref=$CACHE_IMAGE_GPU,mode=max,oci-mediatypes=true,image-manifest=true + --cache-to type=registry,ref=$CACHE_IMAGE_GPU,mode=max --build-arg WITH_CUDA=true . # gpu-dev -- GitLab From 72cf2fe0a8c831eb5dacc9a55a282de8c7666ef3 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 8 Nov 2024 17:28:12 +0100 Subject: [PATCH 256/317] Update dockerignore --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index acbfeefe..85bef574 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -.git +.git* Dockerfile **/__pycache__ .readthedocs.yaml -- GitLab From 226c9522f922252caf6623a5d82461026a9b95ba Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Sat, 9 Nov 2024 11:41:15 +0100 Subject: [PATCH 257/317] Test trigger CI --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a773991c..245ce795 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -152,7 +152,7 @@ ctest: stage: Applications Test extends: .tests_base needs: ["ctest"] - #when: manual + when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR -- GitLab From 4aa371c870e89ccb095be3a4dd9fd75efecd3adb Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Sat, 9 Nov 2024 11:46:49 +0100 Subject: [PATCH 258/317] Restore test apps --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 245ce795..a773991c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -152,7 +152,7 @@ ctest: stage: Applications Test extends: .tests_base needs: ["ctest"] - when: manual + #when: manual before_script: - mkdir -p $ARTIFACT_TEST_DIR -- GitLab From ce4cc7bc766299709bcedaea1c597885b3113bc9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 14 Nov 2024 14:50:22 +0100 Subject: [PATCH 259/317] Update py code for keras3 + remove useless encoding declaration --- otbtf/__init__.py | 1 - otbtf/dataset.py | 1 - otbtf/layers.py | 1 - otbtf/model.py | 1 - otbtf/tfrecords.py | 1 - otbtf/utils.py | 1 - test/api_unittest.py | 1 - test/geos_test.py | 2 -- test/imports_test.py | 2 -- test/models/model5.py | 19 +++++++++---------- test/nodata_test.py | 13 +++++-------- test/numpy_test.py | 2 -- test/pc_test.py | 2 -- test/rio_test.py | 2 -- test/sr4rs_unittest.py | 2 -- test/test_utils.py | 3 ++- test/tutorial_unittest.py | 1 - 17 files changed, 16 insertions(+), 39 deletions(-) diff --git a/otbtf/__init__.py b/otbtf/__init__.py index 1ce62422..649817ff 100644 --- a/otbtf/__init__.py +++ b/otbtf/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ========================================================================== # # Copyright 2018-2019 IRSTEA diff --git a/otbtf/dataset.py b/otbtf/dataset.py index cf2a0759..73ae88b9 100644 --- a/otbtf/dataset.py +++ b/otbtf/dataset.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ========================================================================== # # Copyright 2018-2019 IRSTEA diff --git a/otbtf/layers.py b/otbtf/layers.py index 028ba9a1..be2ec04c 100644 --- a/otbtf/layers.py +++ b/otbtf/layers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ========================================================================== # # Copyright 2018-2019 IRSTEA diff --git a/otbtf/model.py b/otbtf/model.py index 83013fff..205705fb 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ========================================================================== # # Copyright 2018-2019 IRSTEA diff --git a/otbtf/tfrecords.py b/otbtf/tfrecords.py index e5ac0841..8d2ce781 100644 --- a/otbtf/tfrecords.py +++ b/otbtf/tfrecords.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ========================================================================== # # Copyright 2018-2019 IRSTEA diff --git a/otbtf/utils.py b/otbtf/utils.py index 1c552fbd..66b43ca7 100644 --- a/otbtf/utils.py +++ b/otbtf/utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ========================================================================== # # Copyright 2018-2019 IRSTEA diff --git a/test/api_unittest.py b/test/api_unittest.py index 2fe3fe38..5fe06811 100644 --- a/test/api_unittest.py +++ b/test/api_unittest.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import unittest import pytest diff --git a/test/geos_test.py b/test/geos_test.py index 7b8b39f9..8cb36b4b 100644 --- a/test/geos_test.py +++ b/test/geos_test.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import pytest import unittest from osgeo import ogr diff --git a/test/imports_test.py b/test/imports_test.py index e745ed5b..0b75e8b8 100644 --- a/test/imports_test.py +++ b/test/imports_test.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import pytest import unittest class ImportsTest(unittest.TestCase): diff --git a/test/models/model5.py b/test/models/model5.py index cc17d52e..334d4f79 100644 --- a/test/models/model5.py +++ b/test/models/model5.py @@ -4,22 +4,21 @@ The input of this model must be a mono channel image. All 4 different output shapes supported in OTBTF are tested. """ -import tensorflow as tf +import keras # Input -x = tf.keras.Input(shape=[None, None, None], name="x") # [b, h, w, c=1] +x = keras.Input(shape=[None, None, None], name="x") # [b, h, w, c=1] # Create reshaped outputs -shape = tf.shape(x) +shape = keras.ops.shape(x) b = shape[0] h = shape[1] w = shape[2] -y1 = tf.reshape(x, shape=(b*h*w,)) # [b*h*w] -y2 = tf.reshape(x, shape=(b*h*w, 1)) # [b*h*w, 1] -y3 = tf.reshape(x, shape=(b, h, w)) # [b, h, w] -y4 = tf.reshape(x, shape=(b, h, w, 1)) # [b, h, w, 1] +y1 = keras.ops.reshape(x, shape=(b*h*w,)) # [b*h*w] +y2 = keras.ops.reshape(x, shape=(b*h*w, 1)) # [b*h*w, 1] +y3 = keras.ops.reshape(x, shape=(b, h, w)) # [b, h, w] +y4 = keras.ops.reshape(x, shape=(b, h, w, 1)) # [b, h, w, 1] # Create model -model = tf.keras.Model(inputs={"x": x}, outputs={"y1": y1, "y2": y2, "y3": y3, "y4": y4}) -model.save("model5") - +model = keras.Model(inputs={"x": x}, outputs={"y1": y1, "y2": y2, "y3": y3, "y4": y4}) +model.export("model5") diff --git a/test/nodata_test.py b/test/nodata_test.py index c3892153..32878f43 100644 --- a/test/nodata_test.py +++ b/test/nodata_test.py @@ -1,11 +1,8 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import otbApplication -import pytest -import tensorflow as tf +import keras import unittest -import otbtf from test_utils import resolve_paths, compare @@ -28,10 +25,10 @@ class NodataInferenceTest(unittest.TestCase): sm_dir = resolve_paths("$TMPDIR/l2_norm_savedmodel") # Create model - x = tf.keras.Input(shape=[None, None, None], name="x") - y = tf.norm(x, axis=-1) - model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}) - model.save(sm_dir) + x = keras.Input(shape=[None, None, None], name="x") + y = keras.ops.norm(x, axis=-1) + model = keras.Model(inputs={"x": x}, outputs={"y": y}) + model.export(sm_dir) # Input image: f(x, y) = x * y if x > y else 0 bmx = otbApplication.Registry.CreateApplication("BandMathX") diff --git a/test/numpy_test.py b/test/numpy_test.py index 55f0272c..0d45a47f 100644 --- a/test/numpy_test.py +++ b/test/numpy_test.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import pytest import unittest import otbApplication from osgeo import gdal diff --git a/test/pc_test.py b/test/pc_test.py index 34544d02..55a841d7 100644 --- a/test/pc_test.py +++ b/test/pc_test.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import pytest import unittest import planetary_computer import pystac_client diff --git a/test/rio_test.py b/test/rio_test.py index c6a0f2f1..99bb0d57 100644 --- a/test/rio_test.py +++ b/test/rio_test.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import pytest import unittest import rasterio import rasterio.features diff --git a/test/sr4rs_unittest.py b/test/sr4rs_unittest.py index 89c3945f..87d887dd 100644 --- a/test/sr4rs_unittest.py +++ b/test/sr4rs_unittest.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- - import unittest import os from pathlib import Path diff --git a/test/test_utils.py b/test/test_utils.py index 4554e28e..2d9ba9c4 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,7 +1,8 @@ -import otbApplication import os from pathlib import Path +import otbApplication + def get_nb_of_channels(raster): """ diff --git a/test/tutorial_unittest.py b/test/tutorial_unittest.py index af2b181c..886e017e 100644 --- a/test/tutorial_unittest.py +++ b/test/tutorial_unittest.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import pytest import unittest from test_utils import run_command, run_command_and_test_exist, run_command_and_compare -- GitLab From 2c6896e26c26a00997e57d6036b2ddb99da63268 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 14 Nov 2024 17:34:05 +0100 Subject: [PATCH 260/317] Try fix for invalid dict of named outputs --- otbtf/model.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/otbtf/model.py b/otbtf/model.py index 205705fb..cba70272 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -224,11 +224,18 @@ class ModelBase(abc.ABC): # Post-processing for inference postprocessed_outputs = self.postprocess_outputs( outputs=outputs, - inputs=inputs, + inputs=list(inputs.values()), normalized_inputs=normalized_inputs ) outputs.update(postprocessed_outputs) + # Dirty fix for Keras 3 : we can't pass a dict of outputs + # We need to wrap the last layer in a new layer with the desired name + outputs = [ + keras.layers.Lambda(lambda x: x, name=key)(prediction) + for key, prediction in outputs.items() + ] + # Return the keras model return keras.Model( inputs=inputs, -- GitLab From 24f2bd2676103a2994ed9c7065d5f73aceec293f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Thu, 14 Nov 2024 17:46:33 +0100 Subject: [PATCH 261/317] Use Identity layer instead of Lambda + name target layer for metrics --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 10 ++++++---- otbtf/model.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 7327f69f..0e9df694 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -196,10 +196,12 @@ def train(params, ds_train, ds_valid, ds_test): model.compile( loss=keras.losses.CategoricalCrossentropy(), optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), - metrics=[ - keras.metrics.Precision(class_id=1), - keras.metrics.Recall(class_id=1), - ], + metrics={ + TARGET_NAME: [ + keras.metrics.Precision(class_id=1), + keras.metrics.Recall(class_id=1), + ] + }, ) # Summarize the model (in CLI) diff --git a/otbtf/model.py b/otbtf/model.py index cba70272..1d5cad0b 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -232,7 +232,7 @@ class ModelBase(abc.ABC): # Dirty fix for Keras 3 : we can't pass a dict of outputs # We need to wrap the last layer in a new layer with the desired name outputs = [ - keras.layers.Lambda(lambda x: x, name=key)(prediction) + keras.layers.Identity(name=key)(prediction) for key, prediction in outputs.items() ] -- GitLab From 44db2df54f3f736d8416fc0d8880d0de8f023dcc Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Thu, 14 Nov 2024 23:11:43 +0100 Subject: [PATCH 262/317] Make sure to save all test artifacts --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a773991c..79c56bbf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -127,7 +127,7 @@ docs: reports: junit: report_*.xml paths: - - $ARTIFACT_TEST_DIR/*.* + - $ARTIFACT_TEST_DIR expire_in: 1 week when: on_failure @@ -164,7 +164,7 @@ crc_book: - mkdir -p $CRC_BOOK_TMP - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=report_tutorial.xml test/tutorial_unittest.py after_script: - - cp $CRC_BOOK_TMP/*.* $ARTIFACT_TEST_DIR/ + - cp -r $CRC_BOOK_TMP/* $ARTIFACT_TEST_DIR/ sr4rs: extends: .applications_test_base @@ -200,7 +200,7 @@ otbtf_api: - mkdir $API_TEST_TMP - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py after_script: - - cp $API_TEST_TMP/*.* $ARTIFACT_TEST_DIR/ + - cp -r $API_TEST_TMP/* $ARTIFACT_TEST_DIR/ geos_enabled: extends: .applications_test_base -- GitLab From 5babda34502c3f0e9126e6cb7111eb05a08db692 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 00:58:02 +0100 Subject: [PATCH 263/317] Drop missing keras_metadata.pb from file exists test, fix inputs dict --- .gitlab-ci.yml | 19 +++++++++---------- otbtf/model.py | 8 ++++---- test/api_unittest.py | 4 ++-- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79c56bbf..1d83f0af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -121,13 +121,9 @@ docs: .tests_base: only: - merge_requests - variables: - ARTIFACT_TEST_DIR: $CI_PROJECT_DIR/testing artifacts: reports: junit: report_*.xml - paths: - - $ARTIFACT_TEST_DIR expire_in: 1 week when: on_failure @@ -145,8 +141,9 @@ ctest: - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD - ctest -L $OTB_TEST_UNITS --output-junit $CI_PROJECT_DIR/report_ctest.xml - after_script: - - cp -r $OTB_BUILD/Testing/Temporary $ARTIFACT_TEST_DIR + artifacts: + paths: + - $OTB_BUILD/Testing/Temporary .applications_test_base: stage: Applications Test @@ -163,8 +160,9 @@ crc_book: script: - mkdir -p $CRC_BOOK_TMP - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=report_tutorial.xml test/tutorial_unittest.py - after_script: - - cp -r $CRC_BOOK_TMP/* $ARTIFACT_TEST_DIR/ + artifacts: + paths: + - $CRC_BOOK_TMP sr4rs: extends: .applications_test_base @@ -199,8 +197,9 @@ otbtf_api: script: - mkdir $API_TEST_TMP - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py - after_script: - - cp -r $API_TEST_TMP/* $ARTIFACT_TEST_DIR/ + artifacts: + paths: + - $API_TEST_TMP geos_enabled: extends: .applications_test_base diff --git a/otbtf/model.py b/otbtf/model.py index 1d5cad0b..d471c6c7 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -224,7 +224,7 @@ class ModelBase(abc.ABC): # Post-processing for inference postprocessed_outputs = self.postprocess_outputs( outputs=outputs, - inputs=list(inputs.values()), + inputs=inputs, normalized_inputs=normalized_inputs ) outputs.update(postprocessed_outputs) @@ -232,14 +232,14 @@ class ModelBase(abc.ABC): # Dirty fix for Keras 3 : we can't pass a dict of outputs # We need to wrap the last layer in a new layer with the desired name outputs = [ - keras.layers.Identity(name=key)(prediction) - for key, prediction in outputs.items() + keras.layers.Identity(name=key)(layer) + for key, layer in outputs.items() ] # Return the keras model return keras.Model( inputs=inputs, - outputs=outputs, + outputs=list(outputs.values()), name=self.__class__.__name__ ) diff --git a/test/api_unittest.py b/test/api_unittest.py index 5fe06811..5103b8d3 100644 --- a/test/api_unittest.py +++ b/test/api_unittest.py @@ -32,7 +32,7 @@ class APITest(unittest.TestCase): ]) train_from_patchesimages.train(params=params) self.assertTrue(files_exist([ - '$TMPDIR/model_from_pimg/keras_metadata.pb', + '$TMPDIR/model_from_pimg/fingerprint.pb', '$TMPDIR/model_from_pimg/saved_model.pb', '$TMPDIR/model_from_pimg/variables/variables.data-00000-of-00001', '$TMPDIR/model_from_pimg/variables/variables.index' @@ -109,7 +109,7 @@ class APITest(unittest.TestCase): ]) train_from_tfrecords.train(params=params) self.assertTrue(files_exist([ - '$TMPDIR/model_from_tfrecs/keras_metadata.pb', + '$TMPDIR/model_from_tfrecs/fingerprint.pb', '$TMPDIR/model_from_tfrecs/saved_model.pb', '$TMPDIR/model_from_tfrecs/variables/variables.data-00000-of-00001', '$TMPDIR/model_from_tfrecs/variables/variables.index' -- GitLab From 36d477278079506a093ffa941b4db09de7ec6a60 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 01:04:08 +0100 Subject: [PATCH 264/317] Drop common artifacts test dir --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d83f0af..c9bb5471 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -150,8 +150,6 @@ ctest: extends: .tests_base needs: ["ctest"] #when: manual - before_script: - - mkdir -p $ARTIFACT_TEST_DIR crc_book: extends: .applications_test_base -- GitLab From f35bb7751e89d0ee839c7ee918a7acee329050aa Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 01:15:10 +0100 Subject: [PATCH 265/317] Update tests, drop imports_tests.py --- .gitlab-ci.yml | 15 ++++++--------- otbtf/model.py | 2 +- test/imports_test.py | 32 -------------------------------- 3 files changed, 7 insertions(+), 42 deletions(-) delete mode 100644 test/imports_test.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9bb5471..0b148d50 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,16 +22,16 @@ stages: - Ship variables: - DOCKER_DRIVER: overlay2 - DOCKER_BUILDKIT: 1 - BUILDX_BUILDER: container - BUILDX_NO_DEFAULT_ATTESTATIONS: 1 OTBTF_VERSION: 4.4.0-rc1 OTBTF_SRC: /src/otbtf # OTBTF source directory path in image DATADIR: $CI_PROJECT_DIR/test/data CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + DOCKER_DRIVER: overlay2 + DOCKER_BUILDKIT: 1 + BUILDX_BUILDER: container + BUILDX_NO_DEFAULT_ATTESTATIONS: 1 default: tags: [ godzilla ] @@ -153,6 +153,7 @@ ctest: crc_book: extends: .applications_test_base + allow_failure: true variables: CRC_BOOK_TMP: /tmp/crc_book_tests_tmp script: @@ -179,6 +180,7 @@ sr4rs: decloud: extends: .applications_test_base + allow_failure: true variables: DATASET_DECLOUD: https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download script: @@ -210,11 +212,6 @@ planetary_computer: - pip install pystac_client planetary_computer - python -m pytest --junitxml=report_pc_enabled.xml test/pc_test.py -imports: - extends: .applications_test_base - script: - - python -m pytest --junitxml=report_imports.xml test/imports_test.py - numpy_gdal_otb: extends: .applications_test_base script: diff --git a/otbtf/model.py b/otbtf/model.py index d471c6c7..04bc8a5c 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -239,7 +239,7 @@ class ModelBase(abc.ABC): # Return the keras model return keras.Model( inputs=inputs, - outputs=list(outputs.values()), + outputs=outputs, name=self.__class__.__name__ ) diff --git a/test/imports_test.py b/test/imports_test.py deleted file mode 100644 index 0b75e8b8..00000000 --- a/test/imports_test.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -import unittest - -class ImportsTest(unittest.TestCase): - - def test_import_both1(self): - import tensorflow - self.assertTrue(tensorflow.__version__) - import otbApplication - self.assertTrue(otbApplication.Registry_GetAvailableApplications()) - - - def test_import_both2(self): - import otbApplication - self.assertTrue(otbApplication.Registry_GetAvailableApplications()) - import tensorflow - self.assertTrue(tensorflow.__version__) - - - def test_import_all(self): - import otbApplication - self.assertTrue(otbApplication.Registry_GetAvailableApplications()) - import tensorflow - self.assertTrue(tensorflow.__version__) - from osgeo import gdal - self.assertTrue(gdal.__version__) - import numpy - self.assertTrue(numpy.__version__) - - -if __name__ == '__main__': - unittest.main() -- GitLab From 022409944c6dce424d27b5ab806d3211837f97ef Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 01:27:19 +0100 Subject: [PATCH 266/317] Fix normalize inputs line length --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 0e9df694..8b4f502e 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -53,7 +53,10 @@ class FCNNModel(ModelBase): Returns: dict of normalized inputs, ready to be used from `get_outputs()` """ - return {INPUT_NAME: keras.ops.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} + return { + key: keras.ops.cast(layer, tf.float32) * 0.0001 + for key, layer in inputs.items() + } def get_outputs(self, normalized_inputs: dict) -> dict: """ -- GitLab From 08b2b88352e8d05f4d0c9fe94b0ed8b405acfe21 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 01:28:07 +0100 Subject: [PATCH 267/317] Try fix for out tensors names --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 2 +- otbtf/model.py | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 8b4f502e..b55e7088 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -200,7 +200,7 @@ def train(params, ds_train, ds_valid, ds_test): loss=keras.losses.CategoricalCrossentropy(), optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ - TARGET_NAME: [ + OUTPUT_SOFTMAX_NAME: [ keras.metrics.Precision(class_id=1), keras.metrics.Recall(class_id=1), ] diff --git a/otbtf/model.py b/otbtf/model.py index 04bc8a5c..5a493430 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -229,17 +229,10 @@ class ModelBase(abc.ABC): ) outputs.update(postprocessed_outputs) - # Dirty fix for Keras 3 : we can't pass a dict of outputs - # We need to wrap the last layer in a new layer with the desired name - outputs = [ - keras.layers.Identity(name=key)(layer) - for key, layer in outputs.items() - ] - # Return the keras model return keras.Model( inputs=inputs, - outputs=outputs, + outputs=list(outputs.values()), name=self.__class__.__name__ ) -- GitLab From ce2be35f8de1ec4b961036828a46abcf1831c9ec Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 01:40:30 +0100 Subject: [PATCH 268/317] Test API first, then applications --- .gitlab-ci.yml | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b148d50..b0893651 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -145,10 +145,22 @@ ctest: paths: - $OTB_BUILD/Testing/Temporary +otbtf_api: + stage: Test + extends: .tests_base + variables: + API_TEST_TMP: /tmp/api_tests_tmp + script: + - mkdir $API_TEST_TMP + - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py + artifacts: + paths: + - $API_TEST_TMP + .applications_test_base: stage: Applications Test extends: .tests_base - needs: ["ctest"] + needs: ["ctest", "otbtf_api"] #when: manual crc_book: @@ -163,21 +175,6 @@ crc_book: paths: - $CRC_BOOK_TMP -sr4rs: - extends: .applications_test_base - variables: - DATASET_S2: https://nextcloud.inrae.fr/s/EZL2JN7SZyDK8Cf/download/sr4rs_sentinel2_bands4328_france2020_savedmodel.zip - DATASET_SR4RS: https://nextcloud.inrae.fr/s/kDms9JrRMQE2Q5z/download - script: - - wget -qO sr4rs_sentinel2_bands4328_france2020_savedmodel.zip $DATASET_S2 - - unzip -o sr4rs_sentinel2_bands4328_france2020_savedmodel.zip - - wget -qO sr4rs_data.zip $DATASET_SR4RS - - unzip -o sr4rs_data.zip - - rm -rf sr4rs - - git clone https://github.com/remicres/sr4rs.git - - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs - - python -m pytest --junitxml=report_sr4rs.xml test/sr4rs_unittest.py - decloud: extends: .applications_test_base allow_failure: true @@ -190,16 +187,20 @@ decloud: - export DECLOUD_DATA_DIR="$PWD/decloud_data" - pytest decloud/tests/train_from_tfrecords_unittest.py -otbtf_api: +sr4rs: extends: .applications_test_base variables: - API_TEST_TMP: /tmp/api_tests_tmp + DATASET_S2: https://nextcloud.inrae.fr/s/EZL2JN7SZyDK8Cf/download/sr4rs_sentinel2_bands4328_france2020_savedmodel.zip + DATASET_SR4RS: https://nextcloud.inrae.fr/s/kDms9JrRMQE2Q5z/download script: - - mkdir $API_TEST_TMP - - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py - artifacts: - paths: - - $API_TEST_TMP + - wget -qO sr4rs_sentinel2_bands4328_france2020_savedmodel.zip $DATASET_S2 + - unzip -o sr4rs_sentinel2_bands4328_france2020_savedmodel.zip + - wget -qO sr4rs_data.zip $DATASET_SR4RS + - unzip -o sr4rs_data.zip + - rm -rf sr4rs + - git clone https://github.com/remicres/sr4rs.git + - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs + - python -m pytest --junitxml=report_sr4rs.xml test/sr4rs_unittest.py geos_enabled: extends: .applications_test_base -- GitLab From 3a0d78c4771defbfd49465c0dd9bdcb401ae12ec Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 01:40:40 +0100 Subject: [PATCH 269/317] Format --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index b55e7088..0cf92d59 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -198,7 +198,9 @@ def train(params, ds_train, ds_valid, ds_test): # useless outputs (e.g. metrics computed over extra outputs). model.compile( loss=keras.losses.CategoricalCrossentropy(), - optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), + optimizer=keras.optimizers.Adam( + learning_rate=params.learning_rate + ), metrics={ OUTPUT_SOFTMAX_NAME: [ keras.metrics.Precision(class_id=1), -- GitLab From 69f21c513fc67d62eee2a505dc5494b9160aa5e7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 09:09:01 +0100 Subject: [PATCH 270/317] Try show placeholders in CI logs --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b0893651..571a5487 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -153,6 +153,7 @@ otbtf_api: script: - mkdir $API_TEST_TMP - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py + - saved_model_cli show --dir $API_TEST_TMP/model_from_pimg --all artifacts: paths: - $API_TEST_TMP -- GitLab From db598651da9cf355f02c663932c809f3ffdae3be Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@gmail.com> Date: Fri, 15 Nov 2024 09:22:18 +0100 Subject: [PATCH 271/317] Fix artifacts --- .gitlab-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 571a5487..de50cc30 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -141,9 +141,11 @@ ctest: - ln -s $CI_PROJECT_DIR/test/models $OTBTF_SRC/test/models - cd $OTB_BUILD - ctest -L $OTB_TEST_UNITS --output-junit $CI_PROJECT_DIR/report_ctest.xml + after_script: + - cp -r $OTB_BUILD/Testing/Temporary/* $CI_PROJECT_DIR/artifacts_ctest artifacts: paths: - - $OTB_BUILD/Testing/Temporary + - $CI_PROJECT_DIR/artifacts_ctest otbtf_api: stage: Test @@ -153,10 +155,12 @@ otbtf_api: script: - mkdir $API_TEST_TMP - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py + after_script: - saved_model_cli show --dir $API_TEST_TMP/model_from_pimg --all + - cp -r $API_TEST_TMP $CI_PROJECT_DIR/artifacts_test_api artifacts: paths: - - $API_TEST_TMP + - $CI_PROJECT_DIR/artifacts_test_api .applications_test_base: stage: Applications Test @@ -172,9 +176,11 @@ crc_book: script: - mkdir -p $CRC_BOOK_TMP - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=report_tutorial.xml test/tutorial_unittest.py + after_script: + - cp -r $CRC_BOOK_TMP $CI_PROJECT_DIR/artifacts_crc_book artifacts: paths: - - $CRC_BOOK_TMP + - $CI_PROJECT_DIR/artifacts_crc_book decloud: extends: .applications_test_base -- GitLab From 30b3ac6ed3c13ebe4667d25d383a6b85102841e8 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 10:52:17 +0100 Subject: [PATCH 272/317] Try with a list of outputs --- .../tensorflow_v2x/fcnn/fcnn_model.py | 40 ++++----- otbtf/model.py | 82 ++++++++----------- 2 files changed, 51 insertions(+), 71 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 0cf92d59..dbe5bb72 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -7,7 +7,7 @@ import logging import tensorflow as tf import keras -from otbtf.model import ModelBase +from otbtf.model import ModelBase, Tensor, TensorsList, TensorsDict logging.basicConfig( format="%(asctime)s %(levelname)-8s %(message)s", @@ -22,11 +22,8 @@ N_CLASSES = 2 # in the SavedModel INPUT_NAME = "input_xs" -# Name of the output in the `FCNNModel` instance -TARGET_NAME = "predictions" - # Name (prefix) of the output node in the SavedModel -OUTPUT_SOFTMAX_NAME = "predictions_softmax_tensor" +OUTPUT_SOFTMAX_NAME = "predictions_softmax" class FCNNModel(ModelBase): @@ -58,7 +55,7 @@ class FCNNModel(ModelBase): for key, layer in inputs.items() } - def get_outputs(self, normalized_inputs: dict) -> dict: + def get_outputs(self, normalized_inputs: TensorsDict) -> Tensor | TensorsList: """ Inherits from `ModelBase` @@ -114,33 +111,28 @@ class FCNNModel(ModelBase): # the `saved_model_cli show --dir /path/to/your/savedmodel --all` # command. # - # Do not confuse **the name of the output layers** (i.e. the "name" - # property of the keras.layer that is used to generate an output - # tensor) and **the key of the output tensor**, in the dict returned - # from `MyModel.get_output()`. They are two identifiers with a - # different purpose: - # - the output layer name is used only at inference time, to identify - # the output tensor from which generate the output image, - # - the output tensor key identifies the output tensors, mainly to - # fit the targets to model outputs during training process, but it - # can also be used to access the tensors as tf/keras objects, for - # instance to display previews images in TensorBoard. + # Since TF 2.18, there are no distinction between output tensor name + # and output keys. You must use tensor names to specify outputs, + # or target for metrics. + # You can't pass a dict of named outputs when building the model, + # instead you must ensure you're using the right names + # when adding layers to your model softmax_op = keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) predictions = softmax_op(out_tconv4) - # note that we could also add additional outputs, for instance the - # argmax of the softmax: + # Note that we could also add additional outputs + # and return a list, for instance the argmax of the softmax: # # argmax_op = otbtf.layers.Argmax(name="labels") # labels = argmax_op(predictions) - # return {TARGET_NAME: predictions, OUTPUT_ARGMAX_NAME: labels} + # return [predictions, labels] # The default extra outputs (i.e. output tensors with cropping in # physical domain) are append by `otbtf.ModelBase` for all returned # outputs of this function to be used at inference time (e.g. # "labels_crop32", "labels_crop64", ..., # "predictions_softmax_tensor_crop16", ..., etc). - return {TARGET_NAME: predictions} + return predictions def dataset_preprocessing_fn(examples: dict): @@ -163,7 +155,7 @@ def dataset_preprocessing_fn(examples: dict): """ return { INPUT_NAME: examples["input_xs_patches"], - TARGET_NAME: keras.ops.one_hot( + OUTPUT_SOFTMAX_NAME: keras.ops.one_hot( keras.ops.squeeze( keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1 ), @@ -198,9 +190,7 @@ def train(params, ds_train, ds_valid, ds_test): # useless outputs (e.g. metrics computed over extra outputs). model.compile( loss=keras.losses.CategoricalCrossentropy(), - optimizer=keras.optimizers.Adam( - learning_rate=params.learning_rate - ), + optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ OUTPUT_SOFTMAX_NAME: [ keras.metrics.Precision(class_id=1), diff --git a/otbtf/model.py b/otbtf/model.py index 5a493430..f2b5e930 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -29,6 +29,7 @@ import tensorflow as tf import keras Tensor = Any +TensorsList = List[Tensor] TensorsDict = Dict[str, Tensor] @@ -38,10 +39,10 @@ class ModelBase(abc.ABC): """ def __init__( - self, - dataset_element_spec: tf.TensorSpec, - input_keys: List[str] = None, - inference_cropping: List[int] = None + self, + dataset_element_spec: tf.TensorSpec, + input_keys: List[str] = None, + inference_cropping: List[int] = None, ): """ Model initializer, must be called **inside** the strategy.scope(). @@ -60,18 +61,14 @@ class ModelBase(abc.ABC): """ # Retrieve dataset inputs shapes dataset_input_element_spec = dataset_element_spec[0] - logging.info( - "Dataset input element spec: %s", dataset_input_element_spec - ) + logging.info("Dataset input element spec: %s", dataset_input_element_spec) if input_keys: self.dataset_input_keys = input_keys logging.info("Using input keys: %s", self.dataset_input_keys) else: self.dataset_input_keys = list(dataset_input_element_spec) - logging.info( - "Found dataset input keys: %s", self.dataset_input_keys - ) + logging.info("Found dataset input keys: %s", self.dataset_input_keys) self.inputs_shapes = { key: dataset_input_element_spec[key].shape[1:] @@ -122,7 +119,7 @@ class ModelBase(abc.ABC): return model_inputs @abc.abstractmethod - def get_outputs(self, normalized_inputs: TensorsDict) -> TensorsDict: + def get_outputs(self, normalized_inputs: TensorsDict) -> Tensor | TensorsList: """ Implementation of the model, from the normalized inputs. @@ -158,14 +155,14 @@ class ModelBase(abc.ABC): return inputs def postprocess_outputs( - self, - outputs: TensorsDict, - inputs: TensorsDict = None, - normalized_inputs: TensorsDict = None - ) -> TensorsDict: + self, + outputs: Tensor | list[Tensor], + inputs: TensorsDict = None, + normalized_inputs: TensorsDict = None, + ) -> Tensor | TensorsList: """ Post-process the model outputs. - Takes the dicts of inputs and outputs, and returns a dict of + Takes the dicts of inputs and list of outputs, and returns a list of post-processed outputs. The default implementation provides a set of cropped output tensors. @@ -175,29 +172,28 @@ class ModelBase(abc.ABC): normalized_inputs: dict of normalized model inputs (optional) Returns: - a dict of post-processed model outputs + a list of post-processed model named outputs """ + if not isinstance(outputs, list): + outputs = [outputs] # Add extra outputs for inference - extra_outputs = {} - for out_key, out_tensor in outputs.items(): + for out_tensor in outputs: for crop in self.inference_cropping: - extra_output_key = cropped_tensor_name(out_key, crop) - extra_output_name = cropped_tensor_name( + name = cropped_tensor_name( out_tensor._keras_history.operation.name, crop ) logging.info( - "Adding extra output for tensor %s with crop %s (%s)", - out_key, crop, extra_output_name + "Adding extra output for tensor %s with crop %s", + name, + crop, ) cropped = out_tensor[:, crop:-crop, crop:-crop, :] - identity = keras.layers.Activation( - 'linear', name=extra_output_name - ) - extra_outputs[extra_output_key] = identity(cropped) + identity = keras.layers.Activation("linear", name=name) + outputs.append(identity(cropped)) - return extra_outputs + return outputs def create_network(self) -> keras.Model: """ @@ -222,19 +218,12 @@ class ModelBase(abc.ABC): logging.info("Model outputs: %s", outputs) # Post-processing for inference - postprocessed_outputs = self.postprocess_outputs( - outputs=outputs, - inputs=inputs, - normalized_inputs=normalized_inputs + outputs = self.postprocess_outputs( + outputs=outputs, inputs=inputs, normalized_inputs=normalized_inputs ) - outputs.update(postprocessed_outputs) # Return the keras model - return keras.Model( - inputs=inputs, - outputs=list(outputs.values()), - name=self.__class__.__name__ - ) + return keras.Model(inputs=inputs, outputs=outputs, name=self.__class__.__name__) def summary(self, strategy=None): """ @@ -260,14 +249,13 @@ class ModelBase(abc.ABC): show_shapes: annotate with shapes values (True or False) """ - assert self.model, "Plot() only works if create_network() has been " \ - "called beforehand" + assert self.model, ( + "Plot() only works if create_network() has been " "called beforehand" + ) # When multiworker strategy, only plot if the worker is chief if not strategy or _is_chief(strategy): - keras.utils.plot_model( - self.model, output_path, show_shapes=show_shapes - ) + keras.utils.plot_model(self.model, output_path, show_shapes=show_shapes) def _is_chief(strategy): @@ -294,9 +282,11 @@ def _is_chief(strategy): if strategy.cluster_resolver: # this means MultiWorkerMirroredStrategy task_type = strategy.cluster_resolver.task_type task_id = strategy.cluster_resolver.task_id - return (task_type == 'chief') \ - or (task_type == 'worker' and task_id == 0) \ + return ( + (task_type == "chief") + or (task_type == "worker" and task_id == 0) or task_type is None + ) # strategy with only one worker return True -- GitLab From e7ed006a9dc9c2cd7dca78de63edef67bcf4def9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 10:57:21 +0100 Subject: [PATCH 273/317] Fix missing var TARGET_NAME --- otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py | 2 +- otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py b/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py index 9dab4b9b..3d4fd9ae 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py @@ -90,7 +90,7 @@ def create_dataset( tf_ds = dataset.get_tf_dataset( batch_size=batch_size, preprocessing_fn=fcnn_model.dataset_preprocessing_fn, - targets_keys=targets_keys or [fcnn_model.TARGET_NAME] + targets_keys=targets_keys or [fcnn_model.OUTPUT_SOFTMAX_NAME] ) return tf_ds diff --git a/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py b/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py index caf15a79..52cfe574 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py @@ -51,7 +51,7 @@ def train(params): kwargs = { "batch_size": params.batch_size, - "target_keys": [fcnn_model.TARGET_NAME], + "target_keys": [fcnn_model.OUTPUT_SOFTMAX_NAME], "preprocessing_fn": fcnn_model.dataset_preprocessing_fn } -- GitLab From 8e16fc859dd5487fde578d908a55bfb436a3ca92 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 11:33:42 +0100 Subject: [PATCH 274/317] Pytest verbose --- .gitlab-ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de50cc30..4df3a422 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -154,7 +154,7 @@ otbtf_api: API_TEST_TMP: /tmp/api_tests_tmp script: - mkdir $API_TEST_TMP - - TMPDIR=$API_TEST_TMP python -m pytest --junitxml=report_api.xml test/api_unittest.py + - TMPDIR=$API_TEST_TMP python -m pytest -vv --junitxml=report_api.xml test/api_unittest.py after_script: - saved_model_cli show --dir $API_TEST_TMP/model_from_pimg --all - cp -r $API_TEST_TMP $CI_PROJECT_DIR/artifacts_test_api @@ -175,7 +175,7 @@ crc_book: CRC_BOOK_TMP: /tmp/crc_book_tests_tmp script: - mkdir -p $CRC_BOOK_TMP - - TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=report_tutorial.xml test/tutorial_unittest.py + - TMPDIR=$CRC_BOOK_TMP python -m pytest -vv --junitxml=report_tutorial.xml test/tutorial_unittest.py after_script: - cp -r $CRC_BOOK_TMP $CI_PROJECT_DIR/artifacts_crc_book artifacts: @@ -192,7 +192,7 @@ decloud: - pip install -r $PWD/decloud/docker/requirements.txt - wget -q $DATASET_DECLOUD -O file.zip && unzip file.zip - export DECLOUD_DATA_DIR="$PWD/decloud_data" - - pytest decloud/tests/train_from_tfrecords_unittest.py + - pytest -vv decloud/tests/train_from_tfrecords_unittest.py sr4rs: extends: .applications_test_base @@ -207,34 +207,34 @@ sr4rs: - rm -rf sr4rs - git clone https://github.com/remicres/sr4rs.git - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs - - python -m pytest --junitxml=report_sr4rs.xml test/sr4rs_unittest.py + - python -m pytest -vv --junitxml=report_sr4rs.xml test/sr4rs_unittest.py geos_enabled: extends: .applications_test_base script: - - python -m pytest --junitxml=report_geos_enabled.xml test/geos_test.py + - python -m pytest -vv --junitxml=report_geos_enabled.xml test/geos_test.py planetary_computer: extends: .applications_test_base script: - pip install pystac_client planetary_computer - - python -m pytest --junitxml=report_pc_enabled.xml test/pc_test.py + - python -m pytest -vv --junitxml=report_pc_enabled.xml test/pc_test.py numpy_gdal_otb: extends: .applications_test_base script: - - python -m pytest --junitxml=report_numpy.xml test/numpy_test.py + - python -m pytest -vv --junitxml=report_numpy.xml test/numpy_test.py rio: extends: .applications_test_base script: - pip install rasterio --no-binary rasterio - - python -m pytest --junitxml=report_rio.xml test/rio_test.py + - python -m pytest -vv --junitxml=report_rio.xml test/rio_test.py nodata: extends: .applications_test_base script: - - python -m pytest --junitxml=report_nodata.xml test/nodata_test.py + - python -m pytest -vv --junitxml=report_nodata.xml test/nodata_test.py .ship_base: extends: .docker_build_base -- GitLab From 9431ffd982f8c1bdb6ee7ee1d2e038fa8ca872d0 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 11:46:11 +0100 Subject: [PATCH 275/317] Try update get_outputs --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 4 ++-- otbtf/model.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index dbe5bb72..d73fd30b 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -55,7 +55,7 @@ class FCNNModel(ModelBase): for key, layer in inputs.items() } - def get_outputs(self, normalized_inputs: TensorsDict) -> Tensor | TensorsList: + def get_outputs(self, normalized_inputs: TensorsDict) -> TensorsList: """ Inherits from `ModelBase` @@ -132,7 +132,7 @@ class FCNNModel(ModelBase): # "labels_crop32", "labels_crop64", ..., # "predictions_softmax_tensor_crop16", ..., etc). - return predictions + return [predictions] def dataset_preprocessing_fn(examples: dict): diff --git a/otbtf/model.py b/otbtf/model.py index f2b5e930..a17c161e 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -214,13 +214,11 @@ class ModelBase(abc.ABC): logging.info("Normalized model inputs: %s", normalized_inputs) # Build the model - outputs = self.get_outputs(normalized_inputs=normalized_inputs) + outputs = self.get_outputs(normalized_inputs) logging.info("Model outputs: %s", outputs) # Post-processing for inference - outputs = self.postprocess_outputs( - outputs=outputs, inputs=inputs, normalized_inputs=normalized_inputs - ) + outputs = self.postprocess_outputs(outputs, inputs, normalized_inputs) # Return the keras model return keras.Model(inputs=inputs, outputs=outputs, name=self.__class__.__name__) -- GitLab From 6f8550d03252ff26ede4b14af11e39b59bb81208 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 13:33:59 +0100 Subject: [PATCH 276/317] Try to see test outputs in real time --- .gitlab-ci.yml | 18 +++++++++--------- .../examples/tensorflow_v2x/fcnn/fcnn_model.py | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4df3a422..ac1bec00 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -154,7 +154,7 @@ otbtf_api: API_TEST_TMP: /tmp/api_tests_tmp script: - mkdir $API_TEST_TMP - - TMPDIR=$API_TEST_TMP python -m pytest -vv --junitxml=report_api.xml test/api_unittest.py + - TMPDIR=$API_TEST_TMP python -m pytest -svv --junitxml=report_api.xml test/api_unittest.py after_script: - saved_model_cli show --dir $API_TEST_TMP/model_from_pimg --all - cp -r $API_TEST_TMP $CI_PROJECT_DIR/artifacts_test_api @@ -175,7 +175,7 @@ crc_book: CRC_BOOK_TMP: /tmp/crc_book_tests_tmp script: - mkdir -p $CRC_BOOK_TMP - - TMPDIR=$CRC_BOOK_TMP python -m pytest -vv --junitxml=report_tutorial.xml test/tutorial_unittest.py + - TMPDIR=$CRC_BOOK_TMP python -m pytest -v --junitxml=report_tutorial.xml test/tutorial_unittest.py after_script: - cp -r $CRC_BOOK_TMP $CI_PROJECT_DIR/artifacts_crc_book artifacts: @@ -192,7 +192,7 @@ decloud: - pip install -r $PWD/decloud/docker/requirements.txt - wget -q $DATASET_DECLOUD -O file.zip && unzip file.zip - export DECLOUD_DATA_DIR="$PWD/decloud_data" - - pytest -vv decloud/tests/train_from_tfrecords_unittest.py + - pytest -v decloud/tests/train_from_tfrecords_unittest.py sr4rs: extends: .applications_test_base @@ -207,34 +207,34 @@ sr4rs: - rm -rf sr4rs - git clone https://github.com/remicres/sr4rs.git - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs - - python -m pytest -vv --junitxml=report_sr4rs.xml test/sr4rs_unittest.py + - python -m pytest -v --junitxml=report_sr4rs.xml test/sr4rs_unittest.py geos_enabled: extends: .applications_test_base script: - - python -m pytest -vv --junitxml=report_geos_enabled.xml test/geos_test.py + - python -m pytest -v --junitxml=report_geos_enabled.xml test/geos_test.py planetary_computer: extends: .applications_test_base script: - pip install pystac_client planetary_computer - - python -m pytest -vv --junitxml=report_pc_enabled.xml test/pc_test.py + - python -m pytest -v --junitxml=report_pc_enabled.xml test/pc_test.py numpy_gdal_otb: extends: .applications_test_base script: - - python -m pytest -vv --junitxml=report_numpy.xml test/numpy_test.py + - python -m pytest -v --junitxml=report_numpy.xml test/numpy_test.py rio: extends: .applications_test_base script: - pip install rasterio --no-binary rasterio - - python -m pytest -vv --junitxml=report_rio.xml test/rio_test.py + - python -m pytest -v --junitxml=report_rio.xml test/rio_test.py nodata: extends: .applications_test_base script: - - python -m pytest -vv --junitxml=report_nodata.xml test/nodata_test.py + - python -m pytest -v --junitxml=report_nodata.xml test/nodata_test.py .ship_base: extends: .docker_build_base diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index d73fd30b..709cc907 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -132,7 +132,7 @@ class FCNNModel(ModelBase): # "labels_crop32", "labels_crop64", ..., # "predictions_softmax_tensor_crop16", ..., etc). - return [predictions] + return predictions def dataset_preprocessing_fn(examples: dict): @@ -188,6 +188,7 @@ def train(params, ds_train, ds_valid, ds_test): # over which the losses/metrics are computed. # This ensures a better optimization control, and also avoids lots of # useless outputs (e.g. metrics computed over extra outputs). + print("Compiling model...") model.compile( loss=keras.losses.CategoricalCrossentropy(), optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), -- GitLab From 8b03d9128560c2e67ea822d7092dc579158763c9 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 15:05:02 +0100 Subject: [PATCH 277/317] Reset previous state --- .../tensorflow_v2x/fcnn/fcnn_model.py | 44 +++++---- otbtf/model.py | 91 +++++++++++-------- 2 files changed, 79 insertions(+), 56 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 709cc907..0e9df694 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -7,7 +7,7 @@ import logging import tensorflow as tf import keras -from otbtf.model import ModelBase, Tensor, TensorsList, TensorsDict +from otbtf.model import ModelBase logging.basicConfig( format="%(asctime)s %(levelname)-8s %(message)s", @@ -22,8 +22,11 @@ N_CLASSES = 2 # in the SavedModel INPUT_NAME = "input_xs" +# Name of the output in the `FCNNModel` instance +TARGET_NAME = "predictions" + # Name (prefix) of the output node in the SavedModel -OUTPUT_SOFTMAX_NAME = "predictions_softmax" +OUTPUT_SOFTMAX_NAME = "predictions_softmax_tensor" class FCNNModel(ModelBase): @@ -50,12 +53,9 @@ class FCNNModel(ModelBase): Returns: dict of normalized inputs, ready to be used from `get_outputs()` """ - return { - key: keras.ops.cast(layer, tf.float32) * 0.0001 - for key, layer in inputs.items() - } + return {INPUT_NAME: keras.ops.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} - def get_outputs(self, normalized_inputs: TensorsDict) -> TensorsList: + def get_outputs(self, normalized_inputs: dict) -> dict: """ Inherits from `ModelBase` @@ -111,28 +111,33 @@ class FCNNModel(ModelBase): # the `saved_model_cli show --dir /path/to/your/savedmodel --all` # command. # - # Since TF 2.18, there are no distinction between output tensor name - # and output keys. You must use tensor names to specify outputs, - # or target for metrics. - # You can't pass a dict of named outputs when building the model, - # instead you must ensure you're using the right names - # when adding layers to your model + # Do not confuse **the name of the output layers** (i.e. the "name" + # property of the keras.layer that is used to generate an output + # tensor) and **the key of the output tensor**, in the dict returned + # from `MyModel.get_output()`. They are two identifiers with a + # different purpose: + # - the output layer name is used only at inference time, to identify + # the output tensor from which generate the output image, + # - the output tensor key identifies the output tensors, mainly to + # fit the targets to model outputs during training process, but it + # can also be used to access the tensors as tf/keras objects, for + # instance to display previews images in TensorBoard. softmax_op = keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) predictions = softmax_op(out_tconv4) - # Note that we could also add additional outputs - # and return a list, for instance the argmax of the softmax: + # note that we could also add additional outputs, for instance the + # argmax of the softmax: # # argmax_op = otbtf.layers.Argmax(name="labels") # labels = argmax_op(predictions) - # return [predictions, labels] + # return {TARGET_NAME: predictions, OUTPUT_ARGMAX_NAME: labels} # The default extra outputs (i.e. output tensors with cropping in # physical domain) are append by `otbtf.ModelBase` for all returned # outputs of this function to be used at inference time (e.g. # "labels_crop32", "labels_crop64", ..., # "predictions_softmax_tensor_crop16", ..., etc). - return predictions + return {TARGET_NAME: predictions} def dataset_preprocessing_fn(examples: dict): @@ -155,7 +160,7 @@ def dataset_preprocessing_fn(examples: dict): """ return { INPUT_NAME: examples["input_xs_patches"], - OUTPUT_SOFTMAX_NAME: keras.ops.one_hot( + TARGET_NAME: keras.ops.one_hot( keras.ops.squeeze( keras.ops.cast(examples["labels_patches"], tf.int32), axis=-1 ), @@ -188,12 +193,11 @@ def train(params, ds_train, ds_valid, ds_test): # over which the losses/metrics are computed. # This ensures a better optimization control, and also avoids lots of # useless outputs (e.g. metrics computed over extra outputs). - print("Compiling model...") model.compile( loss=keras.losses.CategoricalCrossentropy(), optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ - OUTPUT_SOFTMAX_NAME: [ + TARGET_NAME: [ keras.metrics.Precision(class_id=1), keras.metrics.Recall(class_id=1), ] diff --git a/otbtf/model.py b/otbtf/model.py index a17c161e..1d5cad0b 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -29,7 +29,6 @@ import tensorflow as tf import keras Tensor = Any -TensorsList = List[Tensor] TensorsDict = Dict[str, Tensor] @@ -39,10 +38,10 @@ class ModelBase(abc.ABC): """ def __init__( - self, - dataset_element_spec: tf.TensorSpec, - input_keys: List[str] = None, - inference_cropping: List[int] = None, + self, + dataset_element_spec: tf.TensorSpec, + input_keys: List[str] = None, + inference_cropping: List[int] = None ): """ Model initializer, must be called **inside** the strategy.scope(). @@ -61,14 +60,18 @@ class ModelBase(abc.ABC): """ # Retrieve dataset inputs shapes dataset_input_element_spec = dataset_element_spec[0] - logging.info("Dataset input element spec: %s", dataset_input_element_spec) + logging.info( + "Dataset input element spec: %s", dataset_input_element_spec + ) if input_keys: self.dataset_input_keys = input_keys logging.info("Using input keys: %s", self.dataset_input_keys) else: self.dataset_input_keys = list(dataset_input_element_spec) - logging.info("Found dataset input keys: %s", self.dataset_input_keys) + logging.info( + "Found dataset input keys: %s", self.dataset_input_keys + ) self.inputs_shapes = { key: dataset_input_element_spec[key].shape[1:] @@ -119,7 +122,7 @@ class ModelBase(abc.ABC): return model_inputs @abc.abstractmethod - def get_outputs(self, normalized_inputs: TensorsDict) -> Tensor | TensorsList: + def get_outputs(self, normalized_inputs: TensorsDict) -> TensorsDict: """ Implementation of the model, from the normalized inputs. @@ -155,14 +158,14 @@ class ModelBase(abc.ABC): return inputs def postprocess_outputs( - self, - outputs: Tensor | list[Tensor], - inputs: TensorsDict = None, - normalized_inputs: TensorsDict = None, - ) -> Tensor | TensorsList: + self, + outputs: TensorsDict, + inputs: TensorsDict = None, + normalized_inputs: TensorsDict = None + ) -> TensorsDict: """ Post-process the model outputs. - Takes the dicts of inputs and list of outputs, and returns a list of + Takes the dicts of inputs and outputs, and returns a dict of post-processed outputs. The default implementation provides a set of cropped output tensors. @@ -172,28 +175,29 @@ class ModelBase(abc.ABC): normalized_inputs: dict of normalized model inputs (optional) Returns: - a list of post-processed model named outputs + a dict of post-processed model outputs """ - if not isinstance(outputs, list): - outputs = [outputs] # Add extra outputs for inference - for out_tensor in outputs: + extra_outputs = {} + for out_key, out_tensor in outputs.items(): for crop in self.inference_cropping: - name = cropped_tensor_name( + extra_output_key = cropped_tensor_name(out_key, crop) + extra_output_name = cropped_tensor_name( out_tensor._keras_history.operation.name, crop ) logging.info( - "Adding extra output for tensor %s with crop %s", - name, - crop, + "Adding extra output for tensor %s with crop %s (%s)", + out_key, crop, extra_output_name ) cropped = out_tensor[:, crop:-crop, crop:-crop, :] - identity = keras.layers.Activation("linear", name=name) - outputs.append(identity(cropped)) + identity = keras.layers.Activation( + 'linear', name=extra_output_name + ) + extra_outputs[extra_output_key] = identity(cropped) - return outputs + return extra_outputs def create_network(self) -> keras.Model: """ @@ -214,14 +218,30 @@ class ModelBase(abc.ABC): logging.info("Normalized model inputs: %s", normalized_inputs) # Build the model - outputs = self.get_outputs(normalized_inputs) + outputs = self.get_outputs(normalized_inputs=normalized_inputs) logging.info("Model outputs: %s", outputs) # Post-processing for inference - outputs = self.postprocess_outputs(outputs, inputs, normalized_inputs) + postprocessed_outputs = self.postprocess_outputs( + outputs=outputs, + inputs=list(inputs.values()), + normalized_inputs=normalized_inputs + ) + outputs.update(postprocessed_outputs) + + # Dirty fix for Keras 3 : we can't pass a dict of outputs + # We need to wrap the last layer in a new layer with the desired name + outputs = [ + keras.layers.Identity(name=key)(prediction) + for key, prediction in outputs.items() + ] # Return the keras model - return keras.Model(inputs=inputs, outputs=outputs, name=self.__class__.__name__) + return keras.Model( + inputs=inputs, + outputs=outputs, + name=self.__class__.__name__ + ) def summary(self, strategy=None): """ @@ -247,13 +267,14 @@ class ModelBase(abc.ABC): show_shapes: annotate with shapes values (True or False) """ - assert self.model, ( - "Plot() only works if create_network() has been " "called beforehand" - ) + assert self.model, "Plot() only works if create_network() has been " \ + "called beforehand" # When multiworker strategy, only plot if the worker is chief if not strategy or _is_chief(strategy): - keras.utils.plot_model(self.model, output_path, show_shapes=show_shapes) + keras.utils.plot_model( + self.model, output_path, show_shapes=show_shapes + ) def _is_chief(strategy): @@ -280,11 +301,9 @@ def _is_chief(strategy): if strategy.cluster_resolver: # this means MultiWorkerMirroredStrategy task_type = strategy.cluster_resolver.task_type task_id = strategy.cluster_resolver.task_id - return ( - (task_type == "chief") - or (task_type == "worker" and task_id == 0) + return (task_type == 'chief') \ + or (task_type == 'worker' and task_id == 0) \ or task_type is None - ) # strategy with only one worker return True -- GitLab From ce2ce9e9c6e602c660dc0f5c576f049e07f4d00f Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 15:17:43 +0100 Subject: [PATCH 278/317] Reset previous test with prediction layer name --- .../fcnn/train_from_patchesimages.py | 2 +- .../fcnn/train_from_tfrecords.py | 2 +- otbtf/model.py | 61 ++++++++----------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py b/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py index 3d4fd9ae..9dab4b9b 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/train_from_patchesimages.py @@ -90,7 +90,7 @@ def create_dataset( tf_ds = dataset.get_tf_dataset( batch_size=batch_size, preprocessing_fn=fcnn_model.dataset_preprocessing_fn, - targets_keys=targets_keys or [fcnn_model.OUTPUT_SOFTMAX_NAME] + targets_keys=targets_keys or [fcnn_model.TARGET_NAME] ) return tf_ds diff --git a/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py b/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py index 52cfe574..caf15a79 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/train_from_tfrecords.py @@ -51,7 +51,7 @@ def train(params): kwargs = { "batch_size": params.batch_size, - "target_keys": [fcnn_model.OUTPUT_SOFTMAX_NAME], + "target_keys": [fcnn_model.TARGET_NAME], "preprocessing_fn": fcnn_model.dataset_preprocessing_fn } diff --git a/otbtf/model.py b/otbtf/model.py index 1d5cad0b..efe76c7d 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -38,10 +38,10 @@ class ModelBase(abc.ABC): """ def __init__( - self, - dataset_element_spec: tf.TensorSpec, - input_keys: List[str] = None, - inference_cropping: List[int] = None + self, + dataset_element_spec: tf.TensorSpec, + input_keys: List[str] = None, + inference_cropping: List[int] = None, ): """ Model initializer, must be called **inside** the strategy.scope(). @@ -60,18 +60,14 @@ class ModelBase(abc.ABC): """ # Retrieve dataset inputs shapes dataset_input_element_spec = dataset_element_spec[0] - logging.info( - "Dataset input element spec: %s", dataset_input_element_spec - ) + logging.info("Dataset input element spec: %s", dataset_input_element_spec) if input_keys: self.dataset_input_keys = input_keys logging.info("Using input keys: %s", self.dataset_input_keys) else: self.dataset_input_keys = list(dataset_input_element_spec) - logging.info( - "Found dataset input keys: %s", self.dataset_input_keys - ) + logging.info("Found dataset input keys: %s", self.dataset_input_keys) self.inputs_shapes = { key: dataset_input_element_spec[key].shape[1:] @@ -158,10 +154,10 @@ class ModelBase(abc.ABC): return inputs def postprocess_outputs( - self, - outputs: TensorsDict, - inputs: TensorsDict = None, - normalized_inputs: TensorsDict = None + self, + outputs: TensorsDict, + inputs: TensorsDict = None, + normalized_inputs: TensorsDict = None, ) -> TensorsDict: """ Post-process the model outputs. @@ -189,12 +185,12 @@ class ModelBase(abc.ABC): ) logging.info( "Adding extra output for tensor %s with crop %s (%s)", - out_key, crop, extra_output_name + out_key, + crop, + extra_output_name, ) cropped = out_tensor[:, crop:-crop, crop:-crop, :] - identity = keras.layers.Activation( - 'linear', name=extra_output_name - ) + identity = keras.layers.Activation("linear", name=extra_output_name) extra_outputs[extra_output_key] = identity(cropped) return extra_outputs @@ -214,18 +210,16 @@ class ModelBase(abc.ABC): logging.info("Model inputs: %s", inputs) # Normalize the inputs - normalized_inputs = self.normalize_inputs(inputs=inputs) + normalized_inputs = self.normalize_inputs(inputs) logging.info("Normalized model inputs: %s", normalized_inputs) # Build the model - outputs = self.get_outputs(normalized_inputs=normalized_inputs) + outputs = self.get_outputs(normalized_inputs) logging.info("Model outputs: %s", outputs) # Post-processing for inference postprocessed_outputs = self.postprocess_outputs( - outputs=outputs, - inputs=list(inputs.values()), - normalized_inputs=normalized_inputs + outputs, inputs, normalized_inputs ) outputs.update(postprocessed_outputs) @@ -237,11 +231,7 @@ class ModelBase(abc.ABC): ] # Return the keras model - return keras.Model( - inputs=inputs, - outputs=outputs, - name=self.__class__.__name__ - ) + return keras.Model(inputs=inputs, outputs=outputs, name=self.__class__.__name__) def summary(self, strategy=None): """ @@ -267,14 +257,13 @@ class ModelBase(abc.ABC): show_shapes: annotate with shapes values (True or False) """ - assert self.model, "Plot() only works if create_network() has been " \ - "called beforehand" + assert self.model, ( + "Plot() only works if create_network() has been " "called beforehand" + ) # When multiworker strategy, only plot if the worker is chief if not strategy or _is_chief(strategy): - keras.utils.plot_model( - self.model, output_path, show_shapes=show_shapes - ) + keras.utils.plot_model(self.model, output_path, show_shapes=show_shapes) def _is_chief(strategy): @@ -301,9 +290,11 @@ def _is_chief(strategy): if strategy.cluster_resolver: # this means MultiWorkerMirroredStrategy task_type = strategy.cluster_resolver.task_type task_id = strategy.cluster_resolver.task_id - return (task_type == 'chief') \ - or (task_type == 'worker' and task_id == 0) \ + return ( + (task_type == "chief") + or (task_type == "worker" and task_id == 0) or task_type is None + ) # strategy with only one worker return True -- GitLab From c0685078cbe1b7a5c1a4942e95c110f7cfc5f57a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 15:37:18 +0100 Subject: [PATCH 279/317] Try model export with signature --- .../examples/tensorflow_v2x/fcnn/fcnn_model.py | 18 ++++++++++++++++-- otbtf/model.py | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 0e9df694..fb2f7d3e 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -21,6 +21,9 @@ N_CLASSES = 2 # Name of the input in the `FCNNModel` instance, also name of the input node # in the SavedModel INPUT_NAME = "input_xs" +INPUT_SPEC = tf.TensorSpec( + shape=[None, None, None, 4], dtype=tf.float32, name=INPUT_NAME +) # Name of the output in the `FCNNModel` instance TARGET_NAME = "predictions" @@ -55,7 +58,7 @@ class FCNNModel(ModelBase): """ return {INPUT_NAME: keras.ops.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} - def get_outputs(self, normalized_inputs: dict) -> dict: + def get_outputs(self, normalized_inputs: dict) -> list: """ Inherits from `ModelBase` @@ -214,5 +217,16 @@ def train(params, ds_train, ds_valid, ds_test): if ds_test is not None: model.evaluate(ds_test, batch_size=params.batch_size) + # This signature function should ensure output names aren't lost + # (due to Keras optimizations) + @tf.function(input_signature=[INPUT_SPEC]) + def serving(input_xs): + predictions = model(input_xs) + # Return a dictionary of named outputs + return { + model.outputs_names[i]: predictions[i] + for i in range(len(predictions)) + } + # Save trained model as SavedModel - model.export(params.model_dir) + model.export(params.model_dir, signatures={"serving_default": serving}) diff --git a/otbtf/model.py b/otbtf/model.py index efe76c7d..21d07b31 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -225,6 +225,7 @@ class ModelBase(abc.ABC): # Dirty fix for Keras 3 : we can't pass a dict of outputs # We need to wrap the last layer in a new layer with the desired name + self.outputs_names = list(outputs) outputs = [ keras.layers.Identity(name=key)(prediction) for key, prediction in outputs.items() -- GitLab From 30263e01ce6fc2e3d8130ce6fdb8212352156446 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 15:45:51 +0100 Subject: [PATCH 280/317] Try with model.save --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index fb2f7d3e..d4baf944 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -222,11 +222,10 @@ def train(params, ds_train, ds_valid, ds_test): @tf.function(input_signature=[INPUT_SPEC]) def serving(input_xs): predictions = model(input_xs) - # Return a dictionary of named outputs return { model.outputs_names[i]: predictions[i] for i in range(len(predictions)) } # Save trained model as SavedModel - model.export(params.model_dir, signatures={"serving_default": serving}) + model.save(params.model_dir, signatures={"serving_default": serving}) -- GitLab From 79e1a4de724f78455e39808a284d7c36ed9d9de4 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 15:51:20 +0100 Subject: [PATCH 281/317] Try with ExportArchive() --- .../tensorflow_v2x/fcnn/fcnn_model.py | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index d4baf944..3bad4185 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -21,7 +21,7 @@ N_CLASSES = 2 # Name of the input in the `FCNNModel` instance, also name of the input node # in the SavedModel INPUT_NAME = "input_xs" -INPUT_SPEC = tf.TensorSpec( +INPUT_SIGNATURE = tf.TensorSpec( shape=[None, None, None, 4], dtype=tf.float32, name=INPUT_NAME ) @@ -217,15 +217,13 @@ def train(params, ds_train, ds_valid, ds_test): if ds_test is not None: model.evaluate(ds_test, batch_size=params.batch_size) - # This signature function should ensure output names aren't lost - # (due to Keras optimizations) - @tf.function(input_signature=[INPUT_SPEC]) - def serving(input_xs): - predictions = model(input_xs) - return { - model.outputs_names[i]: predictions[i] - for i in range(len(predictions)) - } - + # Prepare model export + export_archive = keras.ExportArchive() + export_archive.track(model) + export_archive.add_endpoint( + name="serve", + fn=model.call, + input_signature=INPUT_SIGNATURE, + ) # Save trained model as SavedModel - model.save(params.model_dir, signatures={"serving_default": serving}) + export_archive.write_out(params.model_dir) -- GitLab From f0e89cec488b92978b8779dd7ffd786f8c1e9300 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 16:05:40 +0100 Subject: [PATCH 282/317] Fix attribute error --- .gitlab-ci.yml | 1 + otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac1bec00..deaa1b96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -150,6 +150,7 @@ ctest: otbtf_api: stage: Test extends: .tests_base + needs: ["ctest"] variables: API_TEST_TMP: /tmp/api_tests_tmp script: diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 3bad4185..f80530da 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -218,7 +218,7 @@ def train(params, ds_train, ds_valid, ds_test): model.evaluate(ds_test, batch_size=params.batch_size) # Prepare model export - export_archive = keras.ExportArchive() + export_archive = keras.export.ExportArchive() export_archive.track(model) export_archive.add_endpoint( name="serve", -- GitLab From 4f0d5bdb47b918b220e672184d23d350583ba3e7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 16:16:52 +0100 Subject: [PATCH 283/317] Try with explicit model reference --- .gitlab-ci.yml | 5 ++--- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index deaa1b96..158f184d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -147,10 +147,9 @@ ctest: paths: - $CI_PROJECT_DIR/artifacts_ctest -otbtf_api: +python_api: stage: Test extends: .tests_base - needs: ["ctest"] variables: API_TEST_TMP: /tmp/api_tests_tmp script: @@ -166,7 +165,7 @@ otbtf_api: .applications_test_base: stage: Applications Test extends: .tests_base - needs: ["ctest", "otbtf_api"] + needs: ["ctest", "python_api"] #when: manual crc_book: diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index f80530da..9919ae49 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -189,14 +189,14 @@ def train(params, ds_train, ds_valid, ds_test): # Model instantiation. Note that the normalize_fn is now part of the # model. It is mandatory to instantiate the model inside the strategy # scope. - model = FCNNModel(dataset_element_spec=ds_train.element_spec) + otbtf_model = FCNNModel(dataset_element_spec=ds_train.element_spec) # Compile the model # It is a good practice to use a `dict` to explicitly name the outputs # over which the losses/metrics are computed. # This ensures a better optimization control, and also avoids lots of # useless outputs (e.g. metrics computed over extra outputs). - model.compile( + otbtf_model.model.compile( loss=keras.losses.CategoricalCrossentropy(), optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ @@ -208,21 +208,21 @@ def train(params, ds_train, ds_valid, ds_test): ) # Summarize the model (in CLI) - model.summary() + otbtf_model.model.summary() # Train - model.fit(ds_train, epochs=params.nb_epochs, validation_data=ds_valid) + otbtf_model.model.fit(ds_train, epochs=params.nb_epochs, validation_data=ds_valid) # Evaluate against test data if ds_test is not None: - model.evaluate(ds_test, batch_size=params.batch_size) + otbtf_model.model.evaluate(ds_test, batch_size=params.batch_size) # Prepare model export export_archive = keras.export.ExportArchive() - export_archive.track(model) + export_archive.track(otbtf_model.model) export_archive.add_endpoint( name="serve", - fn=model.call, + fn=otbtf_model.model.call, input_signature=INPUT_SIGNATURE, ) # Save trained model as SavedModel -- GitLab From a66533f8f555a6b2a9b87f58d7971d9e9d31e625 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 16:21:02 +0100 Subject: [PATCH 284/317] Fix input signature --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 9919ae49..646aff93 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -223,7 +223,7 @@ def train(params, ds_train, ds_valid, ds_test): export_archive.add_endpoint( name="serve", fn=otbtf_model.model.call, - input_signature=INPUT_SIGNATURE, + input_signature=[INPUT_SIGNATURE], ) # Save trained model as SavedModel export_archive.write_out(params.model_dir) -- GitLab From 35e5a038eb7472c8cc95f2e27d7b9aa64d2dbf13 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 16:40:14 +0100 Subject: [PATCH 285/317] Try with model output signature --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 646aff93..c086426b 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -217,13 +217,17 @@ def train(params, ds_train, ds_valid, ds_test): if ds_test is not None: otbtf_model.model.evaluate(ds_test, batch_size=params.batch_size) + @tf.function(input_signature=[INPUT_SIGNATURE]) + def model_signature(input_xs): + outputs = otbtf_model.model(input_xs) + return { + name: outputs[i] + for i, name in enumerate(otbtf_model.outputs_names) + } + # Prepare model export export_archive = keras.export.ExportArchive() export_archive.track(otbtf_model.model) - export_archive.add_endpoint( - name="serve", - fn=otbtf_model.model.call, - input_signature=[INPUT_SIGNATURE], - ) + export_archive.add_function("serving_default", model_signature) # Save trained model as SavedModel export_archive.write_out(params.model_dir) -- GitLab From 89b5a0619242288b2fcfdf198ee299002bbfe12e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 15 Nov 2024 16:47:16 +0100 Subject: [PATCH 286/317] Back to model.export --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index c086426b..4178ba6d 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -217,17 +217,5 @@ def train(params, ds_train, ds_valid, ds_test): if ds_test is not None: otbtf_model.model.evaluate(ds_test, batch_size=params.batch_size) - @tf.function(input_signature=[INPUT_SIGNATURE]) - def model_signature(input_xs): - outputs = otbtf_model.model(input_xs) - return { - name: outputs[i] - for i, name in enumerate(otbtf_model.outputs_names) - } - - # Prepare model export - export_archive = keras.export.ExportArchive() - export_archive.track(otbtf_model.model) - export_archive.add_function("serving_default", model_signature) # Save trained model as SavedModel - export_archive.write_out(params.model_dir) + otbtf_model.model.export(params.model_dir) -- GitLab From 1e2070224fc90ba6788132875e1cdd8424c535f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 15:44:48 +0100 Subject: [PATCH 287/317] doc: keras 3 induced changes --- doc/api_tutorial.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/api_tutorial.md b/doc/api_tutorial.md index cc08b919..9c47be74 100644 --- a/doc/api_tutorial.md +++ b/doc/api_tutorial.md @@ -315,12 +315,24 @@ dataset ```python model.compile( - loss=tf.keras.losses.CategoricalCrossentropy(), + loss={TARGET_NAME: tf.keras.losses.CategoricalCrossentropy()}, optimizer=tf.keras.optimizers.Adam(learning_rate=1e-4), - metrics=[tf.keras.metrics.Precision(), tf.keras.metrics.Recall()] + metrics={ + TARGET_NAME: [ + tf.keras.metrics.Precision(), + tf.keras.metrics.Recall() + ] + } ) ``` +!!! Note + + The losses and metrics must always be provided using a dict, to specify + which output to use. This is mandatory since Keras 3, since OTBTF generates + a bunch of extra outputs that are not used during optimization, but needed + in the inference step. + We can then train our model using Keras: ```python -- GitLab From 67eefe59d095638c166d7bba073cc0b6cdc95820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 15:45:16 +0100 Subject: [PATCH 288/317] enh: adapt model class for keras 3 --- otbtf/model.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/otbtf/model.py b/otbtf/model.py index 21d07b31..e20ff81b 100644 --- a/otbtf/model.py +++ b/otbtf/model.py @@ -190,7 +190,7 @@ class ModelBase(abc.ABC): extra_output_name, ) cropped = out_tensor[:, crop:-crop, crop:-crop, :] - identity = keras.layers.Activation("linear", name=extra_output_name) + identity = keras.layers.Identity(name=extra_output_name) extra_outputs[extra_output_key] = identity(cropped) return extra_outputs @@ -223,13 +223,12 @@ class ModelBase(abc.ABC): ) outputs.update(postprocessed_outputs) - # Dirty fix for Keras 3 : we can't pass a dict of outputs - # We need to wrap the last layer in a new layer with the desired name - self.outputs_names = list(outputs) - outputs = [ - keras.layers.Identity(name=key)(prediction) + # Since Keras 3, outputs are named after the key in the returned + # dict of `get_outputs()` + outputs = { + key: keras.layers.Identity(name=key)(prediction) for key, prediction in outputs.items() - ] + } # Return the keras model return keras.Model(inputs=inputs, outputs=outputs, name=self.__class__.__name__) -- GitLab From 64b1689823f1ccf80b7d0dbfbcf727caf124fa10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 15:45:38 +0100 Subject: [PATCH 289/317] test: update tests for keras 3 --- .../tensorflow_v2x/fcnn/fcnn_model.py | 59 ++++++++----------- test/api_unittest.py | 14 +++-- 2 files changed, 31 insertions(+), 42 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 4178ba6d..08c18687 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -28,9 +28,6 @@ INPUT_SIGNATURE = tf.TensorSpec( # Name of the output in the `FCNNModel` instance TARGET_NAME = "predictions" -# Name (prefix) of the output node in the SavedModel -OUTPUT_SOFTMAX_NAME = "predictions_softmax_tensor" - class FCNNModel(ModelBase): """ @@ -106,40 +103,31 @@ class FCNNModel(ModelBase): out_tconv3 = _tconv(out_tconv2, 16, "tconv3") + out_conv1 out_tconv4 = _tconv(out_tconv3, N_CLASSES, "classifier", None) - # Generally it is a good thing to name the final layers of the network - # (i.e. the layers of which outputs are returned from - # `MyModel.get_output()`). Indeed this enables to retrieve them for - # inference time, using their name. In case your forgot to name the - # last layers, it is still possible to look at the model outputs using - # the `saved_model_cli show --dir /path/to/your/savedmodel --all` - # command. - # - # Do not confuse **the name of the output layers** (i.e. the "name" - # property of the keras.layer that is used to generate an output - # tensor) and **the key of the output tensor**, in the dict returned - # from `MyModel.get_output()`. They are two identifiers with a - # different purpose: - # - the output layer name is used only at inference time, to identify - # the output tensor from which generate the output image, - # - the output tensor key identifies the output tensors, mainly to - # fit the targets to model outputs during training process, but it - # can also be used to access the tensors as tf/keras objects, for - # instance to display previews images in TensorBoard. - softmax_op = keras.layers.Softmax(name=OUTPUT_SOFTMAX_NAME) + softmax_op = keras.layers.Softmax() predictions = softmax_op(out_tconv4) - # note that we could also add additional outputs, for instance the - # argmax of the softmax: + # Model outputs are returned in a `dict`, where each key is an output + # name, and the value is the layer output. This naming have two + # functions: + # - the output layer name is used at inference time, to identify + # the output tensor from which generate the output image, + # - the output layer name identifies the output tensors, to fit the + # targets to model outputs, compute metrics, etc. during training + # process. It can also be used to access the tensors as tf/keras + # objects, for instance to display previews images in TensorBoard. # - # argmax_op = otbtf.layers.Argmax(name="labels") - # labels = argmax_op(predictions) - # return {TARGET_NAME: predictions, OUTPUT_ARGMAX_NAME: labels} + # Note that we could also add additional outputs, even outputs which + # are useless for the optimization process, for instance the argmax : + # ``` + # argmax_op = otbtf.layers.Argmax() + # labels = argmax_op(predictions) + # return {TARGET_NAME: predictions, OUTPUT_ARGMAX_NAME: labels} + # ``` # The default extra outputs (i.e. output tensors with cropping in # physical domain) are append by `otbtf.ModelBase` for all returned # outputs of this function to be used at inference time (e.g. - # "labels_crop32", "labels_crop64", ..., - # "predictions_softmax_tensor_crop16", ..., etc). - + # "labels_crop32", "labels_crop64", ..., "predictions__crop16", ..., + # etc). return {TARGET_NAME: predictions} @@ -192,12 +180,11 @@ def train(params, ds_train, ds_valid, ds_test): otbtf_model = FCNNModel(dataset_element_spec=ds_train.element_spec) # Compile the model - # It is a good practice to use a `dict` to explicitly name the outputs - # over which the losses/metrics are computed. - # This ensures a better optimization control, and also avoids lots of - # useless outputs (e.g. metrics computed over extra outputs). + # Since Keras 3 it is mandatory to use a `dict` to explicitly name the + # outputs over which the losses/metrics are computed, e.g. + # `loss: {TARGET_NAME: "categorical_crossentropy"}` otbtf_model.model.compile( - loss=keras.losses.CategoricalCrossentropy(), + loss={TARGET_NAME: keras.losses.CategoricalCrossentropy()}, optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ TARGET_NAME: [ diff --git a/test/api_unittest.py b/test/api_unittest.py index 5103b8d3..b2e3ba85 100644 --- a/test/api_unittest.py +++ b/test/api_unittest.py @@ -6,8 +6,10 @@ import pytest from otbtf.examples.tensorflow_v2x.fcnn import create_tfrecords from otbtf.examples.tensorflow_v2x.fcnn import train_from_patchesimages from otbtf.examples.tensorflow_v2x.fcnn import train_from_tfrecords -from otbtf.examples.tensorflow_v2x.fcnn.fcnn_model import INPUT_NAME, \ - OUTPUT_SOFTMAX_NAME +from otbtf.examples.tensorflow_v2x.fcnn.fcnn_model import ( + INPUT_NAME, + TARGET_NAME +) from otbtf.model import cropped_tensor_name from test_utils import resolve_paths, files_exist, run_command_and_compare @@ -50,7 +52,7 @@ class APITest(unittest.TestCase): f"-source1.placeholder {INPUT_NAME} " "-model.dir $TMPDIR/model_from_pimg " "-model.fullyconv on " - f"-output.names {cropped_tensor_name(OUTPUT_SOFTMAX_NAME, 16)} " + f"-output.names {cropped_tensor_name(TARGET_NAME, 16)} " "-output.efieldx 32 " "-output.efieldy 32 " "-out \"$TMPDIR/classif_model4_softmax.tif?&gdal:co:compress=deflate\" uint8", @@ -67,7 +69,7 @@ class APITest(unittest.TestCase): f"-source1.placeholder {INPUT_NAME} " "-model.dir $TMPDIR/model_from_pimg " "-model.fullyconv on " - f"-output.names {cropped_tensor_name(OUTPUT_SOFTMAX_NAME, 32)} " + f"-output.names {cropped_tensor_name(TARGET_NAME, 32)} " "-output.efieldx 64 " "-output.efieldy 64 " "-out \"$TMPDIR/classif_model4_softmax.tif?&gdal:co:compress=deflate\" uint8", @@ -127,7 +129,7 @@ class APITest(unittest.TestCase): f"-source1.placeholder {INPUT_NAME} " "-model.dir $TMPDIR/model_from_pimg " "-model.fullyconv on " - f"-output.names {cropped_tensor_name(OUTPUT_SOFTMAX_NAME, 16)} " + f"-output.names {cropped_tensor_name(TARGET_NAME, 16)} " "-output.efieldx 32 " "-output.efieldy 32 " "-out \"$TMPDIR/classif_model4_softmax.tif?&gdal:co:compress=deflate\" uint8", @@ -147,7 +149,7 @@ class APITest(unittest.TestCase): f"-source1.placeholder {INPUT_NAME} " "-model.dir $TMPDIR/model_from_pimg " "-model.fullyconv on " - f"-output.names {cropped_tensor_name(OUTPUT_SOFTMAX_NAME, 32)} " + f"-output.names {cropped_tensor_name(TARGET_NAME, 32)} " "-output.efieldx 64 " "-output.efieldy 64 " "-out \"$TMPDIR/classif_model4_softmax.tif?&gdal:co:compress=deflate\" uint8", -- GitLab From 22adf2345724faffae3726da718789921ab7aa0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 17:06:53 +0100 Subject: [PATCH 290/317] bump version to 5.0.0-rc1 --- .gitlab-ci.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 158f184d..a359f3ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ stages: - Ship variables: - OTBTF_VERSION: 4.4.0-rc1 + OTBTF_VERSION: 5.0.0-rc1 OTBTF_SRC: /src/otbtf # OTBTF source directory path in image DATADIR: $CI_PROJECT_DIR/test/data CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu diff --git a/setup.py b/setup.py index 8d200260..15809664 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="otbtf", - version="4.4.0", + version="5.0.0-rc1", author="Remi Cresson", author_email="remi.cresson@inrae.fr", description="OTBTF: Orfeo ToolBox meets TensorFlow", -- GitLab From 4d9396971a414f7110eb51334149647dc0cb1b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 17:07:24 +0100 Subject: [PATCH 291/317] enh: keras 3 support --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 08c18687..200c4d06 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -55,7 +55,7 @@ class FCNNModel(ModelBase): """ return {INPUT_NAME: keras.ops.cast(inputs[INPUT_NAME], tf.float32) * 0.0001} - def get_outputs(self, normalized_inputs: dict) -> list: + def get_outputs(self, normalized_inputs: dict) -> dict: """ Inherits from `ModelBase` @@ -177,13 +177,13 @@ def train(params, ds_train, ds_valid, ds_test): # Model instantiation. Note that the normalize_fn is now part of the # model. It is mandatory to instantiate the model inside the strategy # scope. - otbtf_model = FCNNModel(dataset_element_spec=ds_train.element_spec) + model = FCNNModel(dataset_element_spec=ds_train.element_spec) # Compile the model # Since Keras 3 it is mandatory to use a `dict` to explicitly name the # outputs over which the losses/metrics are computed, e.g. # `loss: {TARGET_NAME: "categorical_crossentropy"}` - otbtf_model.model.compile( + model.model.compile( loss={TARGET_NAME: keras.losses.CategoricalCrossentropy()}, optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ @@ -195,14 +195,14 @@ def train(params, ds_train, ds_valid, ds_test): ) # Summarize the model (in CLI) - otbtf_model.model.summary() + model.model.summary() # Train - otbtf_model.model.fit(ds_train, epochs=params.nb_epochs, validation_data=ds_valid) + model.model.fit(ds_train, epochs=params.nb_epochs, validation_data=ds_valid) # Evaluate against test data if ds_test is not None: - otbtf_model.model.evaluate(ds_test, batch_size=params.batch_size) + model.model.evaluate(ds_test, batch_size=params.batch_size) # Save trained model as SavedModel - otbtf_model.model.export(params.model_dir) + model.model.export(params.model_dir) -- GitLab From 80cebdb3ad8673e194334a6fe84908be5e262e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 17:41:17 +0100 Subject: [PATCH 292/317] comp: update dockerfile --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b2cb2b5a..efb6d56c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -190,6 +190,7 @@ RUN ! $DEV_IMAGE || pip install codespell flake8 pylint pytest pytest-cov pytest WORKDIR /home/otbuser # Test python imports -RUN python -c "import tensorflow ; import keras" +RUN python -c "import tensorflow, keras" RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" -RUN python -c "import otbtf ; import tricks" +RUN python -c "import otbtf, tricks" +RUN python -c "from osgeo import gdal" -- GitLab From 7a02f9a4b4ae92e4dbbe49cb2a75d5af9df2694a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 18:00:14 +0100 Subject: [PATCH 293/317] doc: docker versions --- doc/docker_use.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/docker_use.md b/doc/docker_use.md index 4150c0ff..0f9d95a9 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -26,10 +26,10 @@ versions <= 4.3.0 and [forgemia.inra.fr](https://forgemia.inra.fr/orfeo-toolbox/ | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:4.4.0-cpu** | Ubuntu Jammy | r2.18 | 9.1.0 | CPU | no | | -| **mdl4eo/otbtf:4.4.0-cpu-dev** | Ubuntu Jammy | r2.18 | 9.1.0 | CPU (dev) | yes | | -| **mdl4eo/otbtf:4.4.0-gpu** | Ubuntu Jammy | r2.18 | 9.1.0 | GPU | no | sm_60,sm_70,sm_80,sm_89,compute_90 | -| **mdl4eo/otbtf:4.4.0-gpu-dev** | Ubuntu Jammy | r2.18 | 9.1.0 | GPU (dev) | yes | sm_60,sm_70,sm_80,sm_89,compute_90| +| **mdl4eo/otbtf:5.0.0-cpu** | Ubuntu Jammy | r2.18 | 9.1.0 | CPU | no | | +| **mdl4eo/otbtf:5.0.0-cpu-dev** | Ubuntu Jammy | r2.18 | 9.1.0 | CPU (dev) | yes | | +| **mdl4eo/otbtf:5.0.0-gpu** | Ubuntu Jammy | r2.18 | 9.1.0 | GPU | no | sm_60,sm_70,sm_80,sm_89,compute_90 | +| **mdl4eo/otbtf:5.0.0-gpu-dev** | Ubuntu Jammy | r2.18 | 9.1.0 | GPU (dev) | yes | sm_60,sm_70,sm_80,sm_89,compute_90| [gitlab.irstea.fr](https://gitlab.irstea.fr/remi.cresson/otbtf/container_registry) (before otbtf 4.3.0) and [forgemia](https://forgemia.inra.fr/orfeo-toolbox/otbtf/container_registry) (since otbtf 4.3.1). -- GitLab From d185409757de21de81fd7fb42a3091db067f6704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 18:04:44 +0100 Subject: [PATCH 294/317] enh: keras 3 support --- otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py index 200c4d06..4259390f 100644 --- a/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py +++ b/otbtf/examples/tensorflow_v2x/fcnn/fcnn_model.py @@ -183,7 +183,7 @@ def train(params, ds_train, ds_valid, ds_test): # Since Keras 3 it is mandatory to use a `dict` to explicitly name the # outputs over which the losses/metrics are computed, e.g. # `loss: {TARGET_NAME: "categorical_crossentropy"}` - model.model.compile( + model.compile( loss={TARGET_NAME: keras.losses.CategoricalCrossentropy()}, optimizer=keras.optimizers.Adam(learning_rate=params.learning_rate), metrics={ @@ -195,14 +195,14 @@ def train(params, ds_train, ds_valid, ds_test): ) # Summarize the model (in CLI) - model.model.summary() + model.summary() # Train - model.model.fit(ds_train, epochs=params.nb_epochs, validation_data=ds_valid) + model.fit(ds_train, epochs=params.nb_epochs, validation_data=ds_valid) # Evaluate against test data if ds_test is not None: - model.model.evaluate(ds_test, batch_size=params.batch_size) + model.evaluate(ds_test, batch_size=params.batch_size) # Save trained model as SavedModel - model.model.export(params.model_dir) + model.export(params.model_dir) -- GitLab From 44cf751cbdf57a208322e382a9889f4a78e18887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= <remi.cresson@inrae.fr> Date: Thu, 28 Nov 2024 18:13:40 +0100 Subject: [PATCH 295/317] enh: keras 3 support --- .../tensorflow_v2x/deterministic/__init__.py | 13 +++++++------ .../tensorflow_v2x/deterministic/scalar_prod.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/otbtf/examples/tensorflow_v2x/deterministic/__init__.py b/otbtf/examples/tensorflow_v2x/deterministic/__init__.py index d0ec3db4..8ded4682 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/__init__.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/__init__.py @@ -65,18 +65,19 @@ Let's consider a simple model that inputs two multispectral image (*x1* and The model is exported as a SavedModel named *scalar_product_savedmodel* ```python -import tensorflow as tf +import keras # Input -x1 = tf.keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] -x2 = tf.keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] +x1 = keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] +x2 = keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] # Compute scalar product -y = tf.reduce_sum(tf.multiply(x1, x2), axis=-1) +y = keras.ops.sum(keras.ops.multiply(x1, x2), axis=-1) # Create model -model = tf.keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) -model.save("scalar_product_savedmodel") +model = keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) +model.export("scalar_product_savedmodel") + ``` Run the code. The *scalar_product_savedmodel* file is created. diff --git a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py index 1d5be347..c75d3631 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/scalar_prod.py @@ -24,7 +24,7 @@ x1 = keras.Input(shape=[None, None, None], name="x1") # [1, h, w, N] x2 = keras.Input(shape=[None, None, None], name="x2") # [1, h, w, N] # Compute scalar product -y = keras.ops.reduce_sum(keras.ops.multiply(x1, x2), axis=-1) +y = keras.ops.sum(keras.ops.multiply(x1, x2), axis=-1) # Create model model = keras.Model(inputs={"x1": x1, "x2": x2}, outputs={"y": y}) -- GitLab From 1898dab7104010115a3d70726981707012beeae7 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 09:47:57 +0100 Subject: [PATCH 296/317] Small doc updates for 5.0.0 release --- doc/api_distributed.md | 2 +- doc/deprecated.md | 7 ++++++- doc/docker_build.md | 4 ++-- otbtf/examples/tensorflow_v2x/deterministic/__init__.py | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/api_distributed.md b/doc/api_distributed.md index 09ea86c3..786a6f5c 100644 --- a/doc/api_distributed.md +++ b/doc/api_distributed.md @@ -98,7 +98,7 @@ The rest of the code is identical. !!! Warning - Be careful when calling `mymodel.save()` to export the SavedModel. When + Be careful when calling `mymodel.export()` to export the SavedModel. When multiple nodes are used in parallel, this can lead to a corrupt save. One good practice is to defer the call only to the master worker (e.g. node 0). You can identify the master worker using `otbtf.model._is_chief()`. diff --git a/doc/deprecated.md b/doc/deprecated.md index dfb95158..08f9e73e 100644 --- a/doc/deprecated.md +++ b/doc/deprecated.md @@ -39,4 +39,9 @@ training, etc. is done using the so-called `tensorflow.Strategy` ## Major changes between Keras 2 and 3 -TODO +- Use keras functions on keras objects, instead of tf ones +- Most operations in `tf` namespace have moved to `keras.ops` +- Function `model.save()` should be replaced by `model.export()` +- Target layers for metrics must be explicitly named + +Read further instructions in the official [keras docs](https://keras.io/guides/migrating_to_keras_3/). diff --git a/doc/docker_build.md b/doc/docker_build.md index 50ee9c1c..80393b1e 100644 --- a/doc/docker_build.md +++ b/doc/docker_build.md @@ -131,7 +131,7 @@ You may also need to split some multi-command layers in the Dockerfile. # Pull GPU image and create a new container with your home directory as volume # (requires apt package nvidia-docker2 and CUDA>=11.0) docker create --gpus=all --volume $HOME:/home/otbuser/volume -it \ - --name otbtf-gpu mdl4eo/otbtf:4.4.0-gpu + --name otbtf-gpu mdl4eo/otbtf:5.0.0-gpu # Run interactive docker start -i otbtf-gpu @@ -147,7 +147,7 @@ docker exec otbtf-gpu \ Enter a development ready docker image: ```bash -docker run -it --gpus=all -it --name otbtf-gpu-dev mdl4eo/otbtf:4.4.0-gpu-dev +docker run -it --gpus=all -it --name otbtf-gpu-dev mdl4eo/otbtf:5.0.0-gpu-dev # Then, from the container shell: cd /src/otb/otb/Modules/Remote git clone https://gitlab.irstea.fr/raffaele.gaetano/otbSelectiveHaralickTextures.git diff --git a/otbtf/examples/tensorflow_v2x/deterministic/__init__.py b/otbtf/examples/tensorflow_v2x/deterministic/__init__.py index 8ded4682..03bb3133 100644 --- a/otbtf/examples/tensorflow_v2x/deterministic/__init__.py +++ b/otbtf/examples/tensorflow_v2x/deterministic/__init__.py @@ -29,11 +29,11 @@ import tensorflow as tf x = tf.keras.Input(shape=[None, None, None], name="x") # [1, h, w, N] # Compute norm on the last axis -y = tf.norm(x, axis=-1) +y = tf.keras.ops.norm(x, axis=-1) # Create model model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}) -model.save("l2_norm_savedmodel") +model.export("l2_norm_savedmodel") ``` Run the code. The *l2_norm_savedmodel* file is created. -- GitLab From e85b08454ce411280ef145460483859bb15b23d3 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 15:14:24 +0100 Subject: [PATCH 297/317] Update decloud repo URL --- .gitlab-ci.yml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a359f3ea..bfe68c79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -168,27 +168,25 @@ python_api: needs: ["ctest", "python_api"] #when: manual -crc_book: - extends: .applications_test_base - allow_failure: true - variables: - CRC_BOOK_TMP: /tmp/crc_book_tests_tmp - script: - - mkdir -p $CRC_BOOK_TMP - - TMPDIR=$CRC_BOOK_TMP python -m pytest -v --junitxml=report_tutorial.xml test/tutorial_unittest.py - after_script: - - cp -r $CRC_BOOK_TMP $CI_PROJECT_DIR/artifacts_crc_book - artifacts: - paths: - - $CI_PROJECT_DIR/artifacts_crc_book +# crc_book: +# extends: .applications_test_base +# variables: +# CRC_BOOK_TMP: /tmp/crc_book_tests_tmp +# script: +# - mkdir -p $CRC_BOOK_TMP +# - TMPDIR=$CRC_BOOK_TMP python -m pytest -v --junitxml=report_tutorial.xml test/tutorial_unittest.py +# after_script: +# - cp -r $CRC_BOOK_TMP $CI_PROJECT_DIR/artifacts_crc_book +# artifacts: +# paths: +# - $CI_PROJECT_DIR/artifacts_crc_book decloud: extends: .applications_test_base - allow_failure: true variables: DATASET_DECLOUD: https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download script: - - git clone https://github.com/CNES/decloud.git + - git clone https://forgemia.inra.fr/umr-tetis/decloud.git -b keras3 - pip install -r $PWD/decloud/docker/requirements.txt - wget -q $DATASET_DECLOUD -O file.zip && unzip file.zip - export DECLOUD_DATA_DIR="$PWD/decloud_data" -- GitLab From f876ebedf7ffa53c558be1a174aa3a7686ff7870 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 16:13:10 +0100 Subject: [PATCH 298/317] WIP: add missing auth for dockerhub --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bfe68c79..27c6afbb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,7 @@ default: services: - name: docker:27.3.1-dind before_script: + - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - docker buildx create --name=container --driver=docker-container --use --bootstrap after_script: @@ -265,7 +266,6 @@ deploy_cpu: --build-arg DEV_IMAGE=true . # push images on dockerhub - - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - docker tag $IMAGE_CPU $DOCKERHUB_CPU && docker push $DOCKERHUB_CPU - docker tag $IMAGE_CPUDEV $DOCKERHUB_CPUDEV && docker push $DOCKERHUB_CPUDEV # latest = cpu image @@ -297,7 +297,6 @@ deploy_gpu: --build-arg WITH_CUDA=true --build-arg DEV_IMAGE=true . # push gpu-* images on dockerhub - - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - docker tag $IMAGE_GPU $DOCKERHUB_GPU && docker push $DOCKERHUB_GPU - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV && docker push $DOCKERHUB_GPUDEV # latest-gpu = gpu image -- GitLab From 2688cd64933192c7188a78d84f111adefb80a9bc Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 16:15:16 +0100 Subject: [PATCH 299/317] WIP: try fix pipeline trigger ignore wip --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 27c6afbb..8b11ec83 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ workflow: when: never - if: $CI_COMMIT_REF_PROTECTED == "true" # Ignore pipeline for filthy commits - - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i + - if: '$CI_COMMIT_MESSAGE =~ /^wip.*/i' when: never auto_cancel: on_new_commit: interruptible -- GitLab From bd38009802f711f06b918acb792fadb9436bf187 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 16:22:33 +0100 Subject: [PATCH 300/317] Skip pipeline for draft MRs --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b11ec83..f99b86bc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,15 @@ workflow: rules: - # Execute on tags, MR or protected branches + # Execute on tags, protected branches or merge requests - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_REF_PROTECTED == "true" - if: $CI_PIPELINE_SOURCE == "merge_request_event" + # Ignore pipelines draft MRs + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never # Avoid duplicated pipelines in MR context - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - - if: $CI_COMMIT_REF_PROTECTED == "true" - # Ignore pipeline for filthy commits - - if: '$CI_COMMIT_MESSAGE =~ /^wip.*/i' - when: never auto_cancel: on_new_commit: interruptible -- GitLab From 016d49d389126ae13f9aab5bcf5555f7420bdb13 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 16:24:32 +0100 Subject: [PATCH 301/317] Try fix pipeline skip for draft MR --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f99b86bc..3afbccab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,12 @@ workflow: rules: - # Execute on tags, protected branches or merge requests + # Execute on tags and protected branches - if: $CI_COMMIT_TAG - if: $CI_COMMIT_REF_PROTECTED == "true" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - # Ignore pipelines draft MRs + # Execute on MR except for drafts - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ when: never + - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Avoid duplicated pipelines in MR context - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never -- GitLab From 97aa32c5a303c204f3f6b033427e97f10bcf241a Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 16:26:32 +0100 Subject: [PATCH 302/317] Fix CI rules order --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3afbccab..b24fca5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,15 @@ workflow: rules: - # Execute on tags and protected branches - - if: $CI_COMMIT_TAG - - if: $CI_COMMIT_REF_PROTECTED == "true" + # Avoid duplicated pipelines in MR context + - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS + when: never # Execute on MR except for drafts - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ when: never - if: $CI_PIPELINE_SOURCE == "merge_request_event" - # Avoid duplicated pipelines in MR context - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS - when: never + # Else execute on tags or protected branches + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_REF_PROTECTED == "true" auto_cancel: on_new_commit: interruptible -- GitLab From aa9ddb01746fa842d6e38b1ba0b6c3e45600768c Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 6 Dec 2024 16:29:20 +0100 Subject: [PATCH 303/317] Drop unused variables --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b24fca5d..374a7e96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,8 +28,6 @@ variables: CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu CACHE_IMAGE_GPU: $CI_REGISTRY_IMAGE:build-cache-gpu BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME - DOCKER_DRIVER: overlay2 - DOCKER_BUILDKIT: 1 BUILDX_BUILDER: container BUILDX_NO_DEFAULT_ATTESTATIONS: 1 -- GitLab From d25ec0038281e7e17477d3097a18271fb24407de Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 7 Dec 2024 12:56:07 +0100 Subject: [PATCH 304/317] Try ignore pipelines for wip commits --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 374a7e96..171ab0ed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,10 @@ workflow: rules: - # Avoid duplicated pipelines in MR context - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS + # Ignore pipeline for filthy commits + - if: $CI_COMMIT_MESSAGE =~ /^wip.*/i when: never - # Execute on MR except for drafts - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + # Execute for MR, but avoid duplicated due to branch triggers in MR + - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Else execute on tags or protected branches -- GitLab From bf8fcd12955e1e0cf3f0dd7a5174488614f04c60 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 7 Dec 2024 12:57:40 +0100 Subject: [PATCH 305/317] Comment failing auth for dockerhub --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 171ab0ed..5f9ae851 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,7 +43,7 @@ default: services: - name: docker:27.3.1-dind before_script: - - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - docker buildx create --name=container --driver=docker-container --use --bootstrap after_script: -- GitLab From 5abbf4af490673541eacc979485d2f2d8cfddfc5 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 7 Dec 2024 13:07:46 +0100 Subject: [PATCH 306/317] WIP: try fix dockerhub login --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f9ae851..f633e47d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,7 +43,6 @@ default: services: - name: docker:27.3.1-dind before_script: - #- echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - docker buildx create --name=container --driver=docker-container --use --bootstrap after_script: @@ -241,6 +240,10 @@ nodata: DOCKERHUB_BASE: mdl4eo/otbtf CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION DOCKERHUB_IMAGE_BASE: $DOCKERHUB_BASE:$OTBTF_VERSION + before_script: + - echo -n $DOCKERHUB_TOKEN | docker login -u mdl4eo --password-stdin + - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY + - docker buildx create --name=container --driver=docker-container --use --bootstrap deploy_cpu: stage: Ship -- GitLab From 4f99fc2d6105dea0551909e1a90f70a77049ee36 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Sat, 7 Dec 2024 15:31:36 +0100 Subject: [PATCH 307/317] Fix moved requirements.txt in decloud --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f633e47d..74cbc9b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -183,11 +183,11 @@ decloud: extends: .applications_test_base variables: DATASET_DECLOUD: https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download + DECLOUD_DATA_DIR: $CI_PROJECT_DIR/decloud_data script: - git clone https://forgemia.inra.fr/umr-tetis/decloud.git -b keras3 - - pip install -r $PWD/decloud/docker/requirements.txt + - pip install -r $PWD/decloud/requirements.txt - wget -q $DATASET_DECLOUD -O file.zip && unzip file.zip - - export DECLOUD_DATA_DIR="$PWD/decloud_data" - pytest -v decloud/tests/train_from_tfrecords_unittest.py sr4rs: -- GitLab From 2aed403fa7e22d95d4282f842b1aacb713bb8f20 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 24 Feb 2025 12:05:55 +0100 Subject: [PATCH 308/317] Bump ubuntu base image version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index efb6d56c..ea680edc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # Init base stage - used for intermediate build env and final image # Freeze ubuntu version to avoid surprise rebuild -FROM ubuntu:jammy-20240911.1 AS base-stage +FROM ubuntu:jammy-20250126 AS base-stage WORKDIR /tmp -- GitLab From 5815f3426975e1a37ce94871e5e8cc00b7ec1f86 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 24 Feb 2025 12:07:48 +0100 Subject: [PATCH 309/317] Docker bump versions --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 74cbc9b4..351acc95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ stages: - Ship variables: - OTBTF_VERSION: 5.0.0-rc1 + OTBTF_VERSION: 5.0.0-rc2 OTBTF_SRC: /src/otbtf # OTBTF source directory path in image DATADIR: $CI_PROJECT_DIR/test/data CACHE_IMAGE_CPU: $CI_REGISTRY_IMAGE:build-cache-cpu @@ -39,9 +39,9 @@ default: pull_policy: always .docker_build_base: - image: docker:27.3.1 + image: docker:27.5.1 services: - - name: docker:27.3.1-dind + - name: docker:27.5.1-dind before_script: - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - docker buildx create --name=container --driver=docker-container --use --bootstrap @@ -181,6 +181,7 @@ python_api: decloud: extends: .applications_test_base + allow_failure: true variables: DATASET_DECLOUD: https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download DECLOUD_DATA_DIR: $CI_PROJECT_DIR/decloud_data -- GitLab From 3cf7c42db655fb0000b0f34287405f2906ac08e1 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 24 Feb 2025 12:08:24 +0100 Subject: [PATCH 310/317] ENH: use pyproject.toml, declare version in python module --- otbtf/__init__.py | 5 +++-- pyproject.toml | 39 +++++++++++++++++++++++++++++++++++++++ setup.py | 35 ----------------------------------- 3 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/otbtf/__init__.py b/otbtf/__init__.py index 649817ff..633ccf1b 100644 --- a/otbtf/__init__.py +++ b/otbtf/__init__.py @@ -19,7 +19,9 @@ """ OTBTF python module """ -import pkg_resources + +__version__ = "5.0.0-rc2" + try: from otbtf.utils import read_as_np_arr, gdal_open # noqa from otbtf.dataset import Buffer, PatchesReaderBase, PatchesImagesReader, \ @@ -33,4 +35,3 @@ except ImportError: from otbtf.tfrecords import TFRecords # noqa from otbtf.model import ModelBase # noqa from otbtf import layers, ops # noqa -__version__ = pkg_resources.require("otbtf")[0].version diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..19f7c077 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,39 @@ +[build-system] +requires = ["setuptools>=61", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "otbtf" +description = "OTBTF: Orfeo ToolBox meets TensorFlow" +readme = "README.md" +requires-python = ">=3.8" +dynamic = ["version"] +keywords = [ + "remote sensing", + "otb", + "orfeotoolbox", + "orfeo toolbox", + "tensorflow", + "deep learning", + "machine learning" +] +authors = [ + { name = "Remi Cresson", email = "remi.cresson@inrae.fr" }, +] +urls = { "Homepage" = "https://github.com/remicres/otbtf" } +classifiers = [ + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Scientific/Engineering :: GIS", + "Topic :: Scientific/Engineering :: Image Processing", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent" +] +dependencies = [ "keras>=3" ] + +[tool.setuptools] +packages = ["otbtf"] + +[tool.setuptools.dynamic] +version = { attr = "otbtf.__version__" } diff --git a/setup.py b/setup.py deleted file mode 100644 index 15809664..00000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -import setuptools - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setuptools.setup( - name="otbtf", - version="5.0.0-rc1", - author="Remi Cresson", - author_email="remi.cresson@inrae.fr", - description="OTBTF: Orfeo ToolBox meets TensorFlow", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/remicres/otbtf", - classifiers=[ - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Scientific/Engineering :: GIS", - "Topic :: Scientific/Engineering :: Image Processing", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - ], - packages=setuptools.find_packages(), - python_requires=">=3.6", - keywords=["remote sensing", - "otb", - "orfeotoolbox", - "orfeo toolbox", - "tensorflow", - "deep learning", - "machine learning" - ], -) -- GitLab From 69a7e5eedb6a1aeab7ce2e03cb3a95bda8994b52 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 24 Feb 2025 12:09:33 +0100 Subject: [PATCH 311/317] CI: uncomment crc_book test --- .gitlab-ci.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 351acc95..60572b9c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -166,18 +166,19 @@ python_api: needs: ["ctest", "python_api"] #when: manual -# crc_book: -# extends: .applications_test_base -# variables: -# CRC_BOOK_TMP: /tmp/crc_book_tests_tmp -# script: -# - mkdir -p $CRC_BOOK_TMP -# - TMPDIR=$CRC_BOOK_TMP python -m pytest -v --junitxml=report_tutorial.xml test/tutorial_unittest.py -# after_script: -# - cp -r $CRC_BOOK_TMP $CI_PROJECT_DIR/artifacts_crc_book -# artifacts: -# paths: -# - $CI_PROJECT_DIR/artifacts_crc_book +crc_book: + extends: .applications_test_base + allow_failure: true + variables: + CRC_BOOK_TMP: /tmp/crc_book_tests_tmp + script: + - mkdir -p $CRC_BOOK_TMP + - TMPDIR=$CRC_BOOK_TMP python -m pytest -v --junitxml=report_tutorial.xml test/tutorial_unittest.py + after_script: + - cp -r $CRC_BOOK_TMP $CI_PROJECT_DIR/artifacts_crc_book + artifacts: + paths: + - $CI_PROJECT_DIR/artifacts_crc_book decloud: extends: .applications_test_base -- GitLab From a36160e3ece8802bff395a76215a4bee9fbc7bd6 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 24 Feb 2025 12:10:37 +0100 Subject: [PATCH 312/317] CI: removed setup.py --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ea680edc..e329abf0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -181,7 +181,7 @@ USER otbuser WORKDIR /src/otbtf COPY otbtf ./otbtf COPY tricks ./tricks -COPY README.md setup.py . +COPY README.md pyproject.toml . RUN pip install -e . # Install test packages for dev image -- GitLab From 9728f1b58072dd301460463e2030b3ef3129a5ca Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 24 Feb 2025 15:20:58 +0100 Subject: [PATCH 313/317] Remove legacy module "tricks" --- Dockerfile | 3 +- tricks/__init__.py | 96 --------------------------------------- tricks/ckpt2savedmodel.py | 54 ---------------------- 3 files changed, 1 insertion(+), 152 deletions(-) delete mode 100644 tricks/__init__.py delete mode 100755 tricks/ckpt2savedmodel.py diff --git a/Dockerfile b/Dockerfile index e329abf0..0aacaa5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -180,7 +180,6 @@ USER otbuser # Install OTBTF python module WORKDIR /src/otbtf COPY otbtf ./otbtf -COPY tricks ./tricks COPY README.md pyproject.toml . RUN pip install -e . @@ -192,5 +191,5 @@ WORKDIR /home/otbuser # Test python imports RUN python -c "import tensorflow, keras" RUN python -c "import otbApplication as otb; otb.Registry.CreateApplication('ImageClassifierFromDeepFeatures')" -RUN python -c "import otbtf, tricks" +RUN python -c "import otbtf" RUN python -c "from osgeo import gdal" diff --git a/tricks/__init__.py b/tricks/__init__.py deleted file mode 100644 index d22e7e96..00000000 --- a/tricks/__init__.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -# ========================================================================== -# -# Copyright 2018-2019 IRSTEA -# Copyright 2020-2021 INRAE -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0.txt -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ==========================================================================*/ -""" -This module contains a set of python functions to interact with geospatial data -and TensorFlow models. -Starting from OTBTF >= 3.0.0, tricks is only used as a backward compatible stub -for TF 1.X versions. -""" -import tensorflow.compat.v1 as tf -from deprecated import deprecated -from otbtf.utils import gdal_open, read_as_np_arr as read_as_np_arr_from_gdal_ds -tf.disable_v2_behavior() - - -@deprecated(version="3.0.0", reason="Please use otbtf.read_image_as_np() instead") -def read_image_as_np(filename, as_patches=False): - """ - Read a patches-image as numpy array. - :param filename: File name of the patches-image - :param as_patches: True if the image must be read as patches - :return 4D numpy array [batch, h, w, c] (batch = 1 when as_patches is False) - """ - - # Open a GDAL dataset - gdal_ds = gdal_open(filename) - - # Return patches - return read_as_np_arr_from_gdal_ds(gdal_ds=gdal_ds, as_patches=as_patches) - - -@deprecated(version="3.0.0", reason="Please consider using TensorFlow >= 2 to build your nets") -def create_savedmodel(sess, inputs, outputs, directory): - """ - Create a SavedModel from TF 1.X graphs - :param sess: The Tensorflow V1 session - :param inputs: List of inputs names (e.g. ["x_cnn_1:0", "x_cnn_2:0"]) - :param outputs: List of outputs names (e.g. ["prediction:0", "features:0"]) - :param directory: Path for the generated SavedModel - """ - print("Create a SavedModel in " + directory) - graph = tf.compat.v1.get_default_graph() - inputs_names = {i: graph.get_tensor_by_name(i) for i in inputs} - outputs_names = {o: graph.get_tensor_by_name(o) for o in outputs} - tf.compat.v1.saved_model.simple_save(sess, directory, inputs=inputs_names, outputs=outputs_names) - - -@deprecated(version="3.0.0", reason="Please consider using TensorFlow >= 2 to build and save your nets") -def ckpt_to_savedmodel(ckpt_path, inputs, outputs, savedmodel_path, clear_devices=False): - """ - Read a Checkpoint and build a SavedModel for some TF 1.X graph - :param ckpt_path: Path to the checkpoint file (without the ".meta" extension) - :param inputs: List of inputs names (e.g. ["x_cnn_1:0", "x_cnn_2:0"]) - :param outputs: List of outputs names (e.g. ["prediction:0", "features:0"]) - :param savedmodel_path: Path for the generated SavedModel - :param clear_devices: Clear TensorFlow devices positioning (True/False) - """ - tf.compat.v1.reset_default_graph() - with tf.compat.v1.Session() as sess: - # Restore variables from disk - model_saver = tf.compat.v1.train.import_meta_graph(ckpt_path + ".meta", clear_devices=clear_devices) - model_saver.restore(sess, ckpt_path) - - # Create a SavedModel - create_savedmodel(sess, inputs=inputs, outputs=outputs, directory=savedmodel_path) - - -@deprecated(version="3.0.0", reason="Please use otbtf.read_image_as_np() instead") -def read_samples(filename): - """ - Read a patches image. - @param filename: raster file name - """ - return read_image_as_np(filename, as_patches=True) - - -# Aliases for backward compatibility -# pylint: disable=invalid-name -CreateSavedModel = create_savedmodel -CheckpointToSavedModel = ckpt_to_savedmodel diff --git a/tricks/ckpt2savedmodel.py b/tricks/ckpt2savedmodel.py deleted file mode 100755 index ff22965f..00000000 --- a/tricks/ckpt2savedmodel.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# ========================================================================== -# -# Copyright 2018-2019 IRSTEA -# Copyright 2020-2021 INRAE -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0.txt -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ==========================================================================*/ -""" -This application converts a checkpoint into a SavedModel, that can be used in -TensorflowModelTrain or TensorflowModelServe OTB applications. -This is intended to work mostly with tf.v1 models, since the models in tf.v2 -can be more conveniently exported as SavedModel (see how to build a model with -keras in Tensorflow 2). -""" -import argparse -from tricks.tricks import ckpt_to_savedmodel - - -def main(): - """ - Main function - """ - parser = argparse.ArgumentParser() - parser.add_argument("--ckpt", help="Checkpoint file (without the \".meta\" extension)", required=True) - parser.add_argument("--inputs", help="Inputs names (e.g. [\"x_cnn_1:0\", \"x_cnn_2:0\"])", required=True, nargs='+') - parser.add_argument("--outputs", help="Outputs names (e.g. [\"prediction:0\", \"features:0\"])", required=True, - nargs='+') - parser.add_argument("--model", help="Output directory for SavedModel", required=True) - parser.add_argument('--clear_devices', dest='clear_devices', action='store_true') - parser.set_defaults(clear_devices=False) - params = parser.parse_args() - - ckpt_to_savedmodel(ckpt_path=params.ckpt, - inputs=params.inputs, - outputs=params.outputs, - savedmodel_path=params.model, - clear_devices=params.clear_devices) - - -if __name__ == "__main__": - main() -- GitLab From b059428b027553eace799b748d9010ad64e3f00d Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 3 Mar 2025 15:23:14 +0100 Subject: [PATCH 314/317] Disable unused tests --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 60572b9c..de1dfb57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -168,6 +168,7 @@ python_api: crc_book: extends: .applications_test_base + when: never allow_failure: true variables: CRC_BOOK_TMP: /tmp/crc_book_tests_tmp @@ -182,6 +183,7 @@ crc_book: decloud: extends: .applications_test_base + when: never allow_failure: true variables: DATASET_DECLOUD: https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download -- GitLab From 5705e22e2bd4ebfb69591a14b777325e2b839195 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 3 Mar 2025 15:23:42 +0100 Subject: [PATCH 315/317] CI: test sr4rs without otbtf tricks module --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de1dfb57..e6cd24a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -205,7 +205,7 @@ sr4rs: - wget -qO sr4rs_data.zip $DATASET_SR4RS - unzip -o sr4rs_data.zip - rm -rf sr4rs - - git clone https://github.com/remicres/sr4rs.git + - git clone https://github.com/LaTeleScop/sr4rs.git -b remove-tricks - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs - python -m pytest -v --junitxml=report_sr4rs.xml test/sr4rs_unittest.py -- GitLab From fad6a976ad6083988be18b9fcd42bf629eb2e67b Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 3 Mar 2025 15:26:48 +0100 Subject: [PATCH 316/317] CI: fix yaml file syntax error --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e6cd24a4..a6c9cd8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -168,7 +168,7 @@ python_api: crc_book: extends: .applications_test_base - when: never + when: manual allow_failure: true variables: CRC_BOOK_TMP: /tmp/crc_book_tests_tmp @@ -183,7 +183,7 @@ crc_book: decloud: extends: .applications_test_base - when: never + when: manual allow_failure: true variables: DATASET_DECLOUD: https://nextcloud.inrae.fr/s/aNTWLcH28zNomqk/download -- GitLab From 19b1327749599d9e26969ce15888d1470bf1793e Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Mon, 3 Mar 2025 18:15:53 +0100 Subject: [PATCH 317/317] CI: back to SR4RS master branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a6c9cd8f..35dfe142 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -205,7 +205,7 @@ sr4rs: - wget -qO sr4rs_data.zip $DATASET_SR4RS - unzip -o sr4rs_data.zip - rm -rf sr4rs - - git clone https://github.com/LaTeleScop/sr4rs.git -b remove-tricks + - git clone https://github.com/remicres/sr4rs.git - export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs - python -m pytest -v --junitxml=report_sr4rs.xml test/sr4rs_unittest.py -- GitLab