Run your first job
In this tutorial, follow along to run a program over OpenMPI in a few lines of Python.
Set up
This tutorial runs on Camber infrastructure, and a corresponding notebook is in the demos folder of your Jupyter hub.
The easiest way to run this code is to log into Camber and try it out:
From your Camber account, click Jupyter Hub to access your Jupyter environment.
In the left-hand menu, note the
demosfolder. It contains subfolders for each demo. For this tutorial, head intodemos > 10-get-started > 10-run-your-first-job.
This folder has three files. Open mpi_hello_world.ipynb and start running commands in the notebook.
- makefile
- mpi_hello_world.c
- mpi_hello_world.ipynb
If you prefer to just read, here’s the full notebook.
Run “Hello, world!” on MPI
This notebook demostrates how to run a simple MPI job on Camber.
- Use
maketo build a “Hello, world!” C program. - Run the program over MPI.
First, import camber. This instantiates a set of tools to run different types of workloads on Camber Cloud.
import camberThe node_size specifies the amount of computational power to allocate to the job. Each step up in node size doubles the allocated compute capacity.
make = camber.mpi.create_job(
command="make",
node_size="XXSMALL"
)To check the status of the make job, call on its status attribute. When the job finishes, job status will be COMPLETED.
make.statusWhen the make job is finished, a binary named mpi_hello_world is created in the same directory. This is a compiled C program that prints Hello world from each process.
Run it with MPI with 4 cores and 4 MPI processes:
run = camber.mpi.create_job(
command="mpirun -np 4 mpi_hello_world",
node_size="XXSMALL"
)Again, check the status of the run job with run.status. When the job finishes, the status returns COMPLETED.
run.statusIn fact, you can read the logs of any job with read_logs, which prints the logs of the job to the console:
run.read_logs()The log should look something like this:
Hello world from processor mpi-master-c6df7-adfie, rank 0 out of 4 processors
Hello world from processor mpi-master-c6df7-adfie, rank 1 out of 4 processors
Hello world from processor mpi-master-c6df7-adfie, rank 2 out of 4 processors
Hello world from processor mpi-master-c6df7-adfie, rank 3 out of 4 processorsYou could also download the log file with download_log.
This will save the log file to your current working directory under the name job_<JOB_ID>.log.
run.download_log()Congratulations! You’ve just run your first MPI job on Camber Cloud!