From 427259c344a76226cec7f2c0db3642a72bae9256 Mon Sep 17 00:00:00 2001 From: Jip-Hop <2871973+Jip-Hop@users.noreply.github.com> Date: Wed, 25 Jan 2023 21:17:02 +0100 Subject: [PATCH] Bind mount nvidia --- jlmkr.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jlmkr.sh b/jlmkr.sh index 96454f7..10f251a 100644 --- a/jlmkr.sh +++ b/jlmkr.sh @@ -84,7 +84,17 @@ start_jail() { # Detect intel GPU device and if present add bind flag [[ -d /dev/dri ]] && systemd_nspawn_additional_args+=(--bind=/dev/dri) - # TODO: add bind mount flags in case of nvidia GPU passthrough + # Detect nvidia GPU + if [[ -d /dev/nvidia ]]; then + # Mount the nvidia driver files, so we are always in sync with the host + while read -r line; do + if [[ "${line}" == /dev/* ]]; then + systemd_nspawn_additional_args+=("--bind='${line}'") + else + systemd_nspawn_additional_args+=("--bind-ro='${line}'") + fi + done < <(nvidia-container-cli list) + fi fi local cmd=(systemd-run "${systemd_run_default_args}" "${systemd_run_additional_args[*]}" --