mirror of
https://github.com/stellarshenson/stellars-jupyterhub-ds.git
synced 2026-03-10 07:00:29 +00:00
updated with the nvidia autodetection
This commit is contained in:
@@ -53,12 +53,13 @@ services:
|
|||||||
- /var/run/docker.sock:/var/run/docker.sock:rw # docker socket to use spawner
|
- /var/run/docker.sock:/var/run/docker.sock:rw # docker socket to use spawner
|
||||||
- jupyterhub_data:/data # database and cookie secrets
|
- jupyterhub_data:/data # database and cookie secrets
|
||||||
- jupyterhub_certs:/mnt/certs # SSL certificates
|
- jupyterhub_certs:/mnt/certs # SSL certificates
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro # for nvidia autodetection
|
||||||
environment:
|
environment:
|
||||||
- JUPYTERHUB_ADMIN=admin # this username will be a JupyterHub admin
|
- JUPYTERHUB_ADMIN=admin # this username will be a JupyterHub admin
|
||||||
- DOCKER_NOTEBOOK_IMAGE=stellars/stellars-jupyterlab-ds:latest # jupyterlab image to spawn
|
- DOCKER_NOTEBOOK_IMAGE=stellars/stellars-jupyterlab-ds:latest # jupyterlab image to spawn
|
||||||
- DOCKER_NETWORK_NAME=jupyterhub-network # spawned containers will join this network
|
- DOCKER_NETWORK_NAME=jupyterhub-network # spawned containers will join this network
|
||||||
- JUPYTERHUB_BASE_URL=/jupyterhub # default prefix
|
- JUPYTERHUB_BASE_URL=/jupyterhub # default prefix
|
||||||
- ENABLE_GPU_SUPPORT=0 # this enables NVIDIA GPU support for images
|
- ENABLE_GPU_SUPPORT=2 # gpu status: 0 - disabled, 1 - enabled, 2 - auto-detect
|
||||||
- ENABLE_JUPYTERHUB_SSL=0 # if using traefik - you do need direct SSL config
|
- ENABLE_JUPYTERHUB_SSL=0 # if using traefik - you do need direct SSL config
|
||||||
labels:
|
labels:
|
||||||
# Enable proxy support from Traefik
|
# Enable proxy support from Traefik
|
||||||
|
|||||||
@@ -6,17 +6,30 @@ import os
|
|||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import nativeauthenticator
|
import nativeauthenticator
|
||||||
|
import docker # for gpu autodetection
|
||||||
|
|
||||||
c = get_config()
|
c = get_config()
|
||||||
|
|
||||||
|
# NVIDIA GPU auto-detection
|
||||||
|
NVIDIA_DETECTED = 0
|
||||||
|
docker_client = docker.DockerClient(base_url='unix://var/run/docker.sock')
|
||||||
|
docker_info = docker_client.info()
|
||||||
|
if "nvidia" in docker_info.get("Runtimes", {}):
|
||||||
|
NVIDIA_DETECTED = 1
|
||||||
|
|
||||||
# standard variables imported from env
|
# standard variables imported from env
|
||||||
ENABLE_JUPYTERHUB_SSL = int(os.environ.get("ENABLE_JUPYTERHUB_SSL", 1))
|
ENABLE_JUPYTERHUB_SSL = int(os.environ.get("ENABLE_JUPYTERHUB_SSL", 1))
|
||||||
ENABLE_GPU_SUPPORT= int(os.environ.get("ENABLE_GPU_SUPPORT", 0))
|
ENABLE_GPU_SUPPORT= int(os.environ.get("ENABLE_GPU_SUPPORT", 2))
|
||||||
DOCKER_NOTEBOOK_DIR = "/home/lab/workspace"
|
DOCKER_NOTEBOOK_DIR = "/home/lab/workspace"
|
||||||
JUPYTERHUB_BASE_URL = os.environ.get("JUPYTERHUB_BASE_URL")
|
JUPYTERHUB_BASE_URL = os.environ.get("JUPYTERHUB_BASE_URL")
|
||||||
JUPYTERHUB_ADMIN = os.environ.get("JUPYTERHUB_ADMIN")
|
JUPYTERHUB_ADMIN = os.environ.get("JUPYTERHUB_ADMIN")
|
||||||
NETWORK_NAME = os.environ["DOCKER_NETWORK_NAME"]
|
NETWORK_NAME = os.environ["DOCKER_NETWORK_NAME"]
|
||||||
|
|
||||||
|
# enable gpu autodetect and GPU found
|
||||||
|
# gpu support: 0 - disabled, 1 - enabled, 2 - autodetect
|
||||||
|
if ENABLE_GPU_SUPPORT == 2 and NVIDIA_DETECTED:
|
||||||
|
ENABLE_GPU_SUPPORT = 1 # means - gpu enabled
|
||||||
|
|
||||||
# ensure that we are using SSL, it should be enabled by default
|
# ensure that we are using SSL, it should be enabled by default
|
||||||
if ENABLE_JUPYTERHUB_SSL == 1:
|
if ENABLE_JUPYTERHUB_SSL == 1:
|
||||||
c.JupyterHub.ssl_cert = '/mnt/certs/server.crt'
|
c.JupyterHub.ssl_cert = '/mnt/certs/server.crt'
|
||||||
@@ -37,7 +50,8 @@ c.DockerSpawner.environment = {
|
|||||||
'ENABLE_SERVICE_GLANCES':1,
|
'ENABLE_SERVICE_GLANCES':1,
|
||||||
'ENABLE_SERVICE_TENSORBOARD':1,
|
'ENABLE_SERVICE_TENSORBOARD':1,
|
||||||
'ENABLE_GPU_SUPPORT': ENABLE_GPU_SUPPORT,
|
'ENABLE_GPU_SUPPORT': ENABLE_GPU_SUPPORT,
|
||||||
'ENABLE_GPUSTAT': ENABLE_GPU_SUPPORT
|
'ENABLE_GPUSTAT': ENABLE_GPU_SUPPORT,
|
||||||
|
'NVIDIA_DETECTED': NVIDIA_DETECTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
# configure access to GPU if possible
|
# configure access to GPU if possible
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ COPY ./templates/certs /mnt/certs
|
|||||||
|
|
||||||
## install dockerspawner, nativeauthenticator
|
## install dockerspawner, nativeauthenticator
|
||||||
RUN pip install -U --no-cache-dir \
|
RUN pip install -U --no-cache-dir \
|
||||||
|
docker \
|
||||||
dockerspawner \
|
dockerspawner \
|
||||||
jupyterhub-nativeauthenticator
|
jupyterhub-nativeauthenticator
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user