Skip to content

Commit

Permalink
Fix switch thread crash nitro windows linux (janhq#1214)
Browse files Browse the repository at this point in the history
* Add fix bug janhq#1204 on windows

* nitro gpu exit on kill

* correct bat script syntax

* Remove wait 5 second before start nitro

---------

Co-authored-by: Hien To <[email protected]>
  • Loading branch information
hiento09 and hiento09 authored Dec 26, 2023
1 parent 4cd7466 commit 7c0b45f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
15 changes: 8 additions & 7 deletions extensions/inference-nitro-extension/bin/linux-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ export CUDA_VISIBLE_DEVICES=$selectedGpuId

# Attempt to run nitro_linux_amd64_cuda
cd linux-cuda
if ./nitro "$@"; then
exit $?
else
echo "nitro_linux_amd64_cuda encountered an error, attempting to run nitro_linux_amd64..."
cd ../linux-cpu
./nitro "$@"
./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 $?
fi
)
7 changes: 4 additions & 3 deletions extensions/inference-nitro-extension/bin/win-start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ 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

nitro.exe %* > output.log
type output.log | findstr /C:"CUDA error" >nul
if %errorlevel% equ 0 ( goto :RunCpuVersion ) else ( goto :End )

:RunCpuVersion
rem Run nitro_windows_amd64.exe...
Expand Down
1 change: 1 addition & 0 deletions extensions/inference-nitro-extension/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async function loadModel(nitroResourceProbe: any | undefined) {
// Gather system information for CPU physical cores and memory
if (!nitroResourceProbe) nitroResourceProbe = await getResourcesInfo();
return killSubprocess()
.then(() => tcpPortUsed.waitUntilFree(PORT, 300, 5000))
.then(() => spawnNitroProcess(nitroResourceProbe))
.then(() => loadLLMModel(currentSettings))
.then(validateModelStatus)
Expand Down

0 comments on commit 7c0b45f

Please sign in to comment.