NYU-DLSP21 icon indicating copy to clipboard operation
NYU-DLSP21 copied to clipboard

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

Open prasad-yashdeep opened this issue 1 year ago • 0 comments

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.

prasad-yashdeep avatar Mar 15 '25 06:03 prasad-yashdeep