-
Notifications
You must be signed in to change notification settings - Fork 894
Add Apple MPS GPU support for Pytorch #1973
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
Conversation
There is a Pytorch bug that occurs when an optimizer is created for a network which is on an MPS GPU (pytorch/pytorch#149184), thus a trick to avoid it is needed.
|
Excuse me, I do not know how the build process is organized. The error message says: Maybe the |
|
I have no experience with Apple MPS GPU. The build file is here https://github.com/lululxvi/deepxde/blob/master/.github/workflows/build.yml |
It seems that for GitHub Actions MPS-based environment the necessary virtualization technology is not available, so the GPU is visible, but cannot be accessed. See: - https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources - actions/runner-images#9254 - sktime/pytorch-forecasting#1596 - sktime/pytorch-forecasting#1648 - https://discuss.pytorch.org/t/mps-back-end-out-of-memory-on-github-action/189773/7 - https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/
If the Pytorch optimizer bug is fixed and the line `torch._dynamo.disalbe()` (which raises an exception now) is removed, the added code will perform a simple check whether the MPS GPU can be used.
|
Hello. It seems that the GitHub Actions MPS-based environment doesn't support the necessary virtualization technology. As a result, PyTorch can detect the MPS GPU but cannot access it. I have added a workaround to fall back to the CPU if an exception occurs. Now, the line that addresses the PyTorch optimizer bug checks for GPU availability. If the optimizer bug is fixed and that line is removed, running a few neural network layers will help verify the MPS functionality. For future reference, please see the following links:
Edit:
|
There is a Pytorch bug that occurs when an optimizer is created for a network which is on an MPS GPU (pytorch/pytorch#149184), thus a trick to avoid it is needed.