diff --git a/appendix-D/01_main-chapter-code/appendix-D.ipynb b/appendix-D/01_main-chapter-code/appendix-D.ipynb index fea7694..e1177f0 100644 --- a/appendix-D/01_main-chapter-code/appendix-D.ipynb +++ b/appendix-D/01_main-chapter-code/appendix-D.ipynb @@ -91,6 +91,8 @@ " major, minor = map(int, torch.__version__.split(\".\")[:2])\n", " if (major, minor) >= (2, 9):\n", " device = torch.device(\"mps\")\n", + " else:\n", + " device = torch.device(\"cpu\")\n", "else:\n", " device = torch.device(\"cpu\")\n", "\n", diff --git a/appendix-E/01_main-chapter-code/appendix-E.ipynb b/appendix-E/01_main-chapter-code/appendix-E.ipynb index 21af361..c27cf7e 100644 --- a/appendix-E/01_main-chapter-code/appendix-E.ipynb +++ b/appendix-E/01_main-chapter-code/appendix-E.ipynb @@ -561,6 +561,8 @@ " major, minor = map(int, torch.__version__.split(\".\")[:2])\n", " if (major, minor) >= (2, 9):\n", " device = torch.device(\"mps\")\n", + " else:\n", + " device = torch.device(\"cpu\")\n", "else:\n", " device = torch.device(\"cpu\")\n", "\n", diff --git a/ch05/01_main-chapter-code/ch05.ipynb b/ch05/01_main-chapter-code/ch05.ipynb index 75515ee..97c2a4d 100644 --- a/ch05/01_main-chapter-code/ch05.ipynb +++ b/ch05/01_main-chapter-code/ch05.ipynb @@ -1183,9 +1183,12 @@ " major, minor = map(int, torch.__version__.split(\".\")[:2])\n", " if (major, minor) >= (2, 9):\n", " device = torch.device(\"mps\")\n", + " else:\n", + " device = torch.device(\"cpu\")\n", "else:\n", " device = torch.device(\"cpu\")\n", "\n", + "\n", "print(f\"Using {device} device.\")\n", "\n", "\n", diff --git a/ch06/01_main-chapter-code/ch06.ipynb b/ch06/01_main-chapter-code/ch06.ipynb index be7bced..22b3c88 100644 --- a/ch06/01_main-chapter-code/ch06.ipynb +++ b/ch06/01_main-chapter-code/ch06.ipynb @@ -1895,6 +1895,8 @@ " major, minor = map(int, torch.__version__.split(\".\")[:2])\n", " if (major, minor) >= (2, 9):\n", " device = torch.device(\"mps\")\n", + " else:\n", + " device = torch.device(\"cpu\")\n", "else:\n", " device = torch.device(\"cpu\")\n", "\n", diff --git a/ch07/01_main-chapter-code/ch07.ipynb b/ch07/01_main-chapter-code/ch07.ipynb index 15526ba..9e3ea30 100644 --- a/ch07/01_main-chapter-code/ch07.ipynb +++ b/ch07/01_main-chapter-code/ch07.ipynb @@ -1156,6 +1156,8 @@ " major, minor = map(int, torch.__version__.split(\".\")[:2])\n", " if (major, minor) >= (2, 9):\n", " device = torch.device(\"mps\")\n", + " else:\n", + " device = torch.device(\"cpu\")\n", "else:\n", " device = torch.device(\"cpu\")\n", "\n", diff --git a/ch07/04_preference-tuning-with-dpo/dpo-from-scratch.ipynb b/ch07/04_preference-tuning-with-dpo/dpo-from-scratch.ipynb index bb9f840..3bab1c3 100644 --- a/ch07/04_preference-tuning-with-dpo/dpo-from-scratch.ipynb +++ b/ch07/04_preference-tuning-with-dpo/dpo-from-scratch.ipynb @@ -725,6 +725,8 @@ " major, minor = map(int, torch.__version__.split(\".\")[:2])\n", " if (major, minor) >= (2, 9):\n", " device = torch.device(\"mps\")\n", + " else:\n", + " device = torch.device(\"cpu\")\n", "else:\n", " device = torch.device(\"cpu\")\n", "\n",