Last active
August 29, 2024 02:25
-
-
Save rossja/dced67b894df8ce51cb7f8ceafa7cd00 to your computer and use it in GitHub Desktop.
simple script to figure out what pytorch device you are using
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
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") |
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
[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