Skip to content

Instantly share code, notes, and snippets.

@aryan-jadon
Created September 13, 2022 23:04
Show Gist options
  • Save aryan-jadon/0a71c18e3b56c719db80cc0915f27cb6 to your computer and use it in GitHub Desktop.
Save aryan-jadon/0a71c18e3b56c719db80cc0915f27cb6 to your computer and use it in GitHub Desktop.
Apple Mac PyTorch Check
# What version of Python do you have?
import sys
import platform
import torch
import pandas as pd
import sklearn as sk
has_gpu = torch.cuda.is_available()
has_mps = getattr(torch,'has_mps',False)
device = "mps" if getattr(torch,'has_mps',False) \
else "gpu" if torch.cuda.is_available() else "cpu"
print(f"Python Platform: {platform.platform()}")
print(f"PyTorch Version: {torch.__version__}")
print()
print(f"Python {sys.version}")
print(f"Pandas {pd.__version__}")
print(f"Scikit-Learn {sk.__version__}")
print("GPU is", "available" if has_gpu else "NOT AVAILABLE")
print("MPS (Apple Metal) is", "AVAILABLE" if has_mps else "NOT AVAILABLE")
print(f"Target device is {device}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment