mirror of
https://github.com/dockur/windows.git
synced 2025-06-23 16:07:47 +00:00
Merge pull request #1 from Steel-skull/Steel-skull-patch-2
Update gpu-switch.sh
This commit is contained in:
commit
e8fa68ed39
@ -35,21 +35,24 @@ convert_to_pci_address() {
|
||||
local device="$1"
|
||||
local gpu_address=""
|
||||
|
||||
if [[ "$device" =~ ^[0-9]+$ ]]; then
|
||||
# Convert GPU index to PCI address
|
||||
gpu_address=$(nvidia-smi --id=$device --query-gpu=gpu_bus_id --format=csv,noheader 2>/dev/null | tr -d '[:space:]')
|
||||
elif [[ "$device" =~ ^GPU-.*$ ]]; then
|
||||
# Handle UUID
|
||||
gpu_address=$(nvidia-smi --id=$device --query-gpu=gpu_bus_id --format=csv,noheader 2>/dev/null | tr -d '[:space:]')
|
||||
if [[ "$device" =~ ^[0-9]+$ || "$device" =~ ^GPU-.*$ ]]; then
|
||||
# Convert GPU index or UUID to PCI address
|
||||
gpu_address=$(nvidia-smi --id="$device" --query-gpu=gpu_bus_id --format=csv,noheader 2>/dev/null | tr -d '[:space:]')
|
||||
else
|
||||
# Direct PCI address provided
|
||||
gpu_address=$device
|
||||
gpu_address="$device"
|
||||
fi
|
||||
|
||||
# Check for valid output
|
||||
if [ -z "$gpu_address" ]; then
|
||||
error_exit "Failed to get PCI address for device: $device"
|
||||
fi
|
||||
|
||||
# Standardize format
|
||||
echo "$gpu_address" | sed 's/0000://' | sed 's/\./:/g'
|
||||
echo "$gpu_address" | sed -e 's/0000://' -e 's/\./:/g'
|
||||
}
|
||||
|
||||
|
||||
get_gpu_addresses() {
|
||||
# Split devices by comma
|
||||
IFS=',' read -ra DEVICES <<< "$NVIDIA_VISIBLE_DEVICES"
|
||||
|
Loading…
Reference in New Issue
Block a user