Created
October 15, 2022 09:03
-
-
Save sriharshav/7d76dcc84edd19f31557a3d6fd4f8a0c to your computer and use it in GitHub Desktop.
PyTorch with Apple M1 MPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| print(f"PyTorch version: {torch.__version__}") | |
| # Check PyTorch has access to MPS (Metal Performance Shader, Apple's GPU architecture) | |
| print(f"Is MPS (Metal Performance Shader) built? {torch.backends.mps.is_built()}") | |
| print(f"Is MPS available? {torch.backends.mps.is_available()}") | |
| # Set the device | |
| device = "mps" if torch.backends.mps.is_available() else "cpu" | |
| print(f"Using device: {device}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment