Skip to content

Commit 292edb7

Browse files
committed
[DLMED] update all the notebooks
1 parent d33f0f7 commit 292edb7

18 files changed

+34867
-566
lines changed

automatic_mixed_precision.ipynb

Lines changed: 63 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
},
116116
{
117117
"cell_type": "code",
118-
"execution_count": 4,
118+
"execution_count": 2,
119119
"metadata": {},
120120
"outputs": [
121121
{
@@ -143,7 +143,7 @@
143143
},
144144
{
145145
"cell_type": "code",
146-
"execution_count": 5,
146+
"execution_count": 3,
147147
"metadata": {},
148148
"outputs": [],
149149
"source": [
@@ -165,7 +165,7 @@
165165
},
166166
{
167167
"cell_type": "code",
168-
"execution_count": 6,
168+
"execution_count": 4,
169169
"metadata": {},
170170
"outputs": [],
171171
"source": [
@@ -185,7 +185,7 @@
185185
},
186186
{
187187
"cell_type": "code",
188-
"execution_count": 7,
188+
"execution_count": 5,
189189
"metadata": {},
190190
"outputs": [],
191191
"source": [
@@ -225,7 +225,7 @@
225225
},
226226
{
227227
"cell_type": "code",
228-
"execution_count": 8,
228+
"execution_count": 6,
229229
"metadata": {
230230
"scrolled": true
231231
},
@@ -349,44 +349,52 @@
349349
},
350350
{
351351
"cell_type": "code",
352-
"execution_count": 14,
352+
"execution_count": 8,
353353
"metadata": {},
354354
"outputs": [
355355
{
356356
"name": "stdout",
357357
"output_type": "stream",
358358
"text": [
359-
"Tue Aug 11 05:17:40 2020 \r\n",
360-
"+-----------------------------------------------------------------------------+\r\n",
361-
"| NVIDIA-SMI 440.44 Driver Version: 440.44 CUDA Version: 10.2 |\r\n",
362-
"|-------------------------------+----------------------+----------------------+\r\n",
363-
"| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\r\n",
364-
"| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\r\n",
365-
"|===============================+======================+======================|\r\n",
366-
"| 0 Tesla V100-PCIE... Off | 00000000:02:00.0 Off | 0 |\r\n",
367-
"| N/A 38C P0 36W / 250W | 3329MiB / 32510MiB | 0% Default |\r\n",
368-
"+-------------------------------+----------------------+----------------------+\r\n",
369-
"| 1 Tesla V100-PCIE... Off | 00000000:03:00.0 Off | 0 |\r\n",
370-
"| N/A 40C P0 38W / 250W | 4722MiB / 32510MiB | 0% Default |\r\n",
371-
"+-------------------------------+----------------------+----------------------+\r\n",
372-
" \r\n",
373-
"+-----------------------------------------------------------------------------+\r\n",
374-
"| Processes: GPU Memory |\r\n",
375-
"| GPU PID Type Process name Usage |\r\n",
376-
"|=============================================================================|\r\n",
377-
"+-----------------------------------------------------------------------------+\r\n"
359+
"Tesla V100-PCIE-32GB\n",
360+
"|===========================================================================|\n",
361+
"| PyTorch CUDA memory summary, device ID 0 |\n",
362+
"|---------------------------------------------------------------------------|\n",
363+
"| CUDA OOMs: 0 | cudaMalloc retries: 0 |\n",
364+
"|===========================================================================|\n",
365+
"| Metric | Cur Usage | Peak Usage | Tot Alloc | Tot Freed |\n",
366+
"|---------------------------------------------------------------------------|\n",
367+
"| Allocated memory | 0 B | 1152 MB | 200906 MB | 200906 MB |\n",
368+
"|---------------------------------------------------------------------------|\n",
369+
"| Active memory | 0 B | 1152 MB | 200906 MB | 200906 MB |\n",
370+
"|---------------------------------------------------------------------------|\n",
371+
"| GPU reserved memory | 2112 MB | 2112 MB | 2112 MB | 0 B |\n",
372+
"|---------------------------------------------------------------------------|\n",
373+
"| Non-releasable memory | 0 B | 455384 KB | 100324 MB | 100324 MB |\n",
374+
"|---------------------------------------------------------------------------|\n",
375+
"| Allocations | 0 | 609 | 30778 | 30778 |\n",
376+
"|---------------------------------------------------------------------------|\n",
377+
"| Active allocs | 0 | 609 | 30778 | 30778 |\n",
378+
"|---------------------------------------------------------------------------|\n",
379+
"| GPU reserved segments | 58 | 58 | 58 | 0 |\n",
380+
"|---------------------------------------------------------------------------|\n",
381+
"| Non-releasable allocs | 0 | 73 | 20653 | 20653 |\n",
382+
"|===========================================================================|\n",
383+
"\n"
378384
]
379385
}
380386
],
381387
"source": [
382-
"! nvidia-smi"
388+
"print(torch.cuda.get_device_name(0))\n",
389+
"print(torch.cuda.memory_summary(0, abbreviated=True))"
383390
]
384391
},
385392
{
386393
"cell_type": "markdown",
387394
"metadata": {},
388395
"source": [
389-
"## Enable deterministic and train without AMP"
396+
"## Enable deterministic and train without AMP\n",
397+
"In order to correctly measure the memory usage, please restart the notebook and skip above AMP training."
390398
]
391399
},
392400
{
@@ -411,37 +419,44 @@
411419
},
412420
{
413421
"cell_type": "code",
414-
"execution_count": 16,
422+
"execution_count": 8,
415423
"metadata": {},
416424
"outputs": [
417425
{
418426
"name": "stdout",
419427
"output_type": "stream",
420428
"text": [
421-
"Tue Aug 11 05:20:12 2020 \r\n",
422-
"+-----------------------------------------------------------------------------+\r\n",
423-
"| NVIDIA-SMI 440.44 Driver Version: 440.44 CUDA Version: 10.2 |\r\n",
424-
"|-------------------------------+----------------------+----------------------+\r\n",
425-
"| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\r\n",
426-
"| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\r\n",
427-
"|===============================+======================+======================|\r\n",
428-
"| 0 Tesla V100-PCIE... Off | 00000000:02:00.0 Off | 0 |\r\n",
429-
"| N/A 41C P0 37W / 250W | 4579MiB / 32510MiB | 0% Default |\r\n",
430-
"+-------------------------------+----------------------+----------------------+\r\n",
431-
"| 1 Tesla V100-PCIE... Off | 00000000:03:00.0 Off | 0 |\r\n",
432-
"| N/A 40C P0 38W / 250W | 4722MiB / 32510MiB | 0% Default |\r\n",
433-
"+-------------------------------+----------------------+----------------------+\r\n",
434-
" \r\n",
435-
"+-----------------------------------------------------------------------------+\r\n",
436-
"| Processes: GPU Memory |\r\n",
437-
"| GPU PID Type Process name Usage |\r\n",
438-
"|=============================================================================|\r\n",
439-
"+-----------------------------------------------------------------------------+\r\n"
429+
"Tesla V100-PCIE-32GB\n",
430+
"|===========================================================================|\n",
431+
"| PyTorch CUDA memory summary, device ID 0 |\n",
432+
"|---------------------------------------------------------------------------|\n",
433+
"| CUDA OOMs: 0 | cudaMalloc retries: 0 |\n",
434+
"|===========================================================================|\n",
435+
"| Metric | Cur Usage | Peak Usage | Tot Alloc | Tot Freed |\n",
436+
"|---------------------------------------------------------------------------|\n",
437+
"| Allocated memory | 0 B | 1730 MB | 279807 MB | 279807 MB |\n",
438+
"|---------------------------------------------------------------------------|\n",
439+
"| Active memory | 0 B | 1730 MB | 279807 MB | 279807 MB |\n",
440+
"|---------------------------------------------------------------------------|\n",
441+
"| GPU reserved memory | 3266 MB | 3266 MB | 3266 MB | 0 B |\n",
442+
"|---------------------------------------------------------------------------|\n",
443+
"| Non-releasable memory | 0 B | 630502 KB | 111299 MB | 111299 MB |\n",
444+
"|---------------------------------------------------------------------------|\n",
445+
"| Allocations | 0 | 542 | 25170 | 25170 |\n",
446+
"|---------------------------------------------------------------------------|\n",
447+
"| Active allocs | 0 | 542 | 25170 | 25170 |\n",
448+
"|---------------------------------------------------------------------------|\n",
449+
"| GPU reserved segments | 58 | 58 | 58 | 0 |\n",
450+
"|---------------------------------------------------------------------------|\n",
451+
"| Non-releasable allocs | 0 | 59 | 15985 | 15985 |\n",
452+
"|===========================================================================|\n",
453+
"\n"
440454
]
441455
}
442456
],
443457
"source": [
444-
"! nvidia-smi"
458+
"print(torch.cuda.get_device_name(0))\n",
459+
"print(torch.cuda.memory_summary(0, abbreviated=True))"
445460
]
446461
},
447462
{

brats_segmentation_3d.ipynb

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,33 @@
7777
},
7878
{
7979
"cell_type": "code",
80-
"execution_count": null,
80+
"execution_count": 2,
8181
"metadata": {
8282
"tags": []
8383
},
84-
"outputs": [],
84+
"outputs": [
85+
{
86+
"name": "stdout",
87+
"output_type": "stream",
88+
"text": [
89+
"MONAI version: 0.1.0+318.ga2cd842\n",
90+
"Python version: 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) [GCC 7.3.0]\n",
91+
"Numpy version: 1.18.1\n",
92+
"Pytorch version: 1.6.0\n",
93+
"\n",
94+
"Optional dependencies:\n",
95+
"Pytorch Ignite version: 0.3.0\n",
96+
"Nibabel version: 3.0.1\n",
97+
"scikit-image version: 0.15.0\n",
98+
"Pillow version: 7.0.0\n",
99+
"Tensorboard version: 2.1.0\n",
100+
"\n",
101+
"For details about installing the optional dependencies, please visit:\n",
102+
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
103+
"\n"
104+
]
105+
}
106+
],
85107
"source": [
86108
"# Copyright 2020 MONAI Consortium\n",
87109
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
@@ -98,7 +120,6 @@
98120
"import shutil\n",
99121
"import tempfile\n",
100122
"\n",
101-
"import IPython\n",
102123
"import matplotlib.pyplot as plt\n",
103124
"import numpy as np\n",
104125
"import torch\n",
@@ -142,11 +163,19 @@
142163
},
143164
{
144165
"cell_type": "code",
145-
"execution_count": null,
166+
"execution_count": 3,
146167
"metadata": {
147168
"tags": []
148169
},
149-
"outputs": [],
170+
"outputs": [
171+
{
172+
"name": "stdout",
173+
"output_type": "stream",
174+
"text": [
175+
"/workspace/data/medical\n"
176+
]
177+
}
178+
],
150179
"source": [
151180
"directory = os.environ.get(\"MONAI_DATA_DIRECTORY\")\n",
152181
"root_dir = tempfile.mkdtemp if directory is None else directory\n",
@@ -487,9 +516,7 @@
487516
" f\"current epoch: {epoch + 1} current mean dice: {metric:.4f}\"\n",
488517
" f\" tc: {metric_tc:.4f} wt: {metric_wt:.4f} et: {metric_et:.4f}\"\n",
489518
" f\"\\nbest mean dice: {best_metric:.4f} at epoch: {best_metric_epoch}\"\n",
490-
" )\n",
491-
"\n",
492-
" IPython.display.clear_output()"
519+
" )"
493520
]
494521
},
495522
{

cache_dataset_speed.ipynb

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,33 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": null,
54+
"execution_count": 1,
5555
"metadata": {
5656
"tags": []
5757
},
58-
"outputs": [],
58+
"outputs": [
59+
{
60+
"name": "stdout",
61+
"output_type": "stream",
62+
"text": [
63+
"MONAI version: 0.1.0+318.ga2cd842.dirty\n",
64+
"Python version: 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) [GCC 7.3.0]\n",
65+
"Numpy version: 1.18.1\n",
66+
"Pytorch version: 1.6.0\n",
67+
"\n",
68+
"Optional dependencies:\n",
69+
"Pytorch Ignite version: 0.3.0\n",
70+
"Nibabel version: 3.0.1\n",
71+
"scikit-image version: 0.15.0\n",
72+
"Pillow version: 7.0.0\n",
73+
"Tensorboard version: 2.1.0\n",
74+
"\n",
75+
"For details about installing the optional dependencies, please visit:\n",
76+
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
77+
"\n"
78+
]
79+
}
80+
],
5981
"source": [
6082
"# Copyright 2020 MONAI Consortium\n",
6183
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
@@ -74,7 +96,6 @@
7496
"import tempfile\n",
7597
"import time\n",
7698
"\n",
77-
"import IPython\n",
7899
"import matplotlib.pyplot as plt\n",
79100
"import torch\n",
80101
"\n",
@@ -115,11 +136,19 @@
115136
},
116137
{
117138
"cell_type": "code",
118-
"execution_count": null,
139+
"execution_count": 2,
119140
"metadata": {
120141
"tags": []
121142
},
122-
"outputs": [],
143+
"outputs": [
144+
{
145+
"name": "stdout",
146+
"output_type": "stream",
147+
"text": [
148+
"/workspace/data/medical\n"
149+
]
150+
}
151+
],
123152
"source": [
124153
"directory = os.environ.get(\"MONAI_DATA_DIRECTORY\")\n",
125154
"root_dir = tempfile.mkdtemp() if directory is None else directory\n",
@@ -138,7 +167,7 @@
138167
},
139168
{
140169
"cell_type": "code",
141-
"execution_count": null,
170+
"execution_count": 3,
142171
"metadata": {
143172
"tags": []
144173
},
@@ -149,8 +178,8 @@
149178
"\n",
150179
"compressed_file = os.path.join(root_dir, \"Task09_Spleen.tar\")\n",
151180
"data_dir = os.path.join(root_dir, \"Task09_Spleen\")\n",
152-
"\n",
153-
"download_and_extract(resource, compressed_file, root_dir, md5)"
181+
"if not os.path.exists(data_dir):\n",
182+
" download_and_extract(resource, compressed_file, root_dir, md5)"
154183
]
155184
},
156185
{
@@ -359,8 +388,6 @@
359388
" print(f\"time consuming of epoch {epoch + 1} is: {(time.time() - epoch_start):.4f}\")\n",
360389
" epoch_times.append(time.time() - epoch_start)\n",
361390
"\n",
362-
" IPython.display.clear_output()\n",
363-
"\n",
364391
" print(\n",
365392
" f\"train completed, best_metric: {best_metric:.4f} at epoch: {best_metric_epoch}\"\n",
366393
" f\" total time: {(time.time() - total_start):.4f}\"\n",
@@ -507,16 +534,16 @@
507534
"\n",
508535
"plt.subplot(2, 2, 3)\n",
509536
"plt.title(\"Cache Epoch Average Loss\")\n",
510-
"x = [i + 1 for i in range(len(epoch_loss_values))]\n",
511-
"y = epoch_loss_values\n",
537+
"x = [i + 1 for i in range(len(cache_epoch_loss_values))]\n",
538+
"y = cache_epoch_loss_values\n",
512539
"plt.xlabel(\"epoch\")\n",
513540
"plt.grid(alpha=0.4, linestyle=\":\")\n",
514541
"plt.plot(x, y, color=\"green\")\n",
515542
"\n",
516543
"plt.subplot(2, 2, 4)\n",
517544
"plt.title(\"Cache Val Mean Dice\")\n",
518-
"x = [i + 1 for i in range(len(metric_values))]\n",
519-
"y = metric_values\n",
545+
"x = [i + 1 for i in range(len(cache_metric_values))]\n",
546+
"y = cache_metric_values\n",
520547
"plt.xlabel(\"epoch\")\n",
521548
"plt.grid(alpha=0.4, linestyle=\":\")\n",
522549
"plt.plot(x, y, color=\"green\")\n",

0 commit comments

Comments
 (0)