Skip to content

Torch Device Support for Mac M1 series Metal (Hardware support) #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
prasad-yashdeep opened this issue Mar 15, 2025 · 0 comments
Open

Comments

@prasad-yashdeep
Copy link

The MacBooks are more than capable for running DL model on device now with GPU, so the notebooks should indeed also have support these devices as well.

Instead of having the following line , found in all the .ipynb files

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

We should replace it with ,

if torch.cuda.is_available():
    device = torch.device("cuda:0")
elif torch.backends.mps.is_available():
    device = torch.device("mps")
else:
    device = torch.device("cpu")

print(f"Using device: {device}")

Adding this will also help us bypass the limitations that have been put on training time , when trying to train on colab. As the T4 GPU on colab is only allotted for a very limited time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant