Skip to content

Running nnUnet inference on Apple GPU #87

@valosekj

Description

@valosekj

I tried to install nnU-Net locally on my new MacBook using:

pip install -r packaging_lumbar_rootlets/requirements.txt

But I got this error when running `run_inference_single_subject.py`
 python ~/code/model-spinal-rootlets/packaging_lumbar_rootlets/run_inference_single_subject.py -h
Traceback (most recent call last):
  File "/Users/valosek/code/model-spinal-rootlets/packaging_ventral_rootlets/run_inference_single_subject.py", line 31, in <module>
    from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor
  File "/Users/valosek/miniconda3/envs/nnunet/lib/python3.9/site-packages/nnunetv2/inference/predict_from_raw_data.py", line 22, in <module>
    from nnunetv2.inference.data_iterators import PreprocessAdapterFromNpy, preprocessing_iterator_fromfiles, \
  File "/Users/valosek/miniconda3/envs/nnunet/lib/python3.9/site-packages/nnunetv2/inference/data_iterators.py", line 12, in <module>
    from nnunetv2.preprocessing.preprocessors.default_preprocessor import DefaultPreprocessor
  File "/Users/valosek/miniconda3/envs/nnunet/lib/python3.9/site-packages/nnunetv2/preprocessing/preprocessors/default_preprocessor.py", line 25, in <module>
    from nnunetv2.preprocessing.cropping.cropping import crop_to_nonzero
  File "/Users/valosek/miniconda3/envs/nnunet/lib/python3.9/site-packages/nnunetv2/preprocessing/cropping/cropping.py", line 5, in <module>
    from acvl_utils.cropping_and_padding.bounding_boxes import get_bbox_from_mask, crop_to_bbox, bounding_box_to_slice
  File "/Users/valosek/miniconda3/envs/nnunet/lib/python3.9/site-packages/acvl_utils/cropping_and_padding/bounding_boxes.py", line 5, in <module>
    import blosc2
  File "/Users/valosek/miniconda3/envs/nnunet/lib/python3.9/site-packages/blosc2/__init__.py", line 86, in <module>
    from .blosc2_ext import (
  File "blosc2_ext.pyx", line 1, in init blosc2.blosc2_ext
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
So, I tried `venv_sct`, and it worked!
source $SCT_DIR/python/etc/profile.d/conda.sh
conda activate venv_sct
python ~/code/model-spinal-rootlets/packaging_lumbar_rootlets/run_inference_single_subject.py -h

But since it took several minutes to run inference on a single image using CPU, I checked the status of accelaring nnunet on Apple's GPUs and found this super relevant PR; continued in the next comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions