目次
注意事項
- 20250808 段階で、まだ正式なビルド方法ではない
- あくまでビルドが通って多少遊べるだけ
- サーバーの動作が安定しなかったり落ちたりする
- 特に 20000 トークンなど大きく渡すエージェントとしての運用(ccr router などでの運用)だと途中で GPU Hang などを起こして落ちたりして使い物にならない
- そういった運用は vulkan の方が安定していそう?
(推奨)ビルド手順 - docker 版
必要環境
- ホスト OS は ubuntu24.04 なら動いたが、それ以外の環境は試していない
uname -r
-> 6.11.0-26-generic
- amdgpu のドライバが既に入っている
- 無い人は以下を実行
-
wget https://repo.radeon.com/amdgpu-install/6.4.1/ubuntu/noble/amdgpu-install_6.4.60401-1_all.deb sudo apt install ./amdgpu-install_6.4.60401-1_all.deb sudo apt update sudo apt install "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)" sudo apt install amdgpu-dkms #ドライバインストール
- その後再起動
-
- 無い人は以下を実行
docker ビルド用リポジトリをクローン
以下の URL をクローンする
GitHub - TOSUKUi/llama.cpp-therock-docker
Contribute to TOSUKUi/llama.cpp-therock-docker development by creating an account on GitHub.
git clone https://github.com/TOSUKUi/llama.cpp-therock-docker
cd llama.cpp-therock-docker
ビルド方法は基本 README に書いてあるが、今回はコマンドベースでメモしておく
ビルド(gfx1151 向け)
docker build . --tag llama.cpp-therock:latest --build-arg=therock_tarball_filename=therock-dist-linux-gfx1151-7.0.0rc20250710.tar.gz
5~6 分かかるので気長に待つ。
ここで指定する tarball のファイル名は、以下の s3 のリストから参照する。
therock-nightly-tarball.s3.amazonaws.com
実行
ベンチマーク
- モデルはこちらを利用: https://huggingface.co/TheBloke/Llama-2-7B-GGUF
- /path/to/models はモデルをダウンロードしたディレクトリを指定する
docker run -it -p 8080:8080 -v /path/to/models:/app/models --device /dev/kfd --device /dev/dri --security-opt seccomp=unconfined llama.cpp:therock-dist-linux-gfx1151-7.0.0rc20250710 build/bin/llama-bench -mmp 0 -ngl 99 -m ./models/llama-2-7b.Q4_0.gguf
# 出力
ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no
ggml_cuda_init: GGML_CUDA_FORCE_CUBLAS: no
ggml_cuda_init: found 1 ROCm devices:
Device 0: AMD Radeon Graphics, gfx1151 (0x1151), VMM: no, Wave Size: 32
| model | size | params | backend | ngl | mmap | test | t/s |
| ------------------------------ | ---------: | ---------: | ---------- | --: | ---: | --------------: | -------------------: |
| llama 7B Q4_0 | 3.56 GiB | 6.74 B | ROCm | 99 | 0 | pp512 | 995.40 ± 2.98 |
| llama 7B Q4_0 | 3.56 GiB | 6.74 B | ROCm | 99 | 0 | tg128 | 47.92 ± 0.04 |
build: 7de5c7ca (5882)
API サーバー
note: --no-mmap
をつけない場合、システムメモリ以上の VRAM を使えなくなるので、必ずつける
docker run -it -p 8080:8080 -v /mnt/data/models/llama.cpp/common/:/app/models --device /dev/kfd --device /dev/dri --security-opt seccomp=unconfined llama.cpp:therock-dist-linux-gfx1151-7.0.0rc20250710 build/bin/llama-server --no-mmap -ngl 99 -m ./models/llama-2-7b.Q4_0.gguf --host 0.0.0.0
(非推奨) ビルド手順 - 手動(ubuntu25.04以上必須なので、それ以下のOSの場合は上記のdocker版をまず試して欲しい)
(非推奨) ビルド手順 - 手動(ubuntu25.04 以上必須なので、それ以下の OS の場合は上記の docker 版をまず試して欲しい)
必要環境
- ubuntu25.04 である必要があるが、実際に ubuntu25.04 で実行できることを確認していない(docker は少なくとも動いている)
- ubuntu24.04の場合は TheRock 版の Rocm を使う時点で実行時に segfault 食らうため、その場合は上記の docker 版のセットアップを行うこと
- 出力例
-
ROCBLAS_USE_HIPBLASLT=1 build/bin/llama-bench -mmp 0 -m ./models/llama-2-7b.Q4_0.gguf ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no ggml_cuda_init: GGML_CUDA_FORCE_CUBLAS: no ggml_cuda_init: found 1 ROCm devices: invalid architecture ID received for device 0 AMD Radeon Graphics: cc 1024.1024 Device 0: AMD Radeon Graphics, (0x4000), VMM: no, Wave Size: 0 Segmentation fault (core dumped)
- なんか docker 環境では
ubuntu:rolling
(25.04)をベースイメージにしたら動いた(カーネルは共有のはずなのでその上のどこかのスタックが違う?)
llama.cpp を clone して、作業ディレクトリにする
git clone https://github.com/ggml-org/llama.cpp llama.cpp-therock #適当に名前変えとく
cd llama.cpp-therock
TheRock 版の Rocm からビルド済みパッケージを持ってくる
github の release ページから therock-dist-linux-gfx1151-6.4.0
のパターンのものを持ってくる
Release nightly-tarball · ROCm/TheRock
Nightly ROCm SDK tarballs.
See https://github.com/ROCm/TheRock/blob/main/RELEASES.md#installing-from-tarballs for installation instructions.
今回は:therock-dist-linux-gfx1151-6.4.0rc20250520.tar.gz
を持ってくる
sudo mkdir -p /opt/rocm-6.4.0rc # もし違うディレクトリにしたければそこを指定
wget "https://github.com/ROCm/TheRock/releases/download/nightly-tarball/therock-dist-linux-gfx1151-6.4.0rc20250520.tar.gz"
解答して、/opt/rocmに入れる
sudo tar -xz -C /opt/rocm-6.4.0rc -f therock-dist-linux-gfx1151-6.4.0rc20250520.tar.gz
rm therock-dist-linux-gfx1151-6.4.0rc20250520.tar.gz # 不要なものは消す
環境変数を設定
これは何かしらファイルにして source できるようにしておくか、.envrc などで direnv から設定できるようにしておく方が望ましい
export ROCM_PATH="/opt/rocm-6.5.0rc"
export HIP_PLATFORM="amd"
export HIP_PATH="${ROCM_PATH}"
export HIP_CLANG_PATH="${ROCM_PATH}/llvm/bin"
export HIP_INCLUDE_PATH="${ROCM_PATH}/include"
export HIP_LIB_PATH="${ROCM_PATH}/lib"
export HIP_DEVICE_LIB_PATH="${ROCM_PATH}/lib/llvm/amdgcn/bitcode"
export PATH="${ROCM_PATH}/bin:${HIP_CLANG_PATH}:${PATH}"
export LD_LIBRARY_PATH="${ROCM_PATH}/lib:${ROCM_PATH}/lib64:${ROCM_PATH}/llvm/lib:${LD_LIBRARY_PATH}"
export LIBRARY_PATH="${ROCM_PATH}/lib:${ROCM_PATH}/lib64:${LIBRARY_PATH}"
export CPATH="${HIP_INCLUDE_PATH}:${CPATH}"
export PKG_CONFIG_PATH="${ROCM_PATH}/lib/pkgconfig:${PKG_CONFIG_PATH}"
この辺の参考リンク
Strix Halo
Those looking for my testing code: https://github.com/lhl/strix-halo-testing I will try to datestamp and version most of these sections since there is amount of flux/work going on and some of this will be outdated soon.

llama.cpp の一部書き換え
ggml/src/ggml-cuda/vendors/hip.h
旧 Rocm 向けのマクロを、TheRock 版の Rocm 向けのマクロに置き換える
これをやらないとビルドが通らない。llama.cpp 自体が対応したら不必要になると思われる。
sed -i \
-e 's/#define CUBLAS_COMPUTE_16F HIPBLAS_R_16F/#define CUBLAS_COMPUTE_16F HIPBLAS_COMPUTE_16F/' \
-e 's/#define CUBLAS_COMPUTE_32F HIPBLAS_R_32F/#define CUBLAS_COMPUTE_32F HIPBLAS_COMPUTE_32F/' \
-e 's/#define CUBLAS_COMPUTE_32F_FAST_16F HIPBLAS_R_32F/#define CUBLAS_COMPUTE_32F_FAST_16F HIPBLAS_COMPUTE_32F_FAST_16F/' \
-e 's/#define cublasComputeType_t hipblasDatatype_t/#define cublasComputeType_t hipblasComputeType_t/' \
-e 's/#define cudaDataType_t hipblasDatatype_t/#define cudaDataType_t hipDataType/' \
"ggml/src/ggml-cuda/vendors/hip.h"
git diff
の結果が以下のような雰囲気なら大丈夫。
diff --git a/ggml/src/ggml-cuda/vendors/hip.h b/ggml/src/ggml-cuda/vendors/hip.h
index 184d445f..64d7d1c9 100644
--- a/ggml/src/ggml-cuda/vendors/hip.h
+++ b/ggml/src/ggml-cuda/vendors/hip.h
@@ -146,11 +146,11 @@
#define cublasComputeType_t hipblasComputeType_t
#define cudaDataType_t hipDataType
#else
-#define CUBLAS_COMPUTE_16F HIPBLAS_R_16F
-#define CUBLAS_COMPUTE_32F HIPBLAS_R_32F
-#define CUBLAS_COMPUTE_32F_FAST_16F HIPBLAS_R_32F
-#define cublasComputeType_t hipblasDatatype_t
-#define cudaDataType_t hipblasDatatype_t
+#define CUBLAS_COMPUTE_16F HIPBLAS_COMPUTE_16F
+#define CUBLAS_COMPUTE_32F HIPBLAS_COMPUTE_32F
+#define CUBLAS_COMPUTE_32F_FAST_16F HIPBLAS_COMPUTE_32F_FAST_16F
+#define cublasComputeType_t hipblasComputeType_t
+#define cudaDataType_t hipDataType
#endif
#define __CUDA_ARCH__ 1300
参考リンク
TheRock で llama.cpp をビルド - Qiita
TheRock(ROCm の開発版)で llama.cpp をビルドしてみました。API に変更があり、llvm-rc がなかったため、多少の修正が必要でした。 準備 TheRock をビルドします。PyTorch は不要です。 リリースフォルダ build/dis...

llama.cpp をビルド
必要そうなものをインストールしておく。他に必要なものがあれば適宜入れる。
sudo apt install build-essential clang libcurl4-openssl-dev ninja-build
ビルド
mkdir build && cd build \
&& HIPCC="$(/opt/rocm-6.4.0rc/bin/hipconfig -l)/clang" \
cmake .. \
-G Ninja \
-DGGML_HIP=ON \
-DAMDGPU_TARGETS=gfx1151 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DHIP_PLATFORM=amd \
&& cmake --build . --config Release -- -j $(nproc)
テスト
ベンチマークを回す。
ここでは以下のモデルを使ってベンチマークする。
TheBloke/Llama-2-7B-GGUF · Hugging Face
We’re on a journey to advance and democratize artificial intelligence through open source and open science.

- note1:
-mmp 0
をつけない場合、システムメモリ以上のメモリをアロケーションできない - note2:
ROCBLAS_USE_HIPBLASLT=1
をつけるとパフォーマンスが 20%以上上がるので必須
ROCBLAS_USE_HIPBLASLT=1 build/bin/llama-bench -mmp 0 -m ./models/llama-2-7b.Q4_0.gguf
ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no
ggml_cuda_init: GGML_CUDA_FORCE_CUBLAS: no
ggml_cuda_init: found 1 ROCm devices:
Device 0: AMD Radeon Graphics, gfx1151 (0x1151), VMM: no, Wave Size: 32
build: 7de5c7ca (5882)
model | size | params | backend | ngl | mmap | test | t/s |
---|---|---|---|---|---|---|---|
llama 7B Q4_0 | 3.56 GiB | 6.74 B | ROCm | 99 | 0 | pp512 | 995.40 ± 2.98 |
llama 7B Q4_0 | 3.56 GiB | 6.74 B | ROCm | 99 | 0 | tg128 | 47.92 ± 0.04 |
ベンチマーク
docker 環境で回したものを記載する
model | size | params | backend | ngl | mmap | test | t/s |
---|---|---|---|---|---|---|---|
llama 7B Q4_0 | 3.56 GiB | 6.74 B | ROCm | 99 | 0 | pp512 | 994.53 ± 4.16 |
llama 7B Q4_0 | 3.56 GiB | 6.74 B | ROCm | 99 | 0 | tg128 | 47.92 ± 0.02 |
llama 13B Q4_K - Medium | 13.54 GiB | 23.57 B | ROCm | 99 | 0 | pp512 | 335.70 ± 3.06 |
llama 13B Q4_K - Medium | 13.54 GiB | 23.57 B | ROCm | 99 | 0 | tg128 | 13.71 ± 0.01 |
qwen3moe 30B.A3B Q4_K - Medium | 16.49 GiB | 30.53 B | ROCm | 99 | 0 | pp512 | 607.81 ± 5.31 |
qwen3moe 30B.A3B Q4_K - Medium | 16.49 GiB | 30.53 B | ROCm | 99 | 0 | tg128 | 56.55 ± 0.02 |
qwen3moe 30B.A3B Q8_0 | 33.51 GiB | 30.53 B | ROCm | 99 | 0 | pp512 | 601.03 ± 4.37 |
qwen3moe 30B.A3B Q8_0 | 33.51 GiB | 30.53 B | ROCm | 99 | 0 | tg128 | 37.91 ± 0.00 |
qwen3 32B Q4_K - Medium | 18.40 GiB | 32.76 B | ROCm | 99 | 0 | pp512 | 255.66 ± 2.72 |
qwen3 32B Q4_K - Medium | 18.40 GiB | 32.76 B | ROCm | 99 | 0 | tg128 | 9.91 ± 0.00 |
qwen3 32B Q8_0 | 36.76 GiB | 32.76 B | ROCm | 99 | 0 | pp512 | 246.55 ± 2.16 |
qwen3 32B Q8_0 | 36.76 GiB | 32.76 B | ROCm | 99 | 0 | tg128 | 5.67 ± 0.01 |
hunyuan-moe A13B Q4_K - Medium | 45.43 GiB | 80.39 B | ROCm | 99 | 0 | pp512 | 246.06 ± 3.46 |
hunyuan-moe A13B Q4_K - Medium | 45.43 GiB | 80.39 B | ROCm | 99 | 0 | tg128 | 22.56 ± 0.04 |
qwen3moe 235B.A22B Q3_K - Small | 94.47 GiB | 235.09 B | ROCm | 99 | 0 | pp512 | 125.91 ± 2.24 |
qwen3moe 235B.A22B Q3_K - Small | 94.47 GiB | 235.09 B | ROCm | 99 | 0 | tg128 | 13.52 ± 0.01 |
20250807 追記
GLM4.5-air A12B
PP が思ったより遅いのと、multi token predict があるにも関わらず t/s は思ったより伸びない
model | size | params | backend | ngl | mmap | test | t/s |
---|---|---|---|---|---|---|---|
glm4moe 106B.A12B Q4_K - Medium | 68.01 GiB | 110.47 B | ROCm,RPC | 998 | 0 | pp512 | 114.91 ± 0.23 |
glm4moe 106B.A12B Q4_K - Medium | 68.01 GiB | 110.47 B | ROCm,RPC | 998 | 0 | tg128 | 20.16 ± 0.02 |
gpt-oss 120B
pp も tg もいい感じで、実際にベンチマークしてみて使用感を確かめたいところ
active parameter 5.1b https://openai.com/ja-JP/index/introducing-gpt-oss/
model | size | params | backend | ngl | fa | mmap | test | t/s |
---|---|---|---|---|---|---|---|---|
gpt-oss ?B Q4_K - Medium | 58.68 GiB | 116.83 B | ROCm,RPC | 99 | 1 | 0 | pp512 | 356.22 ± 1.23 |
gpt-oss ?B Q4_K - Medium | 58.68 GiB | 116.83 B | ROCm,RPC | 99 | 1 | 0 | tg128 | 47.51 ± 0.01 |
gpt-oss ?B Q4_K - Medium | 58.68 GiB | 116.83 B | ROCm,RPC | 99 | 0 | 0 | pp512 | 596.35 ± 13.03 |
gpt-oss ?B Q4_K - Medium | 58.68 GiB | 116.83 B | ROCm,RPC | 99 | 0 | 0 | tg128 | 48.61 ± 0.04 |
8 月 8 日追記 pp8192 の結果も書く
model | size | params | backend | ngl | mmap | test | t/s |
---|---|---|---|---|---|---|---|
gpt-oss ?B Q4_K - Medium | 58.68 GiB | 116.83 B | ROCm,RPC | 99 | 0 | pp8192 | 432.96 ± 6.16 |
gpt-oss ?B Q4_K - Medium | 58.68 GiB | 116.83 B | ROCm,RPC | 99 | 0 | pp512 | 562.19 ± 68.35 |
参考リンク
GitHub - TOSUKUi/llama.cpp-therock-docker
Contribute to TOSUKUi/llama.cpp-therock-docker development by creating an account on GitHub.
TheRock で llama.cpp をビルド - Qiita
TheRock(ROCm の開発版)で llama.cpp をビルドしてみました。API に変更があり、llvm-rc がなかったため、多少の修正が必要でした。 準備 TheRock をビルドします。PyTorch は不要です。 リリースフォルダ build/dis...

Release nightly-tarball · ROCm/TheRock
Nightly ROCm SDK tarballs.
See https://github.com/ROCm/TheRock/blob/main/RELEASES.md#installing-from-tarballs for installation instructions.
Strix Halo
Those looking for my testing code: https://github.com/lhl/strix-halo-testing I will try to datestamp and version most of these sections since there is amount of flux/work going on and some of this will be outdated soon.
