* Add fix bug #1204 on windows * nitro gpu exit on kill * correct bat script syntax * Remove wait 5 second before start nitro --------- Co-authored-by: Hien To <tominhhien97@gmail.com>
40 lines
1010 B
Bash
40 lines
1010 B
Bash
#!/bin/bash
|
|
|
|
# Check if nvidia-smi exists and is executable
|
|
if ! command -v nvidia-smi &> /dev/null; then
|
|
echo "nvidia-smi not found, proceeding with CPU version..."
|
|
cd linux-cpu
|
|
./nitro "$@"
|
|
exit $?
|
|
fi
|
|
|
|
# Find the GPU with the highest VRAM
|
|
readarray -t gpus < <(nvidia-smi --query-gpu=index,memory.total --format=csv,noheader,nounits)
|
|
maxMemory=0
|
|
selectedGpuId=0
|
|
|
|
for gpu in "${gpus[@]}"; do
|
|
IFS=, read -ra gpuInfo <<< "$gpu"
|
|
gpuId=${gpuInfo[0]}
|
|
gpuMemory=${gpuInfo[1]}
|
|
if (( gpuMemory > maxMemory )); then
|
|
maxMemory=$gpuMemory
|
|
selectedGpuId=$gpuId
|
|
fi
|
|
done
|
|
|
|
echo "Selected GPU: $selectedGpuId"
|
|
export CUDA_VISIBLE_DEVICES=$selectedGpuId
|
|
|
|
# Attempt to run nitro_linux_amd64_cuda
|
|
cd linux-cuda
|
|
./nitro "$@" > output.log 2>&1 || (
|
|
echo "Check output log" &&
|
|
if grep -q "CUDA error" output.log; then
|
|
echo "CUDA error detected, attempting to run nitro_linux_amd64..."
|
|
cd ../linux-cpu && ./nitro "$@"
|
|
exit $?
|
|
fi
|
|
exit $?
|
|
)
|