Created
June 20, 2024 18:37
-
-
Save glowinthedark/a70fd16db149363291642996353e3cfe to your computer and use it in GitHub Desktop.
check if pytorch can use macos apple silicon chip metal support
This file contains 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
#!/usr/bin/env python3 | |
import torch | |
def is_metal_enabled(): | |
"""Checks if Metal acceleration is enabled for PyTorch.""" | |
# Check if MPS backend is available on the system | |
if not torch.backends.mps.is_available(): | |
print("MPS backend is not available on this system.") | |
return False | |
# Check if current PyTorch version was built with MPS support | |
if not torch.backends.mps.is_built(): | |
print("Current PyTorch version is not built with MPS support.") | |
return False | |
# Metal acceleration is likely enabled | |
print("Metal acceleration appears to be enabled for PyTorch.") | |
return True | |
if __name__ == "__main__": | |
is_metal_enabled() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment