From d8c85c0d7abc777411148dff33957d5c1d8b3bc0 Mon Sep 17 00:00:00 2001 From: Jip-Hop <2871973+Jip-Hop@users.noreply.github.com> Date: Fri, 3 Mar 2023 21:28:06 +0100 Subject: [PATCH] Update jlmkr.py --- jlmkr.py | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/jlmkr.py b/jlmkr.py index 1cae2e8..f530ae1 100755 --- a/jlmkr.py +++ b/jlmkr.py @@ -18,7 +18,6 @@ import time import urllib.request from inspect import cleandoc from pathlib import Path, PurePath -from shutil import which from textwrap import dedent # Only set a color if we have an interactive tty @@ -171,7 +170,6 @@ def start_jail(jail_name): if os.path.exists('/dev/dri'): systemd_nspawn_additional_args.append('--bind=/dev/dri') else: - eprint("No intel GPU seems to be present...") eprint(dedent(""" No intel GPU seems to be present... Skip passthrough of intel GPU.""")) @@ -190,32 +188,14 @@ def start_jail(jail_name): Skip passthrough of nvidia GPU.""")) else: nvidia_files = set(nvidia_devices) - fallback = False - if which('nvidia-container-cli') is None: + try: + nvidia_files.update([x for x in subprocess.check_output( + ['nvidia-container-cli', 'list']).decode().split('\n') if x]) + except: eprint(dedent(""" - Can't run nvidia-container-cli, it appears not to be installed.""")) - fallback = True - else: - tries_remaining = 3 - while tries_remaining: - tries_remaining -= 1 - try: - nvidia_files.update([x for x in subprocess.check_output( - ['nvidia-container-cli', 'list']).decode().split('\n') if x]) - break - except subprocess.CalledProcessError: - eprint(dedent(""" - Failed to run nvidia-container-cli.""")) - if tries_remaining: - eprint("Trying again in 10 seconds...") - time.sleep(10) - else: - fallback = True - - if fallback: - eprint("Unable to detect which nvidia driver files to mount.") - eprint("Falling back to hard-coded list of nvidia files...") + Unable to detect which nvidia driver files to mount. + Falling back to hard-coded list of nvidia files...""")) for pattern in ["/dev/nvidia-modeset", "/dev/nvidia0", @@ -275,10 +255,10 @@ def start_jail(jail_name): *nvidia_mounts, "ldconfig"]) else: - eprint(""" + eprint(dedent(""" Unable to write the ld.so.conf.d directory inside the jail (it doesn't exist). Skipping call to ldconfig. - The nvidia drivers will probably not be detected...""") + The nvidia drivers will probably not be detected...""")) systemd_nspawn_additional_args += nvidia_mounts