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

support GPU? #6

Open
PeaceByte opened this issue Nov 9, 2024 · 9 comments
Open

support GPU? #6

PeaceByte opened this issue Nov 9, 2024 · 9 comments

Comments

@PeaceByte
Copy link

The current script can only run on Mac if config.computeUnits = .cpuOnly is set.
How can I change it to support GPU?
Thank you!

@mallman
Copy link
Owner

mallman commented Nov 13, 2024

I run this model on the GPU on my MacBook Pro M1. Why do you say it only runs on CPU?

@PeaceByte
Copy link
Author

When initializing the model with .cpuAndGPU, it crashes and throws the following error.using:/AppleInternal/Library/BuildRoots/4b66fb3c-7dd0-11ef-b4fb-4a83e32a47e1/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShadersGraph/mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphExecutable.mm, line 129: error 'Error: unhandled platform for MPSGraph serialization'

The only way it works is by
lazy var config: MLModelConfiguration = {
let config = MLModelConfiguration()
config.computeUnits = .cpuOnly
return config
}()

@mallman
Copy link
Owner

mallman commented Nov 18, 2024

Hmmm... I've never seen that error. What hardware and macOS version are you running?

@PeaceByte
Copy link
Author

I’m running macOS 15.1 (24B83) both a MacBook Air M1 and a MacBook Pro M1 Pro.The issue occurs on both machines, so it seems to be consistent across the hardware.”

Xcode Version 16.1 (16B40)

Do it need to adapt it for macOS 15.1 or Xcode 16.1?

@mallman
Copy link
Owner

mallman commented Nov 19, 2024

I'm also running macOS 15.1 and Xcode 16.1. Hmmm...

I tried rebuilding LaMa.mlpackage and ran into an error based on a bad python package version. So I updated requirements.txt with the output of pip freeze from a known working env. Then I could rebuild the model.

I was able to successfully use the model I built. I suggest doing a git pull, deleting your conda env (or creating a new one) and rerunning pip install -y requirements.txt. Rebuild the model with that environment and let me know if that model works for you.

@mallman
Copy link
Owner

mallman commented Nov 19, 2024

BTW, I did a Google search for the error you're encountering and found the following:

https://forums.developer.apple.com/forums/thread/768295

So it looks like this can be an issue with "official" models, too... 👎.

Can you try the example from the forum post and see if you get the same error again?

@PeaceByte
Copy link
Author

I'm also running macOS 15.1 and Xcode 16.1. Hmmm...

I tried rebuilding LaMa.mlpackage and ran into an error based on a bad python package version. So I updated requirements.txt with the output of pip freeze from a known working env. Then I could rebuild the model.

I was able to successfully use the model I built. I suggest doing a git pull, deleting your conda env (or creating a new one) and rerunning pip install -y requirements.txt. Rebuild the model with that environment and let me know if that model works for you.

Thanks for your update! I did a git pull, deleted my conda environment, and created a new one. I also updated the environment by running pip install -r requirements.txt and rebuilt the model. Unfortunately, the issue persists, and I still encounter the same error when trying to use the model.

@PeaceByte
Copy link
Author

BTW, I did a Google search for the error you're encountering and found the following:

https://forums.developer.apple.com/forums/thread/768295

So it looks like this can be an issue with "official" models, too... 👎.

Can you try the example from the forum post and see if you get the same error again?

Thanks for pointing me to the forum post! I tried the example mentioned there, but I encountered the same error again.

@PeaceByte
Copy link
Author

You’re right, it seems like this issue also occurs with the official models. I

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