mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
update GPU usage section
This commit is contained in:
1 parent
1f43ea83f9
commit
0fa794be52
1 file changed
+10
-12
@@ -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()`."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -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"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -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."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -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"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user