Skip to content

Commit dc0df09

Browse files
committed
Tutorials/Accelerated Python: Write checkpoints to /tmp in notebooks 05 and 06.
Fixes performance issues when the Git repository is on a network or slow filesystem by writing checkpoint files to /tmp instead of the working directory.
1 parent 01026d5 commit dc0df09

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

tutorials/accelerated-python/notebooks/fundamentals/05__memory_spaces__power_iteration.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
" print(f\"Step {i}: residual = {res:.3e}\")\n",
188188
"\n",
189189
" # Save a checkpoint.\n",
190-
" np.savetxt(f\"host_{i}.txt\", x)\n",
190+
" np.savetxt(f\"/tmp/host_{i}.txt\", x)\n",
191191
"\n",
192192
" # Convergence check.\n",
193193
" if res < cfg.residual_threshold:\n",
@@ -267,7 +267,7 @@
267267
" if cfg.progress:\n",
268268
" print(f\"Step {i}: residual = {res:.3e}\")\n",
269269
"\n",
270-
" np.savetxt(f\"host_{i}.txt\", x) # Save a checkpoint.\n",
270+
" np.savetxt(f\"/tmp/host_{i}.txt\", x) # Save a checkpoint.\n",
271271
"\n",
272272
" # Convergence check\n",
273273
" if res < cfg.residual_threshold:\n",

tutorials/accelerated-python/notebooks/fundamentals/06__asynchrony__power_iteration.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
" print(f\"step {i}: residual = {res:.3e}\")\n",
131131
"\n",
132132
" # Copy from device to host and save a checkpoint.\n",
133-
" np.savetxt(f\"device_{i}.txt\", cp.asnumpy(x))\n",
133+
" np.savetxt(f\"/tmp/device_{i}.txt\", cp.asnumpy(x))\n",
134134
"\n",
135135
" if res < cfg.residual_threshold:\n",
136136
" break\n",
@@ -268,7 +268,7 @@
268268
"- You can synchronize on an event (or an entire stream) by calling `.synchronize` on it.\n",
269269
"- Memory transfers will block by default. You can launch them asynchronously with `cp.asarray(..., blocking=False)` (for host to device transfers) and `cp.asnumpy(..., blocking=False)` (for device to host transfers).\n",
270270
"\n",
271-
"**TODO:** The code below contains the baseline implementation with NVTX annotations already added. Modify it to improve performance by adding asynchrony."
271+
"**TODO:** Copy your NVTX annotated code from before into the cell below (make sure not to overwrite the %%writefile), and modify the code to improve performance by adding asynchrony."
272272
]
273273
},
274274
{

tutorials/accelerated-python/notebooks/fundamentals/solutions/05__memory_spaces__power_iteration__SOLUTION.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
" print(f\"Step {i}: residual = {res:.3e}\")\n",
188188
"\n",
189189
" # Save a checkpoint.\n",
190-
" np.savetxt(f\"host_{i}.txt\", x)\n",
190+
" np.savetxt(f\"/tmp/host_{i}.txt\", x)\n",
191191
"\n",
192192
" # Convergence check.\n",
193193
" if res < cfg.residual_threshold:\n",
@@ -273,7 +273,7 @@
273273
" print(f\"Step {i}: residual = {res:.3e}\")\n",
274274
"\n",
275275
" # Transfer x from device to host and save a checkpoint.\n",
276-
" np.savetxt(f\"device_{i}.txt\", cp.asnumpy(x))\n",
276+
" np.savetxt(f\"/tmp/device_{i}.txt\", cp.asnumpy(x))\n",
277277
"\n",
278278
" # Convergence check.\n",
279279
" if res < cfg.residual_threshold:\n",

tutorials/accelerated-python/notebooks/fundamentals/solutions/06__asynchrony__power_iteration__SOLUTION.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
" if cfg.progress:\n",
137137
" print(f\"step {i}: residual = {res_host:.3e}\")\n",
138138
"\n",
139-
" np.savetxt(f\"device_{i}.txt\", x_host) # Copy from device to host and\n",
140-
" # save a checkpoint.\n",
139+
" # Copy from device to host and save a checkpoint.\n",
140+
" np.savetxt(f\"/tmp/device_{i}.txt\", x_host)\n",
141141
"\n",
142142
" if res_host < cfg.residual_threshold:\n",
143143
" break\n",
@@ -355,7 +355,8 @@
355355
" if cfg.progress:\n",
356356
" print(f\"step {i}: residual = {res_host:.3e}\")\n",
357357
"\n",
358-
" np.savetxt(f\"device_{i}.txt\", x_host) # Save a checkpoint.\n",
358+
" # Save a checkpoint.\n",
359+
" np.savetxt(f\"/tmp/device_{i}.txt\", x_host)\n",
359360
"\n",
360361
" if res_host < cfg.residual_threshold:\n",
361362
" break\n",

0 commit comments

Comments
 (0)