hiento09 4f93e14d16
Fix token speed slow in machine has multi gpus (#1157)
* Update bat script windows choose GPU has highest ram to start nitro

* Update bash script for linux to choose gpu has highest vram

---------

Co-authored-by: Hien To <tominhhien97@gmail.com>
2023-12-21 15:38:21 +07:00

45 lines
976 B
Batchfile

@echo off
setlocal enabledelayedexpansion
set "maxMemory=0"
set "gpuId="
rem check if nvidia-smi command exist or not
where nvidia-smi >nul 2>&1
if %errorlevel% neq 0 (
echo nvidia-smi not found, proceeding with CPU version...
cd win-cuda
goto RunCpuVersion
)
set "tempFile=%temp%\nvidia_smi_output.txt"
nvidia-smi --query-gpu=index,memory.total --format=csv,noheader,nounits > "%tempFile%"
for /f "usebackq tokens=1-2 delims=, " %%a in ("%tempFile%") do (
set /a memorySize=%%b
if !memorySize! gtr !maxMemory! (
set "maxMemory=!memorySize!"
set "gpuId=%%a"
)
)
rem Echo the selected GPU
echo Selected GPU: !gpuId!
rem Set the GPU with the highest VRAM as the visible CUDA device
set CUDA_VISIBLE_DEVICES=!gpuId!
rem Attempt to run nitro_windows_amd64_cuda.exe
cd win-cuda
nitro.exe %*
if %errorlevel% neq 0 goto RunCpuVersion
goto End
:RunCpuVersion
rem Run nitro_windows_amd64.exe...
cd ..\win-cpu
nitro.exe %*
:End
endlocal