Commit 0f8a467 for stable-diffusion.cpp
commit 0f8a46702b3b87629f2d00e6acb4c5be1f930076
Author: leejet <leejet714@gmail.com>
Date: Sat Nov 14 02:56:17 2026 +0800
docs: consolidate and simplify HIP build instructions
diff --git a/docs/build.md b/docs/build.md
index 8fc4380..8cf235b 100644
--- a/docs/build.md
+++ b/docs/build.md
@@ -157,30 +157,70 @@ the old bundled path becomes `thirdparty/cutlass`, while custom paths and an
empty disabled value are preserved. An explicitly set `SD_CUDA_CUTLASS_PATH`
takes precedence. Non-CUDA builds do not require CUTLASS.
-## Build with HipBLAS
+## Build with HIPBLAS
-This provides GPU acceleration using AMD GPU. Make sure to have the ROCm toolkit installed.
-To build for another GPU architecture than installed in your system, set `$GFX_NAME` manually to the desired architecture (replace first command). This is also necessary if your GPU is not officially supported by ROCm, for example you have to set `$GFX_NAME` manually to `gfx1030` for consumer RDNA2 cards.
+Use `-DSD_HIPBLAS=ON` for AMD GPU acceleration through HIP and hipBLAS.
+Install a compatible AMD GPU driver and the ROCm SDK, including the HIP compiler,
+hipBLAS, rocBLAS, and their development files. See
+[AMD's ROCm installation guide](https://rocm.docs.amd.com/en/latest/install/rocm.html)
+for supported GPUs, operating systems, and installation methods.
-You may need to set up some prerequisites from the [AMD ROCm site](https://rocm.docs.amd.com/en/latest/install/rocm.html) based on your GPU and OS type. Once the repository has been registered, you can proceed with the steps below.
+**Linux**
-Windows User Refer to [docs/hipBLAS_on_Windows.md](docs%2FhipBLAS_on_Windows.md) for a comprehensive guide.
+With ROCm installed, use the default CMake generator and host compilers:
```shell
mkdir build && cd build
-export ROCM_VERSION=10.1
-if command -v rocminfo; then export GFX_NAME=$(rocminfo | awk '/ *Name: +gfx[1-9]/ {print $2; exit}'); else echo "rocminfo missing!"; fi
-sudo apt install amdrocm${ROCM_VERSION}-${GFX_NAME}
-if [ -z "${GFX_NAME}" ]; then
- echo "Error: Couldn't detect GPU!"
- exit 1
-fi
-sudo apt install "amdrocm${ROCM_VERSION}-${GFX_NAME}"
-echo "Building for GPU: ${GFX_NAME}"
-cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DGPU_TARGETS=$GFX_NAME -DAMDGPU_TARGETS=$GFX_NAME -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
+cmake .. -DSD_HIPBLAS=ON
cmake --build . --config Release
```
+For an SDK outside the default installation path, set `ROCM_PATH` to its root
+and add `$ROCM_PATH/bin` to `PATH` before configuring. If its shared libraries
+are not on the system library search path, add `$ROCM_PATH/lib` and
+`$ROCM_PATH/lib64` to `LD_LIBRARY_PATH` when running the executable.
+
+**Windows**
+
+Install Visual Studio 2022 C++ build tools with the Windows SDK, CMake, and
+Ninja. Open an x64 **Developer PowerShell for VS 2022**. The Windows HIP build
+uses ROCm Clang with Ninja; the Visual Studio generator is not supported.
+
+Set `HIP_PATH` to the SDK root. The HIP SDK installer normally sets this variable;
+for [ROCm wheels](https://github.com/ROCm/TheRock/blob/main/RELEASES.md), run
+`rocm-sdk init` and use `rocm-sdk path --root`. The build commands below cover
+both the installer and wheel SDK compiler layouts.
+
+For the wheel SDK, also set the device library path before building:
+
+```powershell
+$env:HIP_DEVICE_LIB_PATH = "$env:HIP_PATH\lib\llvm\amdgcn\bitcode"
+```
+
+Then configure and build:
+
+```powershell
+$env:ROCM_PATH = $env:HIP_PATH
+$env:PATH = "$env:HIP_PATH\bin;$env:HIP_PATH\lib\llvm\bin;$env:PATH"
+cmake -S . -B build-hip -G Ninja -DSD_HIPBLAS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
+cmake --build build-hip --config Release
+```
+
+Keep the SDK's `bin` directory on `PATH` when running `build-hip\bin\sd-cli.exe`
+so its runtime DLLs can be found.
+
+**GPU targets and verification**
+
+CMake normally detects the installed GPU. To select a target explicitly or build
+on a machine without an AMD GPU, add `-DGPU_TARGETS=gfx1100` to the configure
+command (for example, for an RX 7900 XTX, XT, or GRE). For multiple targets, use a
+quoted list such as `-DGPU_TARGETS="gfx1100;gfx1200"`. Check AMD's
+[GPU specifications](https://rocm.docs.amd.com/en/latest/reference/gpu-specs.html)
+for the correct target; the installed SDK libraries must also support it.
+
+Use a fresh build directory when switching SDKs or compilers. Run the resulting
+`sd-cli --version` to check that the executable starts without loading a model.
+
## Build with MUSA
This provides GPU acceleration using Moore Threads GPUs. The configuration below follows upstream validation with MUSA SDK 5.2.0 and MTT S5000 (PH1, `mp_31`). Install that toolkit before building. Older SDKs such as 4.2 may lack the CUB headers required by the current backend.
diff --git a/docs/hipBLAS_on_Windows.md b/docs/hipBLAS_on_Windows.md
deleted file mode 100644
index cd84657..0000000
--- a/docs/hipBLAS_on_Windows.md
+++ /dev/null
@@ -1,88 +0,0 @@
-# Using hipBLAS on Windows
-
-To get hipBLAS in `stable-diffusion.cpp` working on Windows, go through this guide section by section.
-
-## Build Tools for Visual Studio 2022
-
-Skip this step if you already have Build Tools installed.
-
-To install Build Tools, go to [Visual Studio Downloads](https://visualstudio.microsoft.com/vs/), download `Visual Studio 2022 and other Products` and run the installer.
-
-## CMake
-
-Skip this step if you already have CMake installed: running `cmake --version` should output `cmake version x.y.z`.
-
-Download latest `Windows x64 Installer` from [Download | CMake](https://cmake.org/download/) and run it.
-
-## ROCm
-
-Skip this step if you already have Build Tools installed.
-
-The [validation tools](https://rocm.docs.amd.com/en/latest/reference/validation_tools.html) not support on Windows. So you should confirm the Version of `ROCM` by yourself.
-
-Fortunately, `AMD` provides complete help documentation, you can use the help documentation to install [ROCM](https://rocm.docs.amd.com/en/latest/deploy/windows/quick_start.html)
-
->**If you encounter an error, if it is [AMD ROCm Windows Installation Error 215](https://github.com/RadeonOpenCompute/ROCm/issues/2363), don't worry about this error. ROCM has been installed correctly, but the vs studio plugin installation failed, we can ignore it.**
-
-Then we must set `ROCM` as environment variables before running cmake.
-
-Usually if you install according to the official tutorial and do not modify the ROCM path, then there is a high probability that it is here `C:\Program Files\AMD\ROCm\7.1.1\bin`
-
-This is what I use to set the clang:
-```Commandline
-set CC=C:\Program Files\AMD\ROCm\7.1.1\bin\clang.exe
-set CXX=C:\Program Files\AMD\ROCm\7.1.1\bin\clang++.exe
-```
-
-## Ninja
-
-Skip this step if you already have Ninja installed: running `ninja --version` should output `1.11.1`.
-
-Download latest `ninja-win.zip` from [GitHub Releases Page](https://github.com/ninja-build/ninja/releases/tag/v1.11.1) and unzip. Then set as environment variables. I unzipped it in `C:\Program Files\ninja`, so I set it like this:
-
-```Commandline
-set ninja=C:\Program Files\ninja\ninja.exe
-```
-## Building stable-diffusion.cpp
-
-The thing different from the regular CPU build is `-DSD_HIPBLAS=ON` ,
-`-G "Ninja"`, `-DCMAKE_C_COMPILER=clang`, `-DCMAKE_CXX_COMPILER=clang++`, `-DAMDGPU_TARGETS=gfx1150;gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032`
-
->**Notice**: check the `clang` and `clang++` information:
-```Commandline
-clang --version
-clang++ --version
-```
-
-If you see like this, we can continue:
-```
-clang version 17.0.0 (git@github.amd.com:Compute-Mirrors/llvm-project e3201662d21c48894f2156d302276eb1cf47c7be)
-Target: x86_64-pc-windows-msvc
-Thread model: posix
-InstalledDir: C:\Program Files\AMD\ROCm\7.1.1\bin
-```
-
-```
-clang version 17.0.0 (git@github.amd.com:Compute-Mirrors/llvm-project e3201662d21c48894f2156d302276eb1cf47c7be)
-Target: x86_64-pc-windows-msvc
-Thread model: posix
-InstalledDir: C:\Program Files\AMD\ROCm\7.1.1\bin
-```
-
->**Notice** that the GPU targets are now compatible with multiple GPU architectures (ROCm 7.1.1 targets). You can change them to match your GPU architecture. Click here to see your architecture [LLVM Target](https://rocm.docs.amd.com/en/latest/release/windows_support.html#windows-supported-gpus)
-
-Examples:
-- AMD Radeon™ RX 7900 XTX Graphics: `gfx1100`
-- AMD Radeon™ RX 7900 XT Graphics: `gfx1101`
-- AMD Radeon™ RX 7900 GRE Graphics: `gfx1102`
-
-option:
-
-```commandline
-mkdir build
-cd build
-cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1150;gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
-cmake --build . --config Release
-```
-
-If everything went OK, `build\bin\sd-cli.exe` file should appear.