Skip to content

Support MPS (or CPU) as well as CUDA#1

Merged
ksugar merged 2 commits into
ksugar:mainfrom
petebankhead:mac
Jun 11, 2023
Merged

Support MPS (or CPU) as well as CUDA#1
ksugar merged 2 commits into
ksugar:mainfrom
petebankhead:mac

Conversation

@petebankhead
Copy link
Copy Markdown
Contributor

This looks great!

I wanted to test it, but I use a Mac and so don't have CUDA.

Not sure if it's the best way to do it, but in case CUDA isn't available this PR tries to switch to use the MPS backend if possible, or CPU as a last resort.

That change was enough for me to get https://github.com/ksugar/qupath-extension-sam working on my Mac.

petebankhead and others added 2 commits June 11, 2023 15:03
Choose device based upon whether CUDA or MPS is available, so that macOS can also be supported.
See https://pytorch.org/docs/stable/notes/mps.html
As we now support mps and cpu, cudatoolkit becomes optional.
@ksugar
Copy link
Copy Markdown
Owner

ksugar commented Jun 11, 2023

Hi @petebankhead , thank you for the PR!
I'm glad that you have tried this and have made it compatible with native Mac.
I tested it on my Mac environment, and it works well.
I have just made minor changes in README to note that cudatoolkit is optional.
I really appreciate your contribution!

@ksugar ksugar merged commit 799b863 into ksugar:main Jun 11, 2023
@petebankhead petebankhead deleted the mac branch June 11, 2023 14:57
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

Successfully merging this pull request may close these issues.

2 participants