WCHN / CTseg

Brain CT image segmentation, normalisation, skull-stripping and total brain/intracranial volume computation.
GNU General Public License v3.0
62 stars 16 forks source link

Docker build error: /opt/spm/spm: not found #29

Closed lyndonboone closed 4 months ago

lyndonboone commented 4 months ago

Hi there,

I'm trying to build a Docker image from the CTseg Dockerfile in WSL2 version 20.04. When I execute docker build -t ubuntu:ctseg -f CTseg/Dockerfile . I get the following error:

docker build -t ubuntu:ctseg -f CTseg/Dockerfile .
[+] Building 82.3s (7/8)
 => [internal] load build definition from Dockerfile                                                                            0.0s
 => => transferring dockerfile: 38B                                                                                             0.0s
 => [internal] load .dockerignore                                                                                               0.0s
 => => transferring context: 2B                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/ubuntu:22.04                                                                81.3s
 => [1/5] FROM docker.io/library/ubuntu:22.04@sha256:340d9b015b194dc6e2a13938944e0d016e57b9679963fdeb9ce021daac430221           0.0s
 => CACHED [2/5] RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install      unzip xorg wget  && apt-get clea  0.0s
 => CACHED [3/5] RUN mkdir /opt/mcr_install  && mkdir /opt/mcr  && wget --progress=bar:force -P /opt/mcr_install https://ssd.m  0.0s
 => ERROR [4/5] RUN wget --no-check-certificate --progress=bar:force -P /opt https://www.fil.ion.ucl.ac.uk/spm/download/restri  0.9s
------
 > [4/5] RUN wget --no-check-certificate --progress=bar:force -P /opt https://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/tbx/spm_latest_tbx_Linux_R2019b.zip  && unzip -q /opt/spm_latest_tbx_Linux_R2019b.zip -d /opt  && rm -f /opt/spm_latest_tbx_Linux_R2019b.zip  && /opt/spm/spm function exit  && chmod +x /opt/spm/spm:
#7 0.398 --2024-07-03 15:28:14--  https://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/tbx/spm_latest_tbx_Linux_R2019b.zip
#7 0.404 Resolving www.fil.ion.ucl.ac.uk (www.fil.ion.ucl.ac.uk)... 193.62.66.18
#7 0.416 Connecting to www.fil.ion.ucl.ac.uk (www.fil.ion.ucl.ac.uk)|193.62.66.18|:443... connected.
#7 0.740 HTTP request sent, awaiting response... 200 OK
#7 0.912 Length: 869 [application/zip]
#7 0.914 Saving to: '/opt/spm_latest_tbx_Linux_R2019b.zip'
#7 0.914
spm_latest_tbx_Linu 100%[===================>]     869  --.-KB/s    in 0s
#7 0.914
#7 0.914 2024-07-03 15:28:15 (319 MB/s) - '/opt/spm_latest_tbx_Linux_R2019b.zip' saved [869/869]
#7 0.914
#7 0.922 /bin/sh: 1: /opt/spm/spm: not found
------
executor failed running [/bin/sh -c wget --no-check-certificate --progress=bar:force -P /opt https://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/tbx/spm_${SPM_REVISION}_tbx_Linux_${MATLAB_VERSION}.zip  && unzip -q /opt/spm_${SPM_REVISION}_tbx_Linux_${MATLAB_VERSION}.zip -d /opt  && rm -f /opt/spm_${SPM_REVISION}_tbx_Linux_${MATLAB_VERSION}.zip  && /opt/spm/spm function exit  && chmod +x /opt/spm/spm]: exit code: 127

Do you know if there's anything I can do to get around this error? Is the CTseg Docker image compatible with WSL2? Thanks so much for all your help!

jono3030 commented 4 months ago

Hi @lyndonboone

I had a quick look at your issue and it appears that the dev-version zip file that is linked in the Dockerfile does not contain the SPM standalone binary hence why you get the 'not found' error. I have no idea about the different versions of SPM and what you are planning on doing with it but I modified the Dockerfile to install SPM12 version r7771 for MATLAB R2019b and it's working on maghz. This version might work in the WSL2 as well.

Here's the modified Dockerfile:

FROM ubuntu:22.04

LABEL org.opencontainers.image.authors="SPM <fil.spm@ucl.ac.uk>"
LABEL org.opencontainers.image.source="https://github.com/WCHN/CTseg"

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
     unzip xorg wget \
 && apt-get clean \
 && rm -rf \
     /tmp/hsperfdata* \
     /var/*/apt/*/partial \
     /var/lib/apt/lists/* \
     /var/log/apt/term*

# Install MATLAB MCR in /opt/mcr/
ENV MATLAB_VERSION R2019b
ENV MCR_VERSION v97
ENV MCR_UPDATE 9
RUN mkdir /opt/mcr_install \
 && mkdir /opt/mcr \
 && wget --progress=bar:force -P /opt/mcr_install https://ssd.mathworks.com/supportfiles/downloads/${MATLAB_VERSION}/Release/${MCR_UPDATE}/deployment_files/installer/complete/glnxa64/MATLAB_Runtime_${MATLAB_VERSION}_Update_${MCR_UPDATE}_glnxa64.zip \
 && unzip -q /opt/mcr_install/MATLAB_Runtime_${MATLAB_VERSION}_Update_${MCR_UPDATE}_glnxa64.zip -d /opt/mcr_install \
 && /opt/mcr_install/install -destinationFolder /opt/mcr -agreeToLicense yes -mode silent \
 && rm -rf /opt/mcr_install /tmp/*

# Install SPM Standalone in /opt/spm12/
ENV SPM_VERSION r7771
ENV OS_VERSION Linux
ENV SPM_ZIP spm12_${SPM_VERSION}_${OS_VERSION}_${MATLAB_VERSION}.zip
ENV LD_LIBRARY_PATH /opt/mcr/${MCR_VERSION}/runtime/glnxa64:/opt/mcr/${MCR_VERSION}/bin/glnxa64:/opt/mcr/${MCR_VERSION}/sys/os/glnxa64:/opt/mcr/${MCR_VERSION}/sys/opengl/lib/glnxa64:/opt/mcr/${MCR_VERSION}/extern/bin/glnxa64
ENV MCR_INHIBIT_CTF_LOCK 1
ENV SPM_HTML_BROWSER 0
# Running SPM once with "function exit" tests the succesfull installation *and*
# extracts the ctf archive which is necessary if singularity is going to be
# used later on, because singularity containers are read-only.
# Also, set +x on the entrypoint for non-root container invocations
RUN wget --no-check-certificate --progress=bar:force -P /opt https://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/spm12/${SPM_ZIP} \
 && unzip -q /opt/${SPM_ZIP} -d /opt \
 && rm -f /opt/${SPM_ZIP} \
 && /opt/spm12/spm12 function exit \
 && chmod +x /opt/spm12/spm12

# Check that CTseg model files are installed and download them otherwise
RUN /opt/spm12/spm12 eval "try,spm_CTseg(1);end"

# Configure entry point
ENTRYPOINT ["/opt/spm12/spm12"]
CMD ["--help"]

Just build it with docker build -t spm12:r7771 . from the directory the Dockerfile is in and execute with e.g. docker run -it --rm spm12:r7771 -v.

@brudfors I don't know what the intentions were with the Dockerfile re: the version of SPM but I saw SPM12 referenced in a comment in the Dockerfile. Lmk if this would be a useful fix for the repo and I'll open a PR for it. Would it otherwise be a viable option to just add the dev standalone binary to the dev version zips?

Cheers!

brudfors commented 4 months ago

Thank you for reporting @lyndonboone. I just pushed a fix to the Dockerfile, could you please try and see if it resolved your issue?

Thanks for looking at this @jono3030. The SPM binaries that you proposed using does unfortunately not contain the CTseg application. I pushed a fix that uses a version of SPM that does (and changed where it is being hosted).

lyndonboone commented 4 months ago

Thanks a million @jono3030 and @brudfors !! I just retried after pulling the new fix and it appears to be running on our maghz linux server and WSL2.