mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2026-04-10 12:33:42 +00:00
Note about MPS devices (#329)
This commit is contained in:
committed by
GitHub
parent
c443035d56
commit
01cb137bfd
@@ -511,6 +511,21 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
|
||||
"\n",
|
||||
"# Note:\n",
|
||||
"# Uncommenting the following lines will allow the code to run on Apple Silicon chips, if applicable,\n",
|
||||
"# which is approximately 1.2x faster than on an Apple CPU (as measured on an M3 MacBook Air).\n",
|
||||
"# However, the resulting loss values may be slightly different.\n",
|
||||
"\n",
|
||||
"#if torch.cuda.is_available():\n",
|
||||
"# device = torch.device(\"cuda\")\n",
|
||||
"#elif torch.backends.mps.is_available():\n",
|
||||
"# device = torch.device(\"mps\")\n",
|
||||
"#else:\n",
|
||||
"# device = torch.device(\"cpu\")\n",
|
||||
"#\n",
|
||||
"# print(f\"Using {device} device.\")\n",
|
||||
"\n",
|
||||
"model.to(device); # no assignment model = model.to(device) necessary for nn.Module classes"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user