Skip to content
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

RuntimeError: Conv3D is not supported on MPS #385

Open
tlnagy opened this issue Jan 27, 2025 · 4 comments
Open

RuntimeError: Conv3D is not supported on MPS #385

tlnagy opened this issue Jan 27, 2025 · 4 comments

Comments

@tlnagy
Copy link

tlnagy commented Jan 27, 2025

Attempting to segment a 3D image using plant-seg master gives RuntimeError: Conv3D is not supported on MPS.

I believe this is due to the v2.2.2 version of pytorch that is currently being installed. From my sleuthing, it looks like this is potentially resolved in pytorch >2.3.0 because pytorch/pytorch#114183 was merged.

@qin-yu
Copy link
Collaborator

qin-yu commented Jan 27, 2025

If you install PlantSeg with conda/mamba, did you try mamba install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 -c pytorch [ref]? I don't have access to a Mac at the moment.

@tlnagy
Copy link
Author

tlnagy commented Jan 27, 2025

Unfortunately, I keep running into conflict resolution issues. I first ran tnagy in plant-seg on  qy/fix-pred-advanced [!] ➜ mamba create -n plant-seg2 -c pytorch -c conda-forge python=3.11 pytorch::pytorch plant-seg --no-channel-priority followed by mamba install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 -c pytorch and I got the following error:

tnagy in plant-seg on  qy/fix-pred-advanced [!] ➜  mamba create -n plant-seg2 -c pytorch -c conda-forge python=3.11 pytorch::pytorch plant-seg --no-channel-priority
tnagy in plant-seg on  qy/fix-pred-advanced [!] ➜  mamba install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 -c pytorch
pytorch/noarch                                              Using cache
pytorch/osx-arm64                                           Using cache
DEPRECATION: --no-python-version-warning is deprecated. pip 25.1 will enforce this behaviour change. A possible replacement is to remove the flag as it's a no-op. Discussion can be found at https://github.com/pypa/pip/issues/13154

Pinned packages:

  - python=3.11

error    libmamba Could not solve for environment specs
    The following packages are incompatible
    ├─ pytorch ==2.3.1 * is not installable because there are no viable options
    │  ├─ pytorch 2.3.1 would require
    │  │  └─ python >=3.10,<3.11.0a0 *, which does not exist (perhaps a missing channel);
    │  ├─ pytorch 2.3.1 would require
    │  │  └─ llvm-openmp <16 *, which does not exist (perhaps a missing channel);
    │  ├─ pytorch 2.3.1 would require
    │  │  └─ python >=3.12,<3.13.0a0 *, which does not exist (perhaps a missing channel);
    │  ├─ pytorch 2.3.1 would require
    │  │  └─ python >=3.8,<3.9.0a0 *, which does not exist (perhaps a missing channel);
    │  └─ pytorch 2.3.1 would require
    │     └─ python >=3.9,<3.10.0a0 *, which does not exist (perhaps a missing channel);
    ├─ torchaudio ==2.3.1 * is not installable because there are no viable options
    │  ├─ torchaudio 2.3.1 would require
    │  │  └─ pytorch ==2.3.1 *, which cannot be installed (as previously explained);
    │  ├─ torchaudio 2.3.1 would require
    │  │  └─ python >=3.10,<3.11.0a0 *, which does not exist (perhaps a missing channel);
    │  ├─ torchaudio 2.3.1 would require
    │  │  └─ python >=3.12,<3.13.0a0 *, which does not exist (perhaps a missing channel);
    │  ├─ torchaudio 2.3.1 would require
    │  │  └─ python >=3.8,<3.9.0a0 *, which does not exist (perhaps a missing channel);
    │  └─ torchaudio 2.3.1 would require
    │     └─ python >=3.9,<3.10.0a0 *, which does not exist (perhaps a missing channel);
    └─ torchvision ==0.18.1 * is not installable because there are no viable options
       ├─ torchvision 0.18.1 would require
       │  └─ pytorch ==2.3.1 *, which cannot be installed (as previously explained);
       ├─ torchvision 0.18.1 would require
       │  └─ python >=3.10,<3.11.0a0 *, which does not exist (perhaps a missing channel);
       ├─ torchvision 0.18.1 would require
       │  └─ python >=3.12,<3.13.0a0 *, which does not exist (perhaps a missing channel);
       ├─ torchvision 0.18.1 would require
       │  └─ python >=3.8,<3.9.0a0 *, which does not exist (perhaps a missing channel);
       └─ torchvision 0.18.1 would require
          └─ python >=3.9,<3.10.0a0 *, which does not exist (perhaps a missing channel).
critical libmamba Could not solve for environment specs

@qin-yu
Copy link
Collaborator

qin-yu commented Jan 27, 2025

Maybe install PyTorch first:

mamba create -n plant-seg2 pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 -c pytorch
mamba install -c conda-forge plant-seg

@qin-yu
Copy link
Collaborator

qin-yu commented Jan 28, 2025

Hi @tlnagy I tried to use PyTorch 2.3.1, but there is a new error saying MPS doesn't support yet another operation: 'The operator 'aten::max_pool3d_with_indices' is not currently implemented for the MPS device. and this is not solved by PyTorch yet: pytorch/pytorch#77764. I doubt if it make sense to set a PyTorch or Python version just for Conv3D. But thank you for reporting this!

Full log:

INFO: P [MainThread] 2025-01-29 00:08:06,718 plantseg - Logger configured at initialisation. PlantSeg logger name: plantseg
INFO: P [MainThread] 2025-01-29 00:08:07,202 plantseg.utils - You are using the latest version of PlantSeg: 2.0.0b2.
INFO: N [MainThread] 2025-01-29 00:08:58,897 Run viewer - Plantseg is ready!
2025-01-29 00:08:59.234 python3.12[87312:117850972] +[IMKClient subclass]: chose IMKClient_Modern
2025-01-29 00:08:59.234 python3.12[87312:117850972] +[IMKInputSession subclass]: chose IMKInputSession_Modern
2025-01-29 00:09:03.098 python3.12[87312:117850972] The class 'NSOpenPanel' overrides the method identifier.  This method is implemented by class 'NSWindow'
INFO: N [MainThread] 2025-01-29 00:09:21,341 Task - import_image_task started
INFO: N [MainThread] 2025-01-29 00:09:22,128 Task - import_image_task complete in 0.79s
INFO: N [MainThread] 2025-01-29 00:09:35,929 Task - unet_prediction_task started
INFO: P [Dummy-1] 2025-01-29 00:09:36,862 plantseg.functionals.prediction.prediction - Zoo prediction: Running model from PlantSeg official zoo.
INFO: P [Dummy-1] 2025-01-29 00:09:36,898 plantseg.functionals.prediction.prediction - Computing theoretical minimum halo from model.
WARNING: P [Dummy-1] 2025-01-29 00:09:39,259 plantseg.functionals.prediction.utils.size_finder - Encountered 'The operator 'aten::max_pool3d_with_indices' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.' at patch shape (416, 416, 416), unexpected but continuing.
WARNING: P [Dummy-1] 2025-01-29 00:10:04,776 plantseg.functionals.prediction.utils.size_finder - Encountered 'The operator 'aten::max_pool3d_with_indices' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.' at patch shape (208, 208, 208), unexpected but continuing.
WARNING: P [Dummy-1] 2025-01-29 00:10:05,524 plantseg.functionals.prediction.utils.size_finder - Encountered 'The operator 'aten::max_pool3d_with_indices' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.' at patch shape (112, 112, 112), unexpected but continuing.
WARNING: P [Dummy-1] 2025-01-29 00:10:06,802 plantseg.functionals.prediction.utils.size_finder - Encountered 'The operator 'aten::max_pool3d_with_indices' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.' at patch shape (64, 64, 64), unexpected but continuing.
WARNING: P [Dummy-1] 2025-01-29 00:10:07,113 plantseg.functionals.prediction.utils.size_finder - Encountered 'The operator 'aten::max_pool3d_with_indices' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.' at patch shape (32, 32, 32), unexpected but continuing.
INFO: P [Dummy-1] 2025-01-29 00:10:07,136 plantseg.functionals.prediction.prediction - For raw in shape (263, 1024, 1024): set patch shape (-56, -56, -56), set halo shape (44, 44, 44)
WARNING: P [Dummy-1] 2025-01-29 00:10:07,187 plantseg.functionals.prediction.utils.size_finder - Encountered 'The operator 'aten::max_pool3d_with_indices' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.' at batch size 1, unexpected but continuing with halved batch size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants