Skip to content

Commit

Permalink
Merge pull request #72 from FeTS-AI/fixing_docker_build_for_1.0
Browse files Browse the repository at this point in the history
Fixing docker build for 1.0
  • Loading branch information
sarthakpati authored Oct 13, 2023
2 parents e6163a6 + 25eb0ca commit 70d94d8
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 335 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
steps:
- name: Check out the repository
uses: actions/checkout@v3
# with:
with:
# lfs: false
# submodules: 'recursive'
submodules: 'true'

# - name: Check if the repository has changed
# run: ls -l
Expand All @@ -53,7 +53,7 @@ jobs:
run: |
echo "Free space:"
df -h
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
Expand Down Expand Up @@ -117,7 +117,9 @@ jobs:
# Run the image from the base entrypoint as a test
- name: Test container with entrypoint
# Run a tag we generated from the metadata extraction above -- they're all the same image, but echo it regardless just so we know.
run: docker run --rm ghcr.io/fets-ai/front-end:latest -h
run: |
docker run --rm ghcr.io/fets-ai/front-end:latest -h
docker run --entrypoint /Front-End/bin/install/appdir/usr/bin/BraTSPipeline ghcr.io/fets-ai/front-end:latest -h
# Push Docker image with Buildx (but don't push on PR)
# https://github.com/docker/build-push-action
Expand Down Expand Up @@ -148,4 +150,3 @@ jobs:
# # This step uses the identity token to provision an ephemeral certificate
# # against the sigstore community Fulcio instance.
# run: cosign sign ghcr.io/fets-ai/front-end@${{ steps.upload.outputs.digest }}

20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SET( ${PROJECT_NAME}_Variant "Full" ) # the particular variant of CaPTk (Full/Ne

SET( PROJECT_VERSION_MAJOR 1 )
SET( PROJECT_VERSION_MINOR 0 )
SET( PROJECT_VERSION_PATCH 2 )
SET( PROJECT_VERSION_PATCH 3 )
SET( PROJECT_VERSION_TWEAK )

# check for the string "nonRelease" in the PROJECT_VERSION_PATCH variable
Expand Down Expand Up @@ -581,15 +581,15 @@ IF( NOT BUILD_DOCUMENTATION_ONLY )
# copy weights from models
SET( DOWNLOAD_LINK "ftp://www.nitrc.org/home/groups/captk/downloads/models/torch/pt_3dresunet_ss_brainmagebrats_best.pt" )
SET( FILE_TO_EXTRACT "${PROJECT_SOURCE_DIR}/OpenFederatedLearning/bin/federations/weights/pt_3dresunet_ss_brainmagebrats_best.pt")
IF( NOT EXISTS "${FILE_TO_EXTRACT}" )

# download exe from url
MESSAGE( STATUS "Downloading weights for skull stripping" )
FILE(DOWNLOAD "${DOWNLOAD_LINK}" "${FILE_TO_EXTRACT}" TIMEOUT 1000000 STATUS STATUS_CODE SHOW_PROGRESS)
IF(NOT STATUS_CODE EQUAL 0)
MESSAGE(FATAL_ERROR "Failed to download skull-stripping weights. Status=${STATUS_CODE}")
ENDIF()
ENDIF()
# IF( NOT EXISTS "${FILE_TO_EXTRACT}" )

# # download exe from url
# MESSAGE( STATUS "Downloading weights for skull stripping" )
# FILE(DOWNLOAD "${DOWNLOAD_LINK}" "${FILE_TO_EXTRACT}" TIMEOUT 1000000 STATUS STATUS_CODE SHOW_PROGRESS)
# IF(NOT STATUS_CODE EQUAL 0)
# MESSAGE(FATAL_ERROR "Failed to download skull-stripping weights. Status=${STATUS_CODE}")
# ENDIF()
# ENDIF()

# copy network information
## todo: change to a direct installation so that git doesn't get confused that submodule has changed
Expand Down
76 changes: 46 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,58 +1,74 @@
FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime
FROM ghcr.io/fets-ai/fetstool_docker_dependencies:0.0.2.gpu

LABEL authors="FeTS_Admin <admin@fets.ai>"

RUN apt-get update -y
RUN apt-get update && apt-get update --fix-missing && apt-get install -y libnss3 libnspr4 libxcursor1 libxcursor-dev libasound2 libdbus-1-dev libglfw3-dev libgles2-mesa-dev ffmpeg libsm6 libxext6 python3.8 python3.8-venv python3.8-dev python3-setuptools

RUN apt-get install wget zip unzip software-properties-common gcc g++ make -y
# older python
RUN apt-get update -y && apt install -y --reinstall software-properties-common && add-apt-repository ppa:deadsnakes/ppa && apt update -y && apt install -y python3.7 python3.7-venv python3.7-dev python3-setuptools

RUN apt-get update -y && add-apt-repository ppa:deadsnakes/ppa && apt update -y && apt install python3.7 python3.7-venv python3.7-dev python3-setuptools ffmpeg libsm6 libxext6 -y
ENV PATH=/workspace/CaPTk/bin/qt/5.12.1/bin:/workspace/CaPTk/bin/qt/5.12.1/libexec:$PATH
ENV CMAKE_PREFIX_PATH=/workspace/CaPTk/bin/ITK-build:/workspace/CaPTk/bin/DCMTK-build:/workspace/CaPTk/bin/qt/5.12.1/lib/cmake/Qt5:$CMAKE_PREFIX_PATH
ENV SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True

# We will do git pull on the FeTS_Front-End master, because that is the repo using which the base image is made
# We will not do compiles on the PR because the idea is that the Xenial build will check the build status of
# the PR in any case.
RUN pwd && ls -l

ARG VERSION=0.0.9
WORKDIR /Front-End

# download installer
RUN wget https://fets.projects.nitrc.org/FeTS_${VERSION}_Installer.bin && chmod +x FeTS_${VERSION}_Installer.bin
COPY . .

# install FeTS and remove installer
RUN yes yes | ./FeTS_${VERSION}_Installer.bin --target ./FeTS_${VERSION} -- --cudaVersion 11 && rm -rf ./FeTS_${VERSION}_Installer.bin
RUN pwd && ls -l && mv ./data/Algorithms_for_fetsTool1.0.zip OpenFederatedLearning/submodules/fets_ai/ && cd OpenFederatedLearning/submodules/fets_ai/ && unzip -qq Algorithms_for_fetsTool1.0.zip && rm -rf Algorithms_for_fetsTool1.0.zip

ENV PATH=/workspace/FeTS_${VERSION}/squashfs-root/usr/bin/:$PATH
ENV LD_LIBRARY_PATH=/workspace/FeTS_${VERSION}/squashfs-root/usr/lib/:$LD_LIBRARY_PATH
ENV SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL="True"
RUN pwd && ls -l && mv ./data/GANDLF_for_fetsTool1.0.zip OpenFederatedLearning/submodules/fets_ai/Algorithms && cd OpenFederatedLearning/submodules/fets_ai/Algorithms && unzip -qq GANDLF_for_fetsTool1.0.zip && rm -rf GANDLF_for_fetsTool1.0.zip

## C++ build
RUN mkdir bin && cd bin && cmake -DCMAKE_INSTALL_PREFIX="./install/appdir/usr" -DITK_DIR="/workspace/CaPTk/bin/ITK-build" -DDCMTK_DIR="/workspace/CaPTk/bin/DCMTK-build" -DBUILD_TESTING=OFF .. && make -j$(nproc) && make install/strip

# ## Python package installation -- this is for the new docker image, which is much simpler
# RUN cd bin/install/appdir/usr/bin/ && python3.8 -m venv ./venv && ./venv/bin/pip install --upgrade pip wheel && ./venv/bin/pip install torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cpu && ./venv/bin/pip install -e . && ./venv/bin/pip install setuptools-rust Cython scikit-build scikit-learn openvino-dev==2023.0.1 && ./venv/bin/pip install -e .

# set up environment and install correct version of pytorch
RUN cd ./FeTS_${VERSION}/squashfs-root/usr/bin/OpenFederatedLearning && \
RUN echo "Setting up virtual environment for OpenFederatedLearning with base dependencies" && \
cd bin/install/appdir/usr/bin/OpenFederatedLearning && \
rm -rf ./venv && python3.7 -m venv ./venv && ./venv/bin/pip install Cython && \
./venv/bin/pip install --upgrade pip setuptools wheel setuptools-rust && \
./venv/bin/pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

RUN cd ./FeTS_${VERSION}/squashfs-root/usr/bin/OpenFederatedLearning && \
./venv/bin/pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html && \
./venv/bin/pip install wheel && \
./venv/bin/pip install scikit-build scikit-learn && \
./venv/bin/pip install SimpleITK==1.2.4 && \
./venv/bin/pip install protobuf==3.17.3 grpcio==1.30.0 && \
./venv/bin/pip install opencv-python==4.2.0.34
# ./venv/bin/pip install python-gdcm

RUN cd ./FeTS_${VERSION}/squashfs-root/usr/bin/OpenFederatedLearning && \
./venv/bin/pip install setuptools --upgrade && \
./venv/bin/pip install opencv-python==4.2.0.34 && \
./venv/bin/pip install scikit-build scikit-learn && \
make install_openfl && \
make install_fets && \
./venv/bin/pip install -e ./submodules/fets_ai/Algorithms/GANDLF && \
cd ../LabelFusion && \
rm -rf venv && python3.7 -m venv ./venv && \
make install_openfl_pytorch

RUN echo "Setting up virtual environment for OpenFederatedLearning with second-level dependencies" && \
cd bin/install/appdir/usr/bin/OpenFederatedLearning && \
./venv/bin/pip install ../BrainMaGe && \
./venv/bin/pip install ./submodules/fets_ai/Algorithms && \
./venv/bin/pip install -e ./submodules/fets_ai/Algorithms/GANDLF

RUN echo "Installing separate environment for LabelFusion" && \
cd bin/install/appdir/usr/bin/LabelFusion && \
rm -rf venv && python3.8 -m venv ./venv && \
./venv/bin/pip install --upgrade pip setuptools wheel setuptools-rust && \
./venv/bin/pip install -e .

RUN echo "Downloading model weights" && \
cd bin/install/appdir/usr/data && \
wget https://upenn.box.com/shared/static/f7zt19d08c545qt3tcaeg7b37z6qafum.zip -O nnunet.zip && \
unzip -qq nnunet.zip && rm -rf nnunet.zip && \
wget https://upenn.box.com/shared/static/hhvn8nb9xtz6nxcilmdl8kbx9n1afkdu.zip -O ./fets_consensus_models.zip && \
unzip -qq fets_consensus_models.zip && rm -rf fets_consensus_models.zip

### put together a data example that is already aligned and ready to invoke the brain extraction and tumor segmentation

# set up the docker for GUI
ENV LD_LIBRARY_PATH=/CaPTk/bin/qt/5.12.1/lib:$LD_LIBRARY_PATH
ENV PATH=/Front-End/bin/install/appdir/usr/bin/:$PATH
ENV QT_X11_NO_MITSHM=1
ENV QT_GRAPHICSSYSTEM="native"

RUN echo "Env paths\n" && echo $PATH && echo $LD_LIBRARY_PATH

# define entry point
ENTRYPOINT ["/workspace/FeTS_0.0.9/squashfs-root/usr/bin/FeTS_CLI_Inference"]
ENTRYPOINT ["/Front-End/bin/install/appdir/usr/bin/FeTS_CLI_Segment"]
Binary file added data/Algorithms_for_fetsTool1.0.zip
Binary file not shown.
Binary file added data/GANDLF_for_fetsTool1.0.zip
Binary file not shown.
Loading

0 comments on commit 70d94d8

Please sign in to comment.