Running Jupyter Notebook using workspaces¶
This guide provides a step-by-step walkthrough for running a Jupyter Notebook using workspaces.
A workspace contains the setup and configuration needed for building your model, including the container, images, data sets, and resource requests, as well as the required tools for the research, all in one place. See Running workspaces. for more information.
Prerequisites¶
Before you start, make sure:
- You have created a project or have one created for you.
- The project has an assigned quota of at least 1 GPU.
Step 1: Logging in¶
Browse to the provided Run:ai user interface and log in with your credentials.
Log in using the following command. You will be prompted to enter your username and password:
Run the below --help command to obtain the login options and log in according to your setup:
To use the API, you will need to obtain a token. Please follow the API authentication article.
Step 2: Submitting a workspace¶
- Go to the Workload manager → Workloads
- Select +NEW WORKLOAD and then Workspace. Within the New workspace form:
- Select under which cluster to create the workload
- Select the project in which your workspace will run
- Select a preconfigured template or select the Start from scratch to launch a new workspace quickly
- Enter a name for the workspace (If the name already exists in the project, you will be requested to submit a different name)
- Click CONTINUE. In the next step:
-
Select the ‘jupyter-lab’ environment for your workspace (Image URL: jupyter/scipy-notebook)
- If the ‘jupyter-lab’ is not displayed in the gallery, follow the step-by-step guide:
Create a jupyter-lab environment
- Click +NEW ENVIRONMENT
- Select under which cluster to create the environment
- Select a scope.
- Enter a name for the environment. The name must be unique.
- Enter the jupyter-lab Image URL - jupyter/scipy-notebook
-
Tools - Set the connection for your tool
- Click +TOOL
- Select Jupyter tool from the list
-
Set the runtime settings for the environment
- Click +COMMAND
- Enter command - start-notebook.sh
- Enter arguments -
--NotebookApp.base_url=/${RUNAI_PROJECT}/${RUNAI_JOB_NAME} --NotebookApp.token=''
Note
If host-based routing is enabled on the cluster, enter the argument
--NotebookApp.token=''
only.- Click CREATE ENVIRONMENT
- The newly created jupyter-lab will be selected automatically
-
Select the ‘one-gpu’ compute resource for your workspace (GPU devices: 1)
- If the ‘one-gpu’ is not displayed in the gallery, follow the step-by-step guide:
Create a one-gpu compute resource
- Click +NEW COMPUTE RESOURCE
- Select under which cluster to create the compute resource
- Select a scope
- Enter a name for the compute resource. The name must be unique.
- Set GPU devices per pod - 1
-
Set GPU memory per device
- Select % (of device) - Fraction of a GPU device’s memory
- Set the memory Request - 100 (The workload will allocate 100% of the GPU memory)
-
Optional: set the CPU compute per pod - 0.1 cores (default)
- Optional: set the CPU memory per pod - 100 MB (default)
- Click CREATE COMPUTE RESOURCE
- The newly created one-gpu compute resource will be selected automatically
-
Click CREATE WORKSPACE
After the workspace is created, it is added to the workloads table.
Copy the following command to your terminal. Make sure to update the below with the name of your project:
This would start a workspace with a pre-configured Jupyter image with one GPU allocated.
Copy the following command to your terminal. Make sure to update the below with the name of your project:
runai project set "project-name"
runai workspace submit jup1 --image jupyter/scipy-notebook --gpu-devices-request 1 \
--external-url container=8888 --command start-notebook.sh \
-- --NotebookApp.base_url=/\${RUNAI_PROJECT}/\${RUNAI_JOB_NAME} --NotebookApp.token=''
This would start a workspace with a pre-configured Jupyter image with one GPU allocated.
Copy the following command to your terminal. Make sure to update the below parameters according to the comments. For more details, see Workspaces API reference:
curl -L 'https://<COMPANY-URL>/api/v1/workloads/workspaces' \ # (1)
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <TOKEN>' \ # (2)
-d '{
"name": "jup1",
"projectId": "<PROJECT-ID>", '\ # (3)
"clusterId": "<CLUSTER-UUID>", \ # (4)
"spec": {
"command" : "start-notebook.sh",
"args" : "--NotebookApp.base_url=/${RUNAI_PROJECT}/${RUNAI_JOB_NAME} --NotebookApp.token=''",
"image": "jupyter/scipy-notebook",
"compute": {
"gpuDevicesRequest": 1
},
"exposedUrls" : [
{
"container" : 8888,
"toolType": "jupyter-notebook", \ # (5)
"toolName": "Jupyter" \ # (6)
}
]
}
}'
<COMPANY-URL>
is the link to the Run:ai user interface.<TOKEN>
is the API access token obtained in Step 1.<PROJECT-ID>
is #The ID of the Project the workspace is running on. You can get the Project ID via the Get Projects API Get Projects API.<CLUSTER-UUID>
is the unique identifier of the Cluster. You can get the Cluster UUID by adding the "Cluster ID" column to the Clusters view.toolType
will show the Jupyter icon when connecting to the Jupyter tool via the user interface.toolName
text will show when connecting to the Jupyter tool via the user interface.
Note
The above API snippet will only work with Run:ai clusters of 2.18 and above. For older clusters, use, the now deprecated Cluster API.
Step 3: Connecting to the Jupyter Notebook¶
- Select the newly created workspace with the Jupyter application that you want to connect to
- Click CONNECT
- Select the Jupyter tool
- The selected tool is opened in a new tab on your browser
To connect to the Jupyter Notebook, browse directly to https://<COMPANY-URL>/<PROJECT-NAME>/jup1
.
To connect to the Jupyter Notebook, browse directly to https://<COMPANY-URL>/<PROJECT-NAME>/jup1
.
To connect to the Jupyter Notebook, browse directly to https://<COMPANY-URL>/<PROJECT-NAME>/jup1
.
Next Steps¶
Manage and monitor your newly created workspace using the workloads table.