mallman / CoreMLaMa

LaMa for Core ML
Apache License 2.0
85 stars 11 forks source link

support GPU? #6

Open PeaceByte opened 1 week ago

PeaceByte commented 1 week ago

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 commented 1 week ago

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

PeaceByte commented 5 days ago

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 commented 3 days ago

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

PeaceByte commented 3 days ago

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 commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

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