JupyterLab Installation and Configuration
When HEAVY.AI runs in Docker, the paths must be relative paths accessible to Docker, instead of OS-level paths. Therefore, keep the following in mind when performing Docker-based installations:
- You must locate your docker-compose.yml file in a reachable location from Docker.
- The ingest and export paths from HEAVY.AI likely differ from the file's actual location because HEAVY.AI uses container paths instead of operating system paths.
- 1.Install the NVIDIA drivers and nvidia-container-runtime for your operating system, using the instructions at https://github.com/NVIDIA/nvidia-container-runtime.
- 2.
- 3.Change the default Docker runtime to
nvidia
and restart Docker.a. Edit/etc/docker/daemon.json
and add"default-runtime": "nvidia"
. The resulting file should look similar to the following:{"default-runtime": "nvidia","runtimes": {"nvidia": {"path": "nvidia-container-runtime","runtimeArgs": []}}}b. Restart the Docker service:sudo systemctl restart dockerc. Validate NVIDIA Docker:docker run --rm nvidia/cuda:11.0.3-runtime-ubuntu20.04 nvidia-smi - 4.Create a HEAVY.AI storage directory with a name of your choosing and change directories to it.sudo mkdir /var/lib/heavyai | sudo chown $USER /var/lib/heavyai
- 5.Create the directory /var/lib/heavyai/jupyter/.sudo mkdir /var/lib/heavyai/jupyter| sudo chown $USER /var/lib/heavyai/jupyter
- 6.Create the file
/var/lib/
heavyai/
heavyai.conf
, and configure thejupyter-url
setting under the[web]
section to point to the Jupyter service:port = 6274http-port = 6278calcite-port = 6279data = "/var/lib/heavyai/storage"null-div-by-zero = true[web]port = 6273frontend = "/opt/heavyai/frontend"servers-json = "/var/lib/heavyai/servers.json"jupyter-url = "http://jupyterhub:8000" - 7.Create the following
/var/lib/
heavyai/servers.json
entry to enable Jupyter features in Immerse.[{"enableJupyter": true}] - 8.Create
/var/lib/
heavyai/docker-compose.yml
like this oneversion: '3.7'services:heavyaiserver:container_name: heavyaiserverimage: heavyai/heavyai-ee-cuda:v6.1.1restart: alwaysipc: shareablevolumes:- /var/lib/heavyai:/var/lib/heavyai- /var/lib/heavyai/data/heavyai_import/jhub_heavyai_dropbox:/jhub_heavyai_dropboxnetworks:- heavyai-frontend- heavyai-backendports:- "6273:6273"- "6274:6274"- "6278:6278"# If using binary encryption, uncomment the below line to override the default# command that uses startheavyai, noting that you must have an existing HEAVY.AI# data directory and run initdb before making this change.# command: /bin/bash -c "/heavyai/bin/heavy_web_server --config /heavyai-storage/heavyai.conf & /heavyai/bin/heavydb --config /heavyai-storage/heavyai.conf"# The purpose of this is to make sure the jlabimage is pulled because jupyterhub will not pull it automatically when launchingjupyterlab-tmp:image: &jlabimage omnisci/omnisci-jupyterlab-cpu:v0.5command: echonetworks:- heavyai-backendjupyterhub:container_name: jupyterhubimage: omnisci/omnisci-jupyterhub:v0.4restart: alwaysnetworks:- heavyai-backenddepends_on:- heavyaiservervolumes:- /var/run/docker.sock:/var/run/docker.sock# Map this volume if binary encryption mode is configured and certificates are being validated# - /var/lib/heavyai/cacerts.crt:/heavyai-storage/cacerts.crtenvironment:### Required settings ###OMNISCIDB_CONTAINER_NAME: heavyaiserverSPAWNER_ENV_OMNISCI_HOST: heavyaiserverDOCKER_JUPYTER_LAB_IMAGE: *jlabimageOMNISCI_HOST: heavyaiserverOMNISCI_JUPYTER_ROLE: omnisci_jupyterJLAB_DOCKER_NETWORK_NAME: heavyai-backend### Optional settings #### DOCKER_NOTEBOOK_DIR: /home/jovyan # The directory inside the user's Jupyter Lab container to mount the user volume to.# HUB_IP: jupyterhub # The hostname or IP of the Jupyter Hub server# JHUB_BASE_URL: /jupyter/ # The base URL prepended to all Jupyter Hub and Lab requests# HEAVYAI_ALLOW_SUPERUSER_ROLE: "false" # Enable / disable admin access to Jupyter Hub# JLAB_CONTAINER_AUTOREMOVE: "true" # Enable / disable automatic removal of stopped Juptyer Lab containers# JLAB_DOCKER_NETWORK_NAME: heavyai-backend # The docker network name for Jupyter Lab containers# JLAB_IDLE_TIMEOUT: 3600 # Shut down Jupyter Lab containers after this many seconds of idle time# JLAB_NAME_PREFIX: jupyterlab # Container name prefix for Lab containers# JLAB_HEAVYAI_IMPORT_VOLUME_PATH: /var/lib/heavyai/data/heavyai_import/jhub_heavyai_dropbox # Local Docker host path for where to mount the shared directory available to the HeavyDB server for file ingest# JLAB_NOTEBOOK_TERMINALS_ENBLED: "false" # Enable terminals in notebooks# JLAB_USER_VOLUME_PATH: /var/lib/heavyai/jupyter/ # Local Docker host path to be used for user Jupyter Lab home directory volume mapping# JUPYTER_DEBUG: "true" # Turn on / off debugging for Jupyter Hub and Lab# OMNISCI_BINARY_TLS_CACERTS_LOCAL_PATH: /var/lib/heavyai/cacerts.crt # Specifying this or mapping a volume in the Hub container to /heavyai-storage/cacerts.crt will automatically enable binary TLS mode# OMNISCI_BINARY_TLS_VALIDATE: "false" # Whether or not to validate certificates in binary TLS mode. Specifying either "true" or "false" will enable binary TLS mode# OMNISCI_PORT: 6278 # Port that Jupyter Hub should use to connect to HEAVY.AI. Ensure this matches the protocol# OMNISCI_PROTOCOL: http # Protocol that Jupyter Hub should use to connect to HEAVY.AI. Ensure this is "binary" if using binary encryption# SPAWNER_CPU_LIMIT: 1 # Number of CPU cores available for each Jupyter Lab container, see https://jupyterhub.readthedocs.io/en/stable/api/spawner.html#jupyterhub.spawner.Spawner.cpu_limit# SPAWNER_RAM_LIMIT: 10G # Amount of CPU RAM available for each Jupyter Lab container, see https://jupyterhub.readthedocs.io/en/stable/api/spawner.html#jupyterhub.spawner.LocalProcessSpawner.mem_limit# SPAWNER_ENV_OMNISCI_HOST: heavyaiserver # Hostname / IP address of the HEAVY.AI server for Lab containers to connect to by default# SPAWNER_ENV_OMNISCI_PORT: 6274 # Port of the HEAVY.AI server for Lab containers to connect to by default# SPAWNER_ENV_OMNISCI_PROTOCOL: binary # Protocol of the HEAVY.AI server for Lab containers to connect to by default# OMNISCI_DB_URL: "heavyai://heavyaiserver:6274/heavyai" # Alternative, direct connection (not Immerse session) to heavyaiserver. Username will be inferred, but password will be required in notebook.# More volumes for lab containers:# JLAB_VOLUME_1: /data1:/data1:rw# JLAB_VOLUME_2: /var/lib/heavyai:/heavyai-storage:ronetworks:heavyai-frontend:driver: bridgename: heavyai-frontendheavyai-backend:driver: bridgename: heavyai-backend - 9.Make sure you are in the directory that you created in step 5, and run
compose
in detached mode:cd /var/lib/heavyaidocker-compose up -d - 10.Log in as the super user (
admin/HyperInteractive
) using Heavy Immerse and insert the license. - 11.Create required users in HeavyDB.
- 12.Create the heavyai_jupyter role in HeavyDB.CREATE ROLE omnisci_jupyter;
- 13.Grant the heavyai_jupyter role to users who require Jupyter access.GRANT omnisci_jupyter TO username;
You might need to stop lab containers for them to be restarted with the new image:
docker ps | grep jupyterlab
docker rm -f jupyterlab-USERNAME
You should now see Jupyter icons in the upper right of Immerse and when running queries in SQL Editor.
When HEAVY.AI runs in Docker, the paths must be relative paths accessible to Docker instead of OS-level paths. Keep the following in mind when performing Docker-based installations:
- You must locate your docker-compose.yml file in a reachable location from Docker.
- The ingest and export paths from HEAVY.AI likely differ from the file's actual location because HEAVY.AI uses container paths instead of operating system paths.
To use Jupyter with an existing, non-Docker install of HEAVY.AI, change HEAVY.AI to run on Docker instead of the host. The steps are the same as the install instructions, with the following exceptions:
- 1.Change the volume mappings to point to the existing storage path. In this example is located into
/var/lib/heavyai
.heavyaiserver:container_name: heavyaiserverimage: heavyai/heavyai-ee-cuda:v6.1.1restart: alwaysipc: shareablevolumes:- /var/lib/heavyai:/var/lib/heavyai- /var/lib/heavyai/data/heavyai_import/jhub_heavyai_dropbox:/jhub_heavyai_dropbox - 2.Enable the following environment variables and change the relevant paths to your existing installation:### Optional settings #### DOCKER_NOTEBOOK_DIR: /home/jovyan # The directory inside the user's Jupyter Lab container to mount the user volume to.# HUB_IP: jupyterhub # The hostname or IP of the Jupyter Hub server# JHUB_BASE_URL: /jupyter/ # The base URL prepended to all Jupyter Hub and Lab requests# JHUB_ENABLE_ADMIN_ACCESS: "false" # Enable / disable admin access to Jupyter Hub# JLAB_DOCKER_NETWORK_NAME: heavyai-backend # The docker network name for Jupyter Lab containers# JLAB_IDLE_TIMEOUT: 3600 # Shut down Jupyter Lab containers after this many seconds of idle time# JLAB_NAME_PREFIX: jupyterlab # Container name prefix for Lab containersJLAB_HEAVYAI_IMPORT_VOLUME_PATH: /var/lib/heavyai/data/import/jhub_heavyai_dropbox # Local Docker host path for where to mount the shared directory available to the HeavyDB server for file ingest# JLAB_NOTEBOOK_TERMINALS_ENBLED: "false" # Enable terminals in notebooksJLAB_USER_VOLUME_PATH: /var/lib/heavyai/jupyter/ # Local Docker host path to be used for user Jupyter Lab home directory volume mapping# JUPYTER_DEBUG: "true" # Turn on / off debugging for Jupyter Hub and Lab# HEAVYDB_CONTAINER_NAME: heavyaiserver # HeavyDB container name for IPC sharing with Lab containers# SPAWNER_CPU_LIMIT: 1 # Number of CPU cores available for each Jupyter Lab container, see https://jupyterhub.readthedocs.io/en/stable/api/spawner.html#jupyterhub.spawner.Spawner.cpu_limit# SPAWNER_RAM_LIMIT: 10G # Amount of CPU RAM available for each Jupyter Lab container, see https://jupyterhub.readthedocs.io/en/stable/api/spawner.html#jupyterhub.spawner.LocalProcessSpawner.mem_limit# SPAWNER_ENV_HEAVYAI_HOST: heavyaiserver # Hostname / IP address of the HEAVY.AI server for Lab containers to connect to by default# SPAWNER_ENV_HEAVYAI_PORT: 6274 # Port of the HEAVY.AI server for Lab containers to connect to by default# SPAWNER_ENV_HEAVYAI_PROTOCOL: binary # Protocol of the HEAVY.AI server for Lab containers to connect to by default
- 3.If you have an existing heavyai.conf file:
- Add the required sections instead of creating a new file:[web]jupyter-url = "http://jupyterhub:8000"servers-json = "/var/lib/heavyai/servers.json"
- Ensure that all paths, such as cert and key, are accessible by Docker.
- 4.If you have an existing servers.json file, move it to your HEAVY.AI home directory (/
var/lib/heavyai
in the example) and add the following:"enableJupyter": true - 5.Now you can run the
docker-compose up -d
command
Before running
docker-compose up -d
, ensure that any existing installations are stopped and disabled. For example:sudo systemctl stop heavydb
sudo systemctl stop heavy_web_server
sudo systemctl disable heavydb
sudo systemctl disable heavy_web_server
Run the following commands to create the jhub_heavai_dropbox directory and make it writeable by your users. Change the volume mappings to point to your existing installation path:
sudo mkdir /var/lib/heavyai/data/import/jhub_heavai_dropbox
sudo chown $USER /var/lib/heavyai/data/import/jhub_heavai_dropbox
sudo chmod 750 /var/lib/heavyai/data/import/jhub_heavai_dropbox
This allows Jupyter users to write files into
/var/lib/heavyai/data/import/jhub_heavai_dropbox
. You can also use that directory path in
COPY FROM
SQL commands.To upgrade Jupyter images using the docker-compose.yml file, edit
docker-compose.yml
as follows:services:
heavyaiserver:
...
image: heavyai/heavyai-ee-cuda:v6.1.1
...
jupyterhub:
container_name: jupyterhub
image: heavyai/heavyai-jupyterhub:v0.4
...
environment:
...
DOCKER_JUPYTER_LAB_IMAGE: &jlabimage heavyai/heavyai-jupyterlab-cpu:v0.5
Then, use the following commands to download the images and restart the services with the new versions:
docker-compose pull
docker-compose up -d
You might also need to stop lab containers in to start them again in a new image:
docker ps | grep jupyterlab
For each user, run the following command:
docker rm -f jupyterlab-<username>
Open JupyterLab by clicking the Jupyter icon in the upper right corner of Immerse.

JupyterLab opens in a new tab. You are signed in automatically using HEAVY.AI authentication, with a notebook ready to start a HEAVY.AI connection. The notebook is saved for you at the root of your Jupyter file system.

You can verify the location of your file by clicking the folder icon in the top left.

The cell's contents are prefilled with explanatory comments and the
heavyai_connect()
method ready to set up your HEAVY.AI connection in Jupyter. Click the Play button to run the connection statement and list the tables in your HeavyDB instance.
The session is invalidated after the session timeout period passes with no activity (60 minutes by default). The session is invalidated after the session timeout period passes with no activity (60 minutes by default).
The connection reuses the session already in use by Heavy Immerse by passing Jupyter the raw session ID. If you connect this way without credentials, the connection has a time-to-live (TTL). The session is invalidated after the session timeout period passes with no activity (60 minutes by default). You have to reenter Jupyter from Immerse in the same way to reestablish the connection or use the heavyai connect method to enter your credentials manually.
You can also launch Jupyter from the Heavy Immerse SQL Editor. After you run a query in the SQL Editor, you see a button that allows you to send your query to Jupyter.

The query displays in a different notebook, ready to run the query. You must run the cell to send the query and see the results.
