diff --git a/docs.it4i/anselm/software/mpi/mpi4py-mpi-for-python.md b/docs.it4i/anselm/software/mpi/mpi4py-mpi-for-python.md index 4d687dc2f61e9ae593a7900b1bf183e07e61634f..1805ffe60f7a339fcf2d3ad566a04a1959b6f372 100644 --- a/docs.it4i/anselm/software/mpi/mpi4py-mpi-for-python.md +++ b/docs.it4i/anselm/software/mpi/mpi4py-mpi-for-python.md @@ -20,7 +20,7 @@ $ ml av Python/ Python/2.7.11-foss-2016a Python/3.5.2-foss-2016a Python/3.5.1 Python/2.7.9-foss-2015g Python/3.4.3-intel-2015b Python/2.7.9 Python/2.7.11-intel-2015b Python/3.5.2 - + $ ml av OpenMPI/ --------------------------------------- /apps/modules/mpi -------------------------- OpenMPI/1.8.6-GCC-4.4.7-system OpenMPI/1.8.8-GNU-4.9.3-2.25 OpenMPI/1.10.1-GCC-4.9.3-2.25 @@ -28,7 +28,8 @@ OpenMPI/1.8.6-GNU-5.1.0-2.25 OpenMPI/1.8.8-GNU-5.1.0-2.25 OpenMPI/1.10.1-GN OpenMPI/1.8.8-iccifort-2015.3.187-GNU-4.9.3-2.25 OpenMPI/2.0.2-GCC-6.3.0-2.27 ``` -!!! Warning "" +!!! Warning "Flavours" + * modules Python/x.x.x-intel... - intel MPI * modules Python/x.x.x-foss... - OpenMPI * modules Python/x.x.x - without MPI @@ -37,8 +38,8 @@ OpenMPI/1.8.6-GNU-5.1.0-2.25 OpenMPI/1.8.8-GNU-5.1.0-2.25 OpenMPI/1.10.1-GN You need to import MPI to your python program. Include the following line to the python script: -```cpp - from mpi4py import MPI +```python +from mpi4py import MPI ``` The MPI4Py enabled python programs [execute as any other OpenMPI](Running_OpenMPI/) code.The simpliest way is to run @@ -57,43 +58,43 @@ $ mpiexec python hello_world.py ### Hello World! -```cpp - from mpi4py import MPI +```python +from mpi4py import MPI - comm = MPI.COMM_WORLD +comm = MPI.COMM_WORLD - print "Hello! I'm rank %d from %d running in total..." % (comm.rank, comm.size) +print "Hello! I'm rank %d from %d running in total..." % (comm.rank, comm.size) - comm.Barrier() # wait for everybody to synchronize +comm.Barrier() # wait for everybody to synchronize ``` ### Collective Communication With NumPy Arrays -```cpp - from mpi4py import MPI - from __future__ import division - import numpy as np +```python +from mpi4py import MPI +from __future__ import division +import numpy as np - comm = MPI.COMM_WORLD +comm = MPI.COMM_WORLD - print("-"*78) - print(" Running on %d cores" % comm.size) - print("-"*78) +print("-"*78) +print(" Running on %d cores" % comm.size) +print("-"*78) - comm.Barrier() +comm.Barrier() - # Prepare a vector of N=5 elements to be broadcasted... - N = 5 - if comm.rank == 0: - A = np.arange(N, dtype=np.float64) # rank 0 has proper data - else: - A = np.empty(N, dtype=np.float64) # all other just an empty array +# Prepare a vector of N=5 elements to be broadcasted... +N = 5 +if comm.rank == 0: + A = np.arange(N, dtype=np.float64) # rank 0 has proper data +else: + A = np.empty(N, dtype=np.float64) # all other just an empty array - # Broadcast A from rank 0 to everybody - comm.Bcast( [A, MPI.DOUBLE] ) +# Broadcast A from rank 0 to everybody +comm.Bcast( [A, MPI.DOUBLE] ) - # Everybody should now have the same... - print "[%02d] %s" % (comm.rank, A) +# Everybody should now have the same... +print "[%02d] %s" % (comm.rank, A) ``` Execute the above code as: diff --git a/docs.it4i/software/singularity.md b/docs.it4i/software/singularity.md index 39618e32c735f1ef1dd02447014015518f51e342..026c4205946719c52bff0ae02eacaa5437db9eb5 100644 --- a/docs.it4i/software/singularity.md +++ b/docs.it4i/software/singularity.md @@ -12,7 +12,7 @@ Singularity also allows you to leverage the resources of whatever host you are o Singularity can import, bootstrap, and even run Docker images directly from [Docker Hub](https://hub.docker.com/). You can easily run RHEL7 like this: ```console -[hrb33@r33u01n865 ~]$ cat /etc/redhat-release +[hrb33@r33u01n865 ~]$ cat /etc/redhat-release CentOS release 6.7 (Final) [hrb33@r33u01n865 ~]$ ml Singularity [hrb33@r33u01n865 ~]$ singularity shell docker://centos:latest @@ -23,8 +23,8 @@ Downloading layer: sha256:45a2e645736c4c66ef34acce2407ded21f7a9b231199d3b92d6c97 Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4 Singularity: Invoking an interactive shell within container... -Singularity.centos:latest> cat /etc/redhat-release -CentOS Linux release 7.3.1611 (Core) +Singularity.centos:latest> cat /etc/redhat-release +CentOS Linux release 7.3.1611 (Core) ``` ## Creating Own Image from Docker Image @@ -32,7 +32,7 @@ CentOS Linux release 7.3.1611 (Core) ```console hrb33@hrb33-toshiba:/$ cd /tmp/ hrb33@hrb33-toshiba:/tmp$ sudo singularity create /tmp/c7.img -[sudo] password for hrb33: +[sudo] password for hrb33: Creating a new image with a maximum size of 768MiB... Executing image create helper Formatting image with ext3 file system @@ -49,7 +49,7 @@ No bootstrap definition passed, updating container Executing Prebootstrap module Executing Postbootstrap module Done. -hrb33@hrb33-toshiba:/tmp$ sudo singularity shell --writable c7.img +hrb33@hrb33-toshiba:/tmp$ sudo singularity shell --writable c7.img Singularity: Invoking an interactive shell within container... Singularity.c7.img> mkdir /apps /scratch @@ -68,10 +68,10 @@ Accessing /HOME and /SCRATCH Within Container ```console hrb33@hrb33-toshiba:/tmp$ ssh hrb33@login4.salomon - _____ _ - / ____| | | - | (___ __ _| | ___ _ __ ___ ___ _ __ - \___ \ / _` | |/ _ \| '_ ` _ \ / _ \| '_ \ + _____ _ + / ____| | | + | (___ __ _| | ___ _ __ ___ ___ _ __ + \___ \ / _` | |/ _ \| '_ ` _ \ / _ \| '_ \ ____) | (_| | | (_) | | | | | | (_) | | | | |_____/ \__,_|_|\___/|_| |_| |_|\___/|_| |_| @@ -80,7 +80,7 @@ hrb33@hrb33-toshiba:/tmp$ ssh hrb33@login4.salomon Last login: Fri Feb 10 14:38:36 2017 from 10.0.131.12 [hrb33@login4.salomon ~]$ ml Singularity -[hrb33@login4.salomon ~]$ singularity shell --bind /scratch --bind /apps --writable c7.img +[hrb33@login4.salomon ~]$ singularity shell --bind /scratch --bind /apps --writable c7.img Singularity: Invoking an interactive shell within container... Singularity.c7.img> ls /apps/ -l @@ -124,5 +124,5 @@ drwx------ 3 root root 4096 Aug 15 2016 backup drwxr-x--- 2 root root 4096 Dec 5 10:34 sys drwxrwxrwt 154 root root 20480 Feb 14 14:03 temp drwxr-xr-x 4 root root 4096 Jan 25 10:48 work -Singularity.c7.img> +Singularity.c7.img> ```