Skip to main content

A JupyterLab extension for managing GPU environments using genv.

Project description

GPU Environment Management for JupyterLab Join the community at https://join.slack.com/t/genvcommunity/shared_invite/zt-1i70tphdc-DmFgK5yr3HFI8Txx1yFXBw Join the chat at https://gitter.im/run-ai-genv/community

Github Actions Status

A JupyterLab extension for managing GPU environments using genv.

The genv extension lets you interactively control, configure and monitor the GPU resources that your Jupyter Notebooks are using.

Overview

🏃🏻 Be an early runner in the genv community!

Join our Slack channel with the creators of genv and start building your models faster!

  • Installation and setup support as well as best practice tips and tricks directly for your use-case
  • Discuss possible features
  • Monthly coffee breaks to get to know the rest of the community

Looking forward to seeing you as a part of the community!

Table of Contents

Getting Started

Read the genv reference to get started.

Installation

Requirements

JupyterLab >= 3.0

Conda

If you are using Conda, it is best to install the jupyterlab_genv package from the channel conda-forge:

conda install -c conda-forge jupyterlab_genv

Pip

Alternatively, you can install jupyterlab_genv from PyPI using pip:

pip install jupyterlab_genv

Install genv Kernels

After installing jupyterlab_genv, you will need to install genv Jupyter kernels using:

python -m jupyterlab_genv install

Usage

Activate Your Environment

To activate your environment, you will have to select a genv kernel.

Then, click the GPUs button on the Jupyter Notebook toolbar. A dialog should pop up where you can choose either to create a new environment for your Jupyter Notebook, or to use an existing one.

Then, you can open a terminal activated in your environment. From there you will be able to configure the environment and attach devices.

Activate

Attach GPUs to Your Environment

Configuring the environment and attaching devices is done from the genv terminal.

Make sure to restart your kernel after running the command in the terminal for it to take effect.

Attach

See Devices and Environments

You can open the devices and environments widgets to see information.

Open the command palette (Command/Ctrl Shift C) and type GPUs.

Commands

Development

Setup

You will need to create a virtual environment once using the command:

conda create -n jupyterlab_genv --override-channels --strict-channel-priority -c conda-forge -c nodefaults jupyterlab=3 cookiecutter nodejs jupyter-packaging git

Then, activate the virtual environment when you want to work on the project:

conda activate jupyterlab_genv

Install

Use the following commands to install the Python package and enable it in JupyterLab:

# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Server extension must be manually installed in develop mode
jupyter server extension enable jupyterlab_genv

If you make any changes you will need to rebuild the extension Typescript source using:

jlpm build

Alternatively, you can watch the source directory using:

jlpm watch

With the jlpm watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

Run

Run JupyterLab using the command:

jupyter lab

Running SHELL=bash jupyter lab --no-browser is even better

Uninstall

# Server extension must be manually disabled in develop mode
jupyter server extension disable jupyterlab_genv
pip uninstall jupyterlab_genv

In development mode, you will also need to remove the symlink created by jupyter labextension develop command. To find its location, you can run jupyter labextension list to figure out where the labextensions folder is located. Then you can remove the symlink named jupyterlab_genv within that folder.

Reference

List all kernel provisioners

jupyter kernelspec provisioners

Install a kernel provisioner

To add a kernel provisioner to a kernel spec, edit its kernel.json file. For example, to install a kernel provisioner for the python3 kernel spec, run:

vim $CONDA_PREFIX/share/jupyter/kernels/python3/kernel.json

And add:

"metadata": {
  "kernel_provisioner": {
    "provisioner_name": "genv-provisioner"
  }
}

List all available kernel specs

ls -la $CONDA_PREFIX/share/jupyter/kernels/

List all running kernels

ls -la $(jupyter --runtime-dir)/kernel-*.json

List Jupyter server extensions

jupyter server extension list

List JupyterLab extensions

jupyter labextension list

Publish

The jupyterlab_genv package is manually published to both PyPI and conda-forge.

We do not publish the frontend part as an npm package because the Python package is a prebuilt server extension, and the frontend part alone is useless.

Also make sure to update the changelog (here's how) and lint the project by running npm run lint.

Bump Version

The cookiecutter template uses tbump for bumping the version. However, for some reason this does not work at the moment, and we bump the version manually.

Search for the current version in the project files and replace the relevant instances. Here is a list of files that you should update:

After pushing these changes, create a release on GitHub.

PyPI

Prerequisites

pip install build twine tbump

Create a Python Package

Create a Python source package (.tar.gz) and the binary package (.whl) in the dist/ directory using:

python -m build

python setup.py sdist bdist_wheel is deprecated and will not work for this package.

Then, upload the package to PyPI using:

twine upload dist/*

We upload to PyPI with the organizational user runai

Conda

The Conda package is managed using its feedstock.

After publishing to PyPI, update the version and sha256 fields in the recipe meta.yaml file.

A few minutes after pushing these changes, you should be able to see that the Conda package version was updated.

You can get the SHA256 hash from PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_genv-0.4.0.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

jupyterlab_genv-0.4.0-py3-none-any.whl (88.2 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_genv-0.4.0.tar.gz.

File metadata

  • Download URL: jupyterlab_genv-0.4.0.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for jupyterlab_genv-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9db811955c8d23bc404adf0840275c083d97913be19c965e9f4a3c6d2ae7a3f6
MD5 8dd4c4a7e82e8cf4ee0661fdc64a6874
BLAKE2b-256 4a08eba01ba12ccde17b31e23f00a4ad839e49c30e1a85c930a99707618373ea

See more details on using hashes here.

File details

Details for the file jupyterlab_genv-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_genv-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df75ca42defbca9abe4a05a8df09d587ee6a77382b58386587525ec2478d0663
MD5 7d603c54f53b40ac110851dbebccbdb5
BLAKE2b-256 8dd7b1f6296b55aa522e43468fa1c54c16af34f4a24f337f7961086374f98631

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page