Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save glowinthedark/a70fd16db149363291642996353e3cfe to your computer and use it in GitHub Desktop.
Save glowinthedark/a70fd16db149363291642996353e3cfe to your computer and use it in GitHub Desktop.
check if pytorch can use macos apple silicon chip metal support
#!/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