From f5fd86adbfd416ce4ab1c3cdc84cdc1d188f0e91 Mon Sep 17 00:00:00 2001 From: stellarshenson Date: Thu, 7 Aug 2025 22:29:37 +0200 Subject: [PATCH] another fix --- config/jupyterhub_config.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/config/jupyterhub_config.py b/config/jupyterhub_config.py index 0e5e744..9ccda4e 100644 --- a/config/jupyterhub_config.py +++ b/config/jupyterhub_config.py @@ -13,20 +13,28 @@ c = get_config() # NVIDIA GPU auto-detection, unfortunately through docker exception def detect_nvidia(): client = docker.DockerClient('unix://var/run/docker.sock') + # spin up a container to test if nvidia works + result = 0 + container = None try: - output = client.containers.run( + client.containers.run( image='nvidia/cuda:12.9.1-base-ubuntu24.04', command='nvidia-smi', runtime='nvidia', name='jupyterhub_nvidia_autodetect', - remove=True, - auto_remove=True, stderr=True, - stdout=True + stdout=True, ) - return 1 + result = 1 except: - return 0 + result = 0 + # cleanup that container + try: + container = client.get('jupyterhub_nvidia_autodetect') + container.remove() + except: + pass + return result NVIDIA_DETECTED = detect_nvidia()