Skip to content

Commit

Permalink
update GPU usage section
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdbourke committed Jan 11, 2024
1 parent 1f43ea8 commit 0fa794b
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions 00_pytorch_fundamentals.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3505,15 +3505,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2.1 Getting PyTorch to run on Apple Silicon\n",
"\n",
"In order to run PyTorch on Apple's M1/M2/M3 GPUs you can use the [`torch.backends.mps`](https://pytorch.org/docs/stable/notes/mps.html) module.\n",
"\n",
"### 2.1 Getting PyTorch to run on the ARM GPUs\n",
"Be sure that the versions of the macOS and Pytorch are updated.\n",
"\n",
"In order to run PyTorch on the Apple's M1/M2 GPUs you can use the [`torch.backends.mps`](https://pytorch.org/docs/stable/notes/mps.html) package.\n",
"\n",
"Be sure that the versions of the MacOS and Pytorch are updated\n",
"\n",
"You can test if PyTorch has access to a GPU using `torch.backends.mps.is_available()`\n"
"You can test if PyTorch has access to a GPU using `torch.backends.mps.is_available()`."
]
},
{
Expand All @@ -3533,9 +3531,9 @@
}
],
"source": [
"# Check for ARM GPU\n",
"# Check for Apple Silicon GPU\n",
"import torch\n",
"torch.backends.mps.is_available()"
"torch.backends.mps.is_available() # Note this will print false if you're not running on a Mac"
]
},
{
Expand Down Expand Up @@ -3564,7 +3562,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As before, if the above output `\"mps\"` it means we can set all of our PyTorch code to use the available Apple Arm GPU"
"As before, if the above output `\"mps\"` it means we can set all of our PyTorch code to use the available Apple Silicon GPU."
]
},
{
Expand All @@ -3574,11 +3572,11 @@
"outputs": [],
"source": [
"if torch.cuda.is_available():\n",
" device = 'cuda'\n",
" device = \"cuda\" # Use NVIDIA GPU (if available)\n",
"elif torch.backends.mps.is_available():\n",
" device = 'mps'\n",
" device = \"mps\" # Use Apple Silicon GPU (if available)\n",
"else:\n",
" device = 'cpu'"
" device = \"cpu\" # Default to CPU if no GPU is available"
]
},
{
Expand Down

0 comments on commit 0fa794b

Please sign in to comment.