build_windows.bat builds strata.exe + strata-device.exe (and with `tests` every HIP test) for gfx1100;gfx1101;gfx1102;gfx1200;gfx1201;gfx1030 with no admin rights and no AMD GPU: ROCm 10.2.0a20260930 from AMD's TheRock wheels (whl-next: rocm[libraries,devel,device-<arch>...], the version #325 ran on an RX 9070 XT) in a private venv (.rocm-win, ~7 GB), ROCm's clang as host and HIP compiler with MSVC's headers/linker from vcvars, STRATA_PORTABLE (AVX2 ggml). package_windows.py makes dist/strata-windows-x64-hip.zip (524 MiB, 810 MiB unpacked): strata.exe (61 MiB), strata-device.exe, BUILD.json (backend hip, archs, ROCm and hipBLASLt versions, lib_dirs rocm/bin), rocm/bin with the DLLs the programs import followed through ROCm (amdhip64_7, hipblas, rocblas, rocsolver, libhipblaslt, libtensilelite-host, origami, rocm_kpack) + amd_comgr (loaded by name) + the MSVC runtime, rocBLAS/hipBLASLt kernels for these archs, rocBLAS's kpack device code (found at ../.kpack from rocblas.dll), licenses and a NOTICE. The user needs only the AMD driver (the HIP runtime uses its user-mode components). Checked on this PC's Ryzen iGPU (gfx1036, a test build of the same tree): with only the zip's rocm/bin on PATH, strata-device lists the card and hipblasGemmEx BF16 -> FP32 (T=100) matches the CPU (max err 4.7e-7); ctest 52 of 56 pass, the 4 failures the same as #325's RX 9070 XT run (hip_handoff, and ple_parity / expert_parity / pool_test without the pack fixture).
87 lines
5.2 KiB
Batchfile
87 lines
5.2 KiB
Batchfile
@echo off
|
|
rem Strata's HIP (AMD) engine for Windows, and the ready-made zip setup.py downloads (strata-windows-x64-hip.zip).
|
|
rem
|
|
rem tools\hip\build_windows.bat build strata.exe + strata-device.exe and package dist\strata-windows-x64-hip.zip
|
|
rem tools\hip\build_windows.bat tests also build the HIP unit tests (ctest in build-hip-win; they need an AMD GPU)
|
|
rem
|
|
rem Needs: Visual Studio 2022 (or 2019) Build Tools with the C++ workload (the linker, the CRT and the Windows SDK),
|
|
rem Python 3.10+ and git. No admin rights and no AMD GPU: ROCm comes from AMD's TheRock Python wheels (the same
|
|
rem ROCm 10.2 nightly #325 ran on an RX 9070 XT), installed into a private venv (ROCM_VENV, ~7 GB). CMake refuses to
|
|
rem mix cl.exe with Clang for HIP, so ROCm's clang compiles the host code too (targeting the MSVC ABI, with MSVC's
|
|
rem headers and linker from vcvars); cmake/hip_backend.cmake force-includes the CUDA->HIP shim.
|
|
rem
|
|
rem Settings (environment variables, all optional):
|
|
rem STRATA_HIP_ARCHS gfx1100;gfx1101;gfx1102;gfx1200;gfx1201;gfx1030 (the cards setup supports, + gfx1102)
|
|
rem STRATA_ROCM_VERSION 10.2.0a20260930 STRATA_ROCM_INDEX https://nightly.repo.amd.com/rocm/whl-next/
|
|
rem ROCM_VENV <repo>\.rocm-win BUILD_DIR <repo>\build-hip-win DIST_DIR <repo>\dist
|
|
rem STRATA_GGML_DIR a llama.cpp checkout at the pinned commit (default: CMake fetches it)
|
|
setlocal EnableDelayedExpansion
|
|
for %%I in ("%~dp0..\..") do set "SRC=%%~fI"
|
|
if not defined STRATA_HIP_ARCHS set "STRATA_HIP_ARCHS=gfx1100;gfx1101;gfx1102;gfx1200;gfx1201;gfx1030"
|
|
if not defined STRATA_ROCM_VERSION set "STRATA_ROCM_VERSION=10.2.0a20260930"
|
|
if not defined STRATA_ROCM_INDEX set "STRATA_ROCM_INDEX=https://nightly.repo.amd.com/rocm/whl-next/"
|
|
if not defined ROCM_VENV set "ROCM_VENV=%SRC%\.rocm-win"
|
|
if not defined BUILD_DIR set "BUILD_DIR=%SRC%\build-hip-win"
|
|
if not defined DIST_DIR set "DIST_DIR=%SRC%\dist"
|
|
set "TESTS=OFF"
|
|
if /i "%~1"=="tests" set "TESTS=ON"
|
|
|
|
rem ---- 1. ROCm (TheRock wheels: the compiler, the HIP runtime, hipBLAS/hipBLASLt/rocBLAS, a device package per arch)
|
|
set "PY="
|
|
py -3 -c "import sys" >nul 2>nul && set "PY=py -3"
|
|
if not defined PY python -c "import sys" >nul 2>nul && set "PY=python"
|
|
if not defined PY (echo Python 3.10+ is needed & exit /b 1)
|
|
if not exist "%ROCM_VENV%\Scripts\python.exe" %PY% -m venv "%ROCM_VENV%" || exit /b 1
|
|
set "EXTRAS=libraries,devel"
|
|
for %%A in (%STRATA_HIP_ARCHS:;= %) do set "EXTRAS=!EXTRAS!,device-%%A"
|
|
set "STAMP=%ROCM_VENV%\strata-rocm.txt"
|
|
set "WANT=%STRATA_ROCM_VERSION% %EXTRAS%"
|
|
set "HAVE="
|
|
if exist "%STAMP%" set /p HAVE=<"%STAMP%"
|
|
if not "!HAVE!"=="!WANT!" (
|
|
echo Installing ROCm %STRATA_ROCM_VERSION% [%EXTRAS%] into %ROCM_VENV% ...
|
|
"%ROCM_VENV%\Scripts\python.exe" -m pip install --disable-pip-version-check --index-url "%STRATA_ROCM_INDEX%" "rocm[%EXTRAS%]==%STRATA_ROCM_VERSION%" || exit /b 1
|
|
"%ROCM_VENV%\Scripts\rocm-sdk.exe" init || exit /b 1
|
|
>"%STAMP%" echo !WANT!
|
|
)
|
|
for /f "delims=" %%R in ('"%ROCM_VENV%\Scripts\rocm-sdk.exe" path --root') do set "ROCM=%%R"
|
|
if not exist "%ROCM%\lib\llvm\bin\clang++.exe" (echo ROCm has no compiler in "%ROCM%" & exit /b 1)
|
|
set "ROCM_F=%ROCM:\=/%"
|
|
set "BITCODE=%ROCM_F%/lib/llvm/amdgcn/bitcode"
|
|
|
|
rem ---- 2. MSVC: the linker, the C runtime and the Windows SDK (ROCm's clang uses them)
|
|
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
set "VS="
|
|
if exist "%VSWHERE%" for /f "delims=" %%V in ('"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath') do set "VS=%%V"
|
|
if not defined VS (echo Visual Studio Build Tools with the C++ workload are needed & exit /b 1)
|
|
call "%VS%\VC\Auxiliary\Build\vcvars64.bat" >nul || exit /b 1
|
|
set "HIP_PLATFORM=amd"
|
|
set "HIP_PATH=%ROCM%"
|
|
set "ROCM_PATH=%ROCM%"
|
|
set "PATH=%ROCM%\bin;%ROCM%\lib\llvm\bin;%PATH%"
|
|
|
|
rem ---- 3. configure + build (STRATA_PORTABLE: the CPU kernels for an AVX2 baseline, as in the NVIDIA zip)
|
|
set "GGML="
|
|
if defined STRATA_GGML_DIR set "GGML=-DSTRATA_GGML_DIR=%STRATA_GGML_DIR:\=/%"
|
|
if not exist "%BUILD_DIR%\build.ninja" (
|
|
cmake -G Ninja -S "%SRC%" -B "%BUILD_DIR%" -DCMAKE_BUILD_TYPE=Release ^
|
|
-DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=%TESTS% -DSTRATA_PREFILL_MMQ=ON ^
|
|
-DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_PORTABLE=ON "-DCMAKE_HIP_ARCHITECTURES=%STRATA_HIP_ARCHS%" ^
|
|
"-DCMAKE_C_COMPILER=%ROCM_F%/lib/llvm/bin/clang.exe" "-DCMAKE_CXX_COMPILER=%ROCM_F%/lib/llvm/bin/clang++.exe" ^
|
|
"-DCMAKE_HIP_COMPILER=%ROCM_F%/lib/llvm/bin/clang++.exe" "-DCMAKE_HIP_COMPILER_ROCM_ROOT=%ROCM_F%" ^
|
|
"-DCMAKE_PREFIX_PATH=%ROCM_F%" "-DCMAKE_HIP_FLAGS=--rocm-path=%ROCM_F% --rocm-device-lib-path=%BITCODE%" ^
|
|
%GGML% || exit /b 1
|
|
)
|
|
if "%TESTS%"=="ON" (
|
|
cmake --build "%BUILD_DIR%" || exit /b 1
|
|
) else (
|
|
cmake --build "%BUILD_DIR%" --target strata strata-device || exit /b 1
|
|
)
|
|
|
|
rem ---- 4. the zip: the two programs, the ROCm DLLs they load (+ rocBLAS/hipBLASLt kernels for these archs), licenses
|
|
"%ROCM_VENV%\Scripts\python.exe" "%SRC%\tools\hip\package_windows.py" --build "%BUILD_DIR%" --rocm "%ROCM%" ^
|
|
--archs "%STRATA_HIP_ARCHS%" --rocm-version "%STRATA_ROCM_VERSION%" --out "%DIST_DIR%" || exit /b 1
|
|
echo.
|
|
echo Done: %DIST_DIR%\strata-windows-x64-hip.zip
|
|
endlocal
|