Run your first job

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:

  1. From your Camber account, click Jupyter Hub to access your Jupyter environment.

  2. In the left-hand menu, note the demos folder. It contains subfolders for each demo. For this tutorial, head into demos > 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.

    1. Use make to build a “Hello, world!” C program.
    2. Run the program over MPI.

    First, import camber. This instantiates a set of tools to run different types of workloads on Camber Cloud.

    import camber

    The create_job function creates a process on Camber infrastructure. This function takes at a minimum a command and engine_size as arguments. To compile the C program in the cloud, pass command="make" and engine_size="XXSMALL".

    {{< callout type=“info” >}} The engine_size specifies the amount of computational power to allocate to the job. Each step up in engine size doubles the allocated compute capacity. {{< /callout >}}

    make = camber.mpi.create_job(
        command="make",
        engine_size="XXSMALL"
    )
    To check the status of the make job, run `make.status`. When the job finishes, `make.status` returns `COMPLETED`.
    make.status
    'COMPLETED'

    When 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",
        engine_size="XXSMALL"
    )
    Again, check the status of the `run` job with `run.status`. When the job finishes, the status returns `COMPLETED`.
    run.status
    'COMPLETED'
    In fact, you can read the logs of any job with the `read_logs()` method, 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 processors ```

    Congratulations! You’ve just run your first MPI job on Camber Cloud!