NickCanCode

build_win_msvc_server.bat

Jun 5th, 2026
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. @echo off
  2. setlocal
  3. pushd "%~dp0"
  4.  
  5. set NCCL_ROOT=S:\nccl-windows\install
  6.  
  7. set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
  8. if not exist "%VSWHERE%" (
  9. echo Error: Could not find vswhere.exe at "%VSWHERE%".
  10. exit /b 1
  11. )
  12.  
  13. for /f "usebackq delims=" %%I in (`"%VSWHERE%" -latest -version [17.0^,18.0^) -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VS_INSTALL=%%I"
  14. if not defined VS_INSTALL (
  15. echo Error: Could not locate a Visual Studio 2022 installation with C++ tools. CUDA 13.3 requires a VS 2022 host compiler.
  16. exit /b 1
  17. )
  18.  
  19. call "%VS_INSTALL%\VC\Auxiliary\Build\vcvarsall.bat" x64
  20. if errorlevel 1 exit /b %errorlevel%
  21.  
  22. set "CMAKE_EXE=%VS_INSTALL%\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
  23. if not exist "%CMAKE_EXE%" set "CMAKE_EXE="
  24. if not defined CMAKE_EXE for %%I in (cmake.exe) do set "CMAKE_EXE=%%~$PATH:I"
  25. if not exist "%CMAKE_EXE%" (
  26. echo Error: Could not locate cmake.exe in the Visual Studio 2022 installation or in PATH.
  27. exit /b 1
  28. )
  29.  
  30. set "CUDA_ROOT=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.3"
  31. set "CUDA_NVCC=%CUDA_ROOT%\bin\nvcc.exe"
  32. if not exist "%CUDA_NVCC%" (
  33. echo Error: Could not find nvcc.exe at "%CUDA_NVCC%".
  34. exit /b 1
  35. )
  36.  
  37. set "BUILD_DIR=build-msvc-cuda-server"
  38. set "TARGET_NAME=llama-server"
  39. set "NCCL_BIN_DIR=S:\nccl-windows\install\bin"
  40. set "CUDA_DLL_DIR=%CUDA_ROOT%\bin\x64"
  41.  
  42. if /I "%~1"=="clean" (
  43. if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
  44. )
  45.  
  46. rem Build fatbins for RTX 5070 Ti class GPUs (sm_120).
  47. rem Configure the normal server example target graph, but only compile llama-server
  48. rem and the DLL targets it depends on into a separate output tree.
  49. "%CMAKE_EXE%" -S . -B "%BUILD_DIR%" -G Ninja -DGGML_CUDA=ON -DGGML_NATIVE=ON -DGGML_CUDA_FA=ON -DGGML_CUDA_FA_ALL_QUANTS=ON -DGGML_NCCL=ON -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_CUDA_COMPILER="%CUDA_NVCC%" -DCUDAToolkit_ROOT="%CUDA_ROOT%" -DCMAKE_CUDA_ARCHITECTURES="120-real" -DBUILD_SHARED_LIBS=ON -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_EXAMPLES=ON -DLLAMA_BUILD_SERVER=ON -DLLAMA_CURL=OFF -DGGML_OPENMP=ON -DCMAKE_BUILD_TYPE=Release
  50. if errorlevel 1 exit /b %errorlevel%
  51.  
  52. "%CMAKE_EXE%" --build "%BUILD_DIR%" --config Release --target "%TARGET_NAME%" --verbose --parallel
  53. set "BUILD_EXIT=%ERRORLEVEL%"
  54.  
  55. if "%BUILD_EXIT%"=="0" (
  56. echo.
  57. echo Built "%BUILD_DIR%\bin\%TARGET_NAME%.exe" with its required project DLLs in "%BUILD_DIR%\bin".
  58. echo Run "%~nx0 clean" for a full rebuild of the dedicated server-only tree.
  59. )
  60.  
  61. popd
  62. exit /b %BUILD_EXIT%
  63.  
Advertisement
Add Comment
Please, Sign In to add comment