OmniParser icon indicating copy to clipboard operation
OmniParser copied to clipboard

Add support for Apple Silicon (torch.mps)

Open kiyokiku opened this issue 10 months ago • 5 comments

This PR adds support for Apple Silicon backend (torch.mps).

  • Added support for torch.mps, enabling execution on Apple Silicon devices.
  • Updated the device detection order from (cuda -> cpu) to (cuda -> mps -> cpu).

This PR is expected to resolve #187.

kiyokiku avatar Feb 22 '25 19:02 kiyokiku

@microsoft-github-policy-service agree

kiyokiku avatar Feb 22 '25 19:02 kiyokiku

Has anyone successfully used the GPU of the Apple M1 self-developed chip in the MacBook? I still can't use GPU acceleration properly here

zhenhuaplan avatar Feb 25 '25 09:02 zhenhuaplan

@zhenhuaplan

Could you run the following Python script and let me know the output?

import torch

print("torch.backends.mps:", torch.backends.mps.is_available())
print("torch.mps:", torch.mps.is_available())

On my environment, the output is as follows:

>>> print("torch.backends.mps:", torch.backends.mps.is_available())
torch.backends.mps: True
>>> print("torch.mps:", torch.mps.is_available())
torch.mps: True

kiyokiku avatar Feb 26 '25 15:02 kiyokiku

@zhenhuaplan

Could you run the following Python script and let me know the output?

import torch

print("torch.backends.mps:", torch.backends.mps.is_available())
print("torch.mps:", torch.mps.is_available())

On my environment, the output is as follows:

>>> print("torch.backends.mps:", torch.backends.mps.is_available())
torch.backends.mps: True
>>> print("torch.mps:", torch.mps.is_available())
torch.mps: True

@kiyokiku I am now using torch==2.4.0 instead of torch==2.6.0, and now I can use mps, torch.backends.mps.is_available() results in True, torch.mps.is_available() results in an error, This is because torch has no mps attribute

All in all, I can now use the GPU for acceleration, thanks

zhenhuaplan avatar Feb 27 '25 01:02 zhenhuaplan

For compatibility, I have replaced torch.mps with torch.backends.mps.

kiyokiku avatar Feb 27 '25 09:02 kiyokiku