Update GPU transform for --gpus "device=UUID" style; keep --runtime=nvidia fallback
This commit is contained in:
@@ -74,17 +74,21 @@ detect_remote_gpu() {
|
||||
# Returns the path to a temp file — caller must clean it up.
|
||||
# Returns the original path unchanged if the XML has no NVIDIA markers (not GPU-aware).
|
||||
#
|
||||
# Handles both GPU config styles:
|
||||
# New: --gpus "device=GPU-UUID" in ExtraParams (current approach)
|
||||
# Old: --runtime=nvidia in ExtraParams + NVIDIA_VISIBLE_DEVICES Variable Config
|
||||
#
|
||||
# Transforms applied:
|
||||
# nvidia → nvidia: replace UUID with "all" so any NVIDIA GPU is accepted
|
||||
# nvidia → intel/amd/dri: strip --runtime=nvidia + NVIDIA_VISIBLE_DEVICES,
|
||||
# inject /dev/dri Device Config (+ /dev/kfd for AMD)
|
||||
# nvidia → none: strip --runtime=nvidia + NVIDIA_VISIBLE_DEVICES, no device added
|
||||
# nvidia → nvidia: normalise device UUID to "all" (both styles)
|
||||
# nvidia → intel/dri: strip NVIDIA params, inject /dev/dri Device Config
|
||||
# nvidia → amd: strip NVIDIA params, inject /dev/dri + /dev/kfd Device Configs
|
||||
# nvidia → none: strip NVIDIA params, no device added
|
||||
# ==============================================================================================
|
||||
transform_xml_for_gpu() {
|
||||
local src_xml="$1" gpu_type="$2"
|
||||
|
||||
# Only transform GPU-aware XMLs (containers with NVIDIA config)
|
||||
if ! grep -qE 'runtime=nvidia|NVIDIA_VISIBLE_DEVICES' "$src_xml" 2>/dev/null; then
|
||||
# Detect GPU-aware XMLs — new style (--gpus "device=) or old style (--runtime=nvidia)
|
||||
if ! grep -qE '--gpus[[:space:]]+"device=|--runtime=nvidia|NVIDIA_VISIBLE_DEVICES' "$src_xml" 2>/dev/null; then
|
||||
echo "$src_xml"
|
||||
return 0
|
||||
fi
|
||||
@@ -94,12 +98,16 @@ transform_xml_for_gpu() {
|
||||
|
||||
case "$gpu_type" in
|
||||
nvidia)
|
||||
# Same vendor — normalise UUID to "all" so any NVIDIA card is accepted
|
||||
sed 's/\(Target="NVIDIA_VISIBLE_DEVICES"[^>]*>\)[^<]*/\1all/' "$src_xml" > "$tmp_xml"
|
||||
# Normalise to --gpus all (new style) or NVIDIA_VISIBLE_DEVICES=all (old style)
|
||||
sed \
|
||||
-e 's/--gpus[[:space:]]*"device=[^"]*"/--gpus all/g' \
|
||||
-e 's/\(Target="NVIDIA_VISIBLE_DEVICES"[^>]*>\)[^<]*/\1all/' \
|
||||
"$src_xml" > "$tmp_xml"
|
||||
;;
|
||||
intel|dri)
|
||||
# Strip NVIDIA params, add /dev/dri device
|
||||
sed \
|
||||
-e 's/--gpus[[:space:]]*"device=[^"]*"[[:space:]]*//' \
|
||||
-e 's/--runtime=nvidia[[:space:]]*//' \
|
||||
-e '/Target="NVIDIA_VISIBLE_DEVICES"/d' \
|
||||
"$src_xml" > "$tmp_xml"
|
||||
@@ -108,6 +116,7 @@ transform_xml_for_gpu() {
|
||||
amd)
|
||||
# AMD needs /dev/dri for VA-API and /dev/kfd for ROCm/OpenCL
|
||||
sed \
|
||||
-e 's/--gpus[[:space:]]*"device=[^"]*"[[:space:]]*//' \
|
||||
-e 's/--runtime=nvidia[[:space:]]*//' \
|
||||
-e '/Target="NVIDIA_VISIBLE_DEVICES"/d' \
|
||||
"$src_xml" > "$tmp_xml"
|
||||
@@ -116,6 +125,7 @@ transform_xml_for_gpu() {
|
||||
none)
|
||||
# No GPU — strip all GPU params, no device added
|
||||
sed \
|
||||
-e 's/--gpus[[:space:]]*"device=[^"]*"[[:space:]]*//' \
|
||||
-e 's/--runtime=nvidia[[:space:]]*//' \
|
||||
-e '/Target="NVIDIA_VISIBLE_DEVICES"/d' \
|
||||
"$src_xml" > "$tmp_xml"
|
||||
|
||||
Reference in New Issue
Block a user