Skip to content

Commit bee6fb9

Browse files
committed
[DLMED] update notebooks
1 parent 107e13c commit bee6fb9

File tree

1 file changed

+88
-46
lines changed

1 file changed

+88
-46
lines changed

multi_gpu_test.ipynb

Lines changed: 88 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
},
2525
"outputs": [
2626
{
27-
"output_type": "stream",
2827
"name": "stdout",
29-
"text": "Note: you may need to restart the kernel to use updated packages.\n"
28+
"output_type": "stream",
29+
"text": [
30+
"Note: you may need to restart the kernel to use updated packages.\n"
31+
]
3032
}
3133
],
3234
"source": [
@@ -48,9 +50,25 @@
4850
},
4951
"outputs": [
5052
{
51-
"output_type": "stream",
5253
"name": "stdout",
53-
"text": "MONAI version: 0.2.0\nPython version: 3.7.5 (default, Nov 7 2019, 10:50:52) [GCC 8.3.0]\nNumpy version: 1.19.1\nPytorch version: 1.6.0\n\nOptional dependencies:\nPytorch Ignite version: 0.3.0\nNibabel version: NOT INSTALLED or UNKNOWN VERSION.\nscikit-image version: NOT INSTALLED or UNKNOWN VERSION.\nPillow version: NOT INSTALLED or UNKNOWN VERSION.\nTensorboard version: NOT INSTALLED or UNKNOWN VERSION.\n\nFor details about installing the optional dependencies, please visit:\n https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n\n"
54+
"output_type": "stream",
55+
"text": [
56+
"MONAI version: 0.2.0\n",
57+
"Python version: 3.7.5 (default, Nov 7 2019, 10:50:52) [GCC 8.3.0]\n",
58+
"Numpy version: 1.19.1\n",
59+
"Pytorch version: 1.6.0\n",
60+
"\n",
61+
"Optional dependencies:\n",
62+
"Pytorch Ignite version: 0.3.0\n",
63+
"Nibabel version: NOT INSTALLED or UNKNOWN VERSION.\n",
64+
"scikit-image version: NOT INSTALLED or UNKNOWN VERSION.\n",
65+
"Pillow version: NOT INSTALLED or UNKNOWN VERSION.\n",
66+
"Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.\n",
67+
"\n",
68+
"For details about installing the optional dependencies, please visit:\n",
69+
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
70+
"\n"
71+
]
5472
}
5573
],
5674
"source": [
@@ -110,105 +128,129 @@
110128
},
111129
{
112130
"cell_type": "markdown",
131+
"metadata": {},
113132
"source": [
114133
"### 1 GPU"
115-
],
116-
"metadata": {
117-
"collapsed": false
118-
}
134+
]
119135
},
120136
{
121137
"cell_type": "code",
122-
"source": [
123-
"opt = torch.optim.Adam(net.parameters(), lr)\n",
124-
"trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, [torch.device(\"cuda:0\")])\n",
125-
"trainer.run(fake_data_stream(), 2, 2)\n"
126-
],
138+
"execution_count": 4,
127139
"metadata": {
128-
"collapsed": false,
129140
"pycharm": {
130141
"name": "#%%\n"
131142
}
132143
},
133-
"execution_count": 4,
134144
"outputs": [
135145
{
136-
"output_type": "execute_result",
137146
"data": {
138-
"text/plain": "State:\n\titeration: 4\n\tepoch: 2\n\tepoch_length: 2\n\tmax_epochs: 2\n\toutput: 40707.8984375\n\tbatch: <class 'tuple'>\n\tmetrics: <class 'dict'>\n\tdataloader: <class 'generator'>\n\tseed: 12"
147+
"text/plain": [
148+
"State:\n",
149+
"\titeration: 4\n",
150+
"\tepoch: 2\n",
151+
"\tepoch_length: 2\n",
152+
"\tmax_epochs: 2\n",
153+
"\toutput: 40707.8984375\n",
154+
"\tbatch: <class 'tuple'>\n",
155+
"\tmetrics: <class 'dict'>\n",
156+
"\tdataloader: <class 'generator'>\n",
157+
"\tseed: 12"
158+
]
139159
},
160+
"execution_count": 4,
140161
"metadata": {},
141-
"execution_count": 4
162+
"output_type": "execute_result"
142163
}
164+
],
165+
"source": [
166+
"opt = torch.optim.Adam(net.parameters(), lr)\n",
167+
"trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, [torch.device(\"cuda:0\")])\n",
168+
"trainer.run(fake_data_stream(), 2, 2)\n"
143169
]
144170
},
145171
{
146172
"cell_type": "markdown",
173+
"metadata": {},
147174
"source": [
148175
"### all GPUs"
149-
],
150-
"metadata": {
151-
"collapsed": false
152-
}
176+
]
153177
},
154178
{
155179
"cell_type": "code",
156-
"source": [
157-
"opt = torch.optim.Adam(net.parameters(), lr)\n",
158-
"trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, None)\n",
159-
"trainer.run(fake_data_stream(), 2, 2)\n"
160-
],
180+
"execution_count": 5,
161181
"metadata": {
162-
"collapsed": false,
163182
"pycharm": {
164183
"name": "#%%\n"
165184
},
166185
"tags": []
167186
},
168-
"execution_count": 5,
169187
"outputs": [
170188
{
171-
"output_type": "execute_result",
172189
"data": {
173-
"text/plain": "State:\n\titeration: 4\n\tepoch: 2\n\tepoch_length: 2\n\tmax_epochs: 2\n\toutput: 35669.37109375\n\tbatch: <class 'tuple'>\n\tmetrics: <class 'dict'>\n\tdataloader: <class 'generator'>\n\tseed: 12"
190+
"text/plain": [
191+
"State:\n",
192+
"\titeration: 4\n",
193+
"\tepoch: 2\n",
194+
"\tepoch_length: 2\n",
195+
"\tmax_epochs: 2\n",
196+
"\toutput: 35669.37109375\n",
197+
"\tbatch: <class 'tuple'>\n",
198+
"\tmetrics: <class 'dict'>\n",
199+
"\tdataloader: <class 'generator'>\n",
200+
"\tseed: 12"
201+
]
174202
},
203+
"execution_count": 5,
175204
"metadata": {},
176-
"execution_count": 5
205+
"output_type": "execute_result"
177206
}
207+
],
208+
"source": [
209+
"opt = torch.optim.Adam(net.parameters(), lr)\n",
210+
"trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, None)\n",
211+
"trainer.run(fake_data_stream(), 2, 2)\n"
178212
]
179213
},
180214
{
181215
"cell_type": "markdown",
216+
"metadata": {},
182217
"source": [
183218
"### CPU"
184-
],
185-
"metadata": {
186-
"collapsed": false
187-
}
219+
]
188220
},
189221
{
190222
"cell_type": "code",
191-
"source": [
192-
"opt = torch.optim.Adam(net.parameters(), lr)\n",
193-
"trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, [])\n",
194-
"trainer.run(fake_data_stream(), 2, 2)"
195-
],
223+
"execution_count": 6,
196224
"metadata": {
197-
"collapsed": false,
198225
"pycharm": {
199226
"name": "#%%\n"
200227
}
201228
},
202-
"execution_count": 6,
203229
"outputs": [
204230
{
205-
"output_type": "execute_result",
206231
"data": {
207-
"text/plain": "State:\n\titeration: 4\n\tepoch: 2\n\tepoch_length: 2\n\tmax_epochs: 2\n\toutput: 29662.359375\n\tbatch: <class 'tuple'>\n\tmetrics: <class 'dict'>\n\tdataloader: <class 'generator'>\n\tseed: 12"
232+
"text/plain": [
233+
"State:\n",
234+
"\titeration: 4\n",
235+
"\tepoch: 2\n",
236+
"\tepoch_length: 2\n",
237+
"\tmax_epochs: 2\n",
238+
"\toutput: 29662.359375\n",
239+
"\tbatch: <class 'tuple'>\n",
240+
"\tmetrics: <class 'dict'>\n",
241+
"\tdataloader: <class 'generator'>\n",
242+
"\tseed: 12"
243+
]
208244
},
245+
"execution_count": 6,
209246
"metadata": {},
210-
"execution_count": 6
247+
"output_type": "execute_result"
211248
}
249+
],
250+
"source": [
251+
"opt = torch.optim.Adam(net.parameters(), lr)\n",
252+
"trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, [])\n",
253+
"trainer.run(fake_data_stream(), 2, 2)"
212254
]
213255
}
214256
],

0 commit comments

Comments
 (0)