Remote function - Jupyter Notebook

Robbie supports remotely running Python functions on GPUs in the Robbie cloud. Users typically choose this option if they have a specific task, such as a machine learning training loop, that needs the added performance of a GPU not available on their local machine.

See `Using Robbie in Jupyter Notebooks` for a more detailed explanation of when and how to use Robbie in your experimentation.

In this example, you will create a simple Jupyter Notebook on your local machine with one Python function that runs remotely on a GPU. (You can download the example here).

First, open a new notebook:

jupyter lab

Then create four new (empty) cells in the notebook.

In the first cell paste:

!pip install robbie torch

This will install the Robbie and PyTorch Python packages and their dependencies on your local computer.

In the second cell paste:

import robbie
robbie.login()

This will you and download your API key from Robbie and install it on your local machine.

In the third cell paste:

from robbie import remote

@remote(chooser_ui=True)
def your_function():
     # code (Add Matplotlib here)

In the fourth cell paste:

a = your_functions()
print(“a is:”, a)

This defines the Python function (your_function()) that will be run remotely in the Robbie cloud. Note that the chooser_ui=True argument tells Robbie to display a special UI in the notebook so that the end-user can choose the hardware to run the function.

Now Save the notebook ( on a Mac or on Windows)

Start by pressing the button to run the first cell.

You should see the Robbie and other packages being installed.

A computer screen with white text Description automatically generated

Next, run the second cell by pressing the button.

If you have yet to log into Robbie, you will be prompted for your username and password.

Finally, run the third cell. You should see a small GUI directly in the notebook.

Robbie Remote Function Notebook GUI

From the Hardware Options dropdown menu, choose NERC Small GPU. This is a NVIDIA V100 GPU-based virtual instance in the Robbie cloud.

Next, tick the checkbox.

Next, press the button.

You should then see the command program executing.

A screenshot of a computer program Description automatically generated
A screenshot of a computer Description automatically generated

So, what is Robbie doing here?

  1. Created a new run (uniquely identified as subtle_unicorn) and allocated a GPU machine for your run.

  2. Automatically detected your local Python dependencies (packages and versions), wrote them to a requirements.txt file, and sent them to the remote machine.

  3. Packaged up (serialized) your function and arguments and sent it to the remote machine.

  4. Vended a deep link to view the run progress, logs, and artifacts in the Robbie portal.

  5. On the remote machine, Robbie installed the Python dependencies, unpackaged your function, executed it, and then returned the result to the local machine.

  6. Streamed the standard out from the remote machine to your local machine, including the results of the nvidia-smi command.

  7. Printed out the duration and cost of the job once it was complete

For more examples, see Jupyter Notebook Examples.

Last updated

Was this helpful?