-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImportError: cannot import name 'mmr_auxe' from partially initialized module 'niftypet.nipet' #48
Comments
Hey @Melissa1909 - I hadn't tested installing within Docker before. NiftyPET detects your GPUs during the build process, but unfortunately Docker doesn't expose GPUs during build time (you can't Unfortunately the hack for now would be to install at runtime ( # CUDA development toolkit
FROM nvidia/cuda:12.2.0-devel-ubuntu22.04
# Install Python3 dev depedencies
RUN apt-get update -qq && apt-get install -yqq python3-venv python3-dev && apt-get clean
# Create and activate a virtual environment
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
# Install useful Python packages inside virtual environment
RUN pip install --no-cache numpy scipy scikit-image matplotlib nibabel pydicom pandas ipykernel ipywidgets brainweb spm12
# Install NiftyPET
ENV HMUDIR=/mmr_hardwareumaps
# install after starting the container (requires --gpus all)
COPY <<EOF /entry.sh
#!/bin/bash
set -euo pipefail
if test -z "\$(pip list | grep nipet)"; then
echo 'installing NiftyPET (requires `docker run --gpus all`)'
pip install --no-cache nimpa[cuda,dcm2niix,niftyreg] nipet
fi
exec "\$@"
EOF
RUN chmod 755 /entry.sh
ENTRYPOINT ["/entry.sh"]
CMD ["/bin/bash"] |
☝️ @pjmark you might have to tackle the last bullet point as I don't have much time :) |
nevermind - I just tested and I think NIPET does install properly after all... Here's what I'm using @Melissa1909: # CUDA development toolkit (~7GB)
FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 as build
# Install Python3 dev depedencies
RUN apt-get update -qq && apt-get install -yqq python3-venv python3-dev && apt-get clean
# Create and activate a virtual environment
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
# Install NiftyPET
ENV HMUDIR=/mmr_hardwareumaps
RUN pip install --no-cache 'nimpa[cuda,dcm2niix,niftyreg]>=2.6.3' nipet
# Make a smaller image without development toolkit (~1GB)
FROM nvidia/cuda:12.2.0-base-ubuntu22.04 as nipet
RUN apt-get update -qq && apt-get install -yqq python3-venv python3-dev && apt-get clean
# Copy virtual environment & NiftyPET build artefacts
COPY --from=build --link /venv /venv
ENV PATH="/venv/bin:$PATH"
ENV HMUDIR=/mmr_hardwareumaps
COPY --from=build --link /root/.niftypet /root/.niftypet
# Install useful Python packages
RUN pip install --no-cache numpy scipy scikit-image matplotlib nibabel pydicom pandas ipykernel ipywidgets brainweb spm12 |
Dear Developers, regarding this exact docker installation, I was unable to access nipet and nimpa as there are some resources lacking, giving me this exact error code: NiftyPET resources file <resources.py> could not be imported.
|
I can't reproduce your error @VikNeu ... can run |
Hi @casperdcl, Maybe we should mention that our Linux machines (with NVIDIA GPU) in the office due not have access to the Internet. That's why we have to build a container to ship the ready-to-use software from other machines to it. However, I have created the image on a Windows without a GPU, whereas the image was tested on the aforementioned Linux - might that cause the installation problems? Thank you for your help! |
Based on I've just pushed this to https://github.com/NiftyPET/NIPET/pkgs/container/nipet so you can use the same image: > docker run --rm --gpus all -it ghcr.io/niftypet/nipet /bin/bash
root@f42f473070d9:/# ls $HOME/.niftypet
__pycache__ resources.py
root@f42f473070d9:/# pip list | grep -E 'nipet|nimpa'
nimpa 2.6.3
nipet 2.2.0 |
The link does not yet exist unfortunately... |
try now? |
Worked, could download it! However, when using your image, I once had this problem using another image that required having some folder in the home directory that I could just copy to my Linux machine (netneurolab/neuromaps#69). Could there be a workaround like that? I can't find .niftypet in my home directory either though. |
Hi @casperdcl and @Melissa1909, I had the same problem, but I installed it on Linux using conda. |
Dear developers,
I have installed niftypet inside a docker container using the attached Dockerfile. However, if I start it and enter the Python3 venv (/venv/bin/python3) and import nipet from niftypet as given in the example scripts (from niftypet import nipet), I get the following error:
I have also tried to install nipet via niftypet and directly via pip but the error still occurs. Any feedback or suggestions are appreciated!
Best, Melissa
Dockerfile.txt
The text was updated successfully, but these errors were encountered: