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

Issues with Cellpose on macOS using the MPS Backend #1063

Open
Vijayishwerj opened this issue Nov 23, 2024 · 0 comments
Open

Issues with Cellpose on macOS using the MPS Backend #1063

Vijayishwerj opened this issue Nov 23, 2024 · 0 comments
Labels
install install help

Comments

@Vijayishwerj
Copy link

Hello Cellpose Team,

I am experiencing several issues while using Cellpose for segmentation and training models on my Mac Studio M2 Ultra. I would appreciate your guidance to resolve these problems. Below are the details:

Environment Information

•	Operating System: macOS
•	Device: Mac Studio M2 Ultra
•	Python Version: 3.11.10
•	Cellpose Version: 3.1.0
•	Torch Version: 2.5.1
•	Backend: MPS (Metal Performance Shaders)

Issues Faced

1.	GPU Incompatibility with Sparse Tensor Operations:
•	Error: NotImplementedError: Could not run 'aten::_sparse_coo_tensor_with_dims_and_tensors' with arguments from the 'SparseMPS' backend....
•	This suggests that the MPS backend lacks support for sparse tensor operations, leading to failures during segmentation.
2.	Fallback to CPU:
•	When the MPS backend fails, computation falls back to the CPU.
•	However, warnings about the missing MKL optimizations slow down performance significantly:  WARNING: MKL version on torch not working/installed - CPU version will be slightly slower.


3.	GPU Training Issues:
•	The latest version of Cellpose mandates GPU use for training. However, the MPS backend does not complete tasks, and training without a GPU seems impossible.
4.	Performance Bottleneck:
•	The fallback to CPU leads to extremely long training times, making it impractical for large datasets.

Run Logs

Attached below is the terminal output with verbose mode enabled, showing the errors and relevant information:
• MPS backend available: torch.backends.mps.is_available() returns True.
• The operation fails during sparse tensor computation (aten::_sparse_coo_tensor_with_dims_and_tensors).

NotImplementedError: Could not run 'aten::_sparse_coo_tensor_with_dims_and_tensors' with arguments from the 'SparseMPS' backend. ####

1.	Verified that the MPS backend is correctly installed and available.
2.	Updated to the latest versions of Cellpose, Python, and PyTorch.
3.	Attempted fallback to the CPU but encountered performance issues due to lack of MKL support.
4.	Explored replacing sparse operations with dense ones but encountered compatibility constraints.

Request for Assistance

1.	GPU Support:
•	Are there plans to improve sparse tensor compatibility for the MPS backend in future versions?
@Vijayishwerj Vijayishwerj added the install install help label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
install install help
Projects
None yet
Development

No branches or pull requests

1 participant