Skip to content

Commit 9acb7d4

Browse files
committed
collab update
1 parent c03e73e commit 9acb7d4

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

notebooks/8__mpi.ipynb

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,14 @@
99
},
1010
"outputs": [],
1111
"source": [
12-
"## Uncomment and Execute this cell if running on slurm based cluster\n",
13-
"SRUN=\"srun\""
14-
]
15-
},
16-
{
17-
"cell_type": "code",
18-
"execution_count": null,
19-
"id": "0sW2XPMR-687",
20-
"metadata": {
21-
"id": "0sW2XPMR-687"
22-
},
23-
"outputs": [],
24-
"source": [
25-
"## Uncomment and Execute this cell if running on google collab\n",
26-
"#!pip install mpi4py\n",
27-
"#SRUN=\"mpirun --allow-run-as-root --oversubscribe\""
12+
"## Setup on \n",
13+
"MPIRUN=\"srun\"\n",
14+
"\n",
15+
"import os\n",
16+
"\n",
17+
"if os.getenv(\"COLAB_RELEASE_TAG\"): # If running in Google Colab\n",
18+
" !pip install mpi4py\n",
19+
" MPIRUN=\"mpirun --allow-run-as-root --oversubscribe\"\n"
2820
]
2921
},
3022
{
@@ -52,7 +44,7 @@
5244
},
5345
"outputs": [],
5446
"source": [
55-
"!$SRUN -n 2 -c 2 python hello_world.py"
47+
"!$MPIRUN -n 2 -c 2 python hello_world.py"
5648
]
5749
},
5850
{
@@ -64,7 +56,7 @@
6456
},
6557
"outputs": [],
6658
"source": [
67-
"!$SRUN -n 4 -c 4 python hello_world.py"
59+
"!$MPIRUN -n 4 -c 4 python hello_world.py"
6860
]
6961
},
7062
{
@@ -97,7 +89,7 @@
9789
},
9890
"outputs": [],
9991
"source": [
100-
"!$SRUN -n 2 -c 2 python hello_world_with_ranks.py"
92+
"!$MPIRUN -n 2 -c 2 python hello_world_with_ranks.py"
10193
]
10294
},
10395
{
@@ -128,7 +120,7 @@
128120
"metadata": {},
129121
"outputs": [],
130122
"source": [
131-
"!$SRUN -n 4 -c 4 python fizzbuzz.py"
123+
"!$MPIRUN -n 4 -c 4 python fizzbuzz.py"
132124
]
133125
},
134126
{
@@ -164,7 +156,7 @@
164156
},
165157
"outputs": [],
166158
"source": [
167-
"!$SRUN -n 2 -c 2 python send_recv.py"
159+
"!$MPIRUN -n 2 -c 2 python send_recv.py"
168160
]
169161
},
170162
{
@@ -200,7 +192,7 @@
200192
},
201193
"outputs": [],
202194
"source": [
203-
"!$SRUN -n 2 -c 2 python send_recv_eff.py"
195+
"!$MPIRUN -n 2 -c 2 python send_recv_eff.py"
204196
]
205197
},
206198
{
@@ -238,7 +230,7 @@
238230
},
239231
"outputs": [],
240232
"source": [
241-
"!$SRUN -n 2 -c 2 python send_recv_numpy.py"
233+
"!$MPIRUN -n 2 -c 2 python send_recv_numpy.py"
242234
]
243235
},
244236
{
@@ -271,7 +263,7 @@
271263
},
272264
"outputs": [],
273265
"source": [
274-
"!$SRUN -n 4 -c 4 python barrier.py"
266+
"!$MPIRUN -n 4 -c 4 python barrier.py"
275267
]
276268
},
277269
{
@@ -309,7 +301,7 @@
309301
},
310302
"outputs": [],
311303
"source": [
312-
"!$SRUN -n 4 -c 4 python scatter.py"
304+
"!$MPIRUN -n 4 -c 4 python scatter.py"
313305
]
314306
},
315307
{
@@ -350,7 +342,7 @@
350342
},
351343
"outputs": [],
352344
"source": [
353-
"!$SRUN -n 4 -c 4 python gather.py"
345+
"!$MPIRUN -n 4 -c 4 python gather.py"
354346
]
355347
},
356348
{
@@ -384,7 +376,7 @@
384376
},
385377
"outputs": [],
386378
"source": [
387-
"!$SRUN -n 4 -c 4 python reduce.py"
379+
"!$MPIRUN -n 4 -c 4 python reduce.py"
388380
]
389381
},
390382
{
@@ -448,7 +440,7 @@
448440
},
449441
"outputs": [],
450442
"source": [
451-
"!$SRUN -n 4 -c 4 python compute_pi.py"
443+
"!$MPIRUN -n 4 -c 4 python compute_pi.py"
452444
]
453445
},
454446
{
@@ -547,7 +539,7 @@
547539
},
548540
"outputs": [],
549541
"source": [
550-
"!$SRUN -n 4 -c 4 python compute_mandelbot.py"
542+
"!$MPIRUN -n 4 -c 4 python compute_mandelbot.py"
551543
]
552544
},
553545
{

0 commit comments

Comments
 (0)