Skip to content

Instantly share code, notes, and snippets.

@rossja
Last active August 29, 2024 02:25
Show Gist options
  • Save rossja/dced67b894df8ce51cb7f8ceafa7cd00 to your computer and use it in GitHub Desktop.
Save rossja/dced67b894df8ce51cb7f8ceafa7cd00 to your computer and use it in GitHub Desktop.
simple script to figure out what pytorch device you are using
import torch
if torch.cuda.is_available():
print ("cuda available")
print(f'available devices: {torch.cuda.device_count()}')
elif torch.backends.mps.is_available():
print ("mps available")
device = torch.device("mps")
x = torch.ones(1, device=device)
print (x)
else:
print ("cpu availabile")
[tool.poetry]
name = "check-devices"
version = "0.1.0"
description = "simple script to figure out what pytorch device you are using"
authors = ["Jason Ross <[email protected]>"]
readme = "README.md"
package-mode = false
[tool.poetry.dependencies]
python = "^3.10"
torch = "^2.4.0"
numpy = "^2.1.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment