Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal
- pushd "%~dp0"
- set NCCL_ROOT=S:\nccl-windows\install
- set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
- if not exist "%VSWHERE%" (
- echo Error: Could not find vswhere.exe at "%VSWHERE%".
- exit /b 1
- )
- 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"
- if not defined VS_INSTALL (
- echo Error: Could not locate a Visual Studio 2022 installation with C++ tools. CUDA 13.3 requires a VS 2022 host compiler.
- exit /b 1
- )
- call "%VS_INSTALL%\VC\Auxiliary\Build\vcvarsall.bat" x64
- if errorlevel 1 exit /b %errorlevel%
- set "CMAKE_EXE=%VS_INSTALL%\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
- if not exist "%CMAKE_EXE%" set "CMAKE_EXE="
- if not defined CMAKE_EXE for %%I in (cmake.exe) do set "CMAKE_EXE=%%~$PATH:I"
- if not exist "%CMAKE_EXE%" (
- echo Error: Could not locate cmake.exe in the Visual Studio 2022 installation or in PATH.
- exit /b 1
- )
- set "CUDA_ROOT=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.3"
- set "CUDA_NVCC=%CUDA_ROOT%\bin\nvcc.exe"
- if not exist "%CUDA_NVCC%" (
- echo Error: Could not find nvcc.exe at "%CUDA_NVCC%".
- exit /b 1
- )
- set "BUILD_DIR=build-msvc-cuda-server"
- set "TARGET_NAME=llama-server"
- set "NCCL_BIN_DIR=S:\nccl-windows\install\bin"
- set "CUDA_DLL_DIR=%CUDA_ROOT%\bin\x64"
- if /I "%~1"=="clean" (
- if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
- )
- rem Build fatbins for RTX 5070 Ti class GPUs (sm_120).
- rem Configure the normal server example target graph, but only compile llama-server
- rem and the DLL targets it depends on into a separate output tree.
- "%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
- if errorlevel 1 exit /b %errorlevel%
- "%CMAKE_EXE%" --build "%BUILD_DIR%" --config Release --target "%TARGET_NAME%" --verbose --parallel
- set "BUILD_EXIT=%ERRORLEVEL%"
- if "%BUILD_EXIT%"=="0" (
- echo.
- echo Built "%BUILD_DIR%\bin\%TARGET_NAME%.exe" with its required project DLLs in "%BUILD_DIR%\bin".
- echo Run "%~nx0 clean" for a full rebuild of the dedicated server-only tree.
- )
- popd
- exit /b %BUILD_EXIT%
Advertisement
Add Comment
Please, Sign In to add comment