RTX 3060 解鎖對本地 LLM 推理有用嗎?Q4 GGUF 速度沒有提升
Unlocking the RTX 3060 for Local LLM Inference: Worth It?
作者測試以 gpu-unlock v2.0.0 解鎖 RTX 3060,發現 Gemma 4 12B QAT(Q4_K_M)的推理速度沒有實質變化。llama-bench 測得 pp512 從 1276 t/s 升至 1280 t/s,tg128 則由 39.5 t/s 變為 39.48 t/s;Q4 GGUF 核心不使用 FP16 累加。
Unlocking the RTX 3060 for Local LLM Inference: Worth It? (Spoiler: Not for Q4 GGUF)
I run a home server with two NVIDIA cards: an RTX 3060 (12 GB) for local inference and an RTX 3070 (8 GB) for mining during idle hours. The inference model is Gemma 4 12B QAT (Q4_K_M) served by llama.cpp. When I read about a driver-level FP16 accumulate limit on GeForce Ampere cards, I wanted to see if removing it would speed things up.
What the limit is
According to the reports I read, GeForce cards run FP16 matrix operations with FP32 accumulation at half speed, while professional cards do not. The gpu-unlock project (Linux kernel module, v2.0.0) patches this at boot via a kernel command-line parameter. It lists the RTX 3060 as stable, based on user reports. It is a community project, not an NVIDIA project.
What I did
Confirmed the baseline with llama-bench on the 3060 alone (pp512, tg128) and with server timings for MTP (speculative decoding).
Checked secure boot (disabled), kernel headers, and PCI addresses.
Backed up GRUB config, systemd units, initramfs, and the kernel command line.
Built and installed the DKMS module for three kernels, and set gpu_unlock.targets to the 3060 and 3070 PCI addresses.
Cold-booted (power off, wait, power on).
The kernel log showed both cards unlocked with ret=0, and the NVIDIA driver attached normally.
Results
Metric
Before
After
pp512 (prompt processing, llama-bench)
1276 t/s
1280 t/s
tg128 (generation, llama-bench)
39.5 t/s
39.48 t/s
Prompt processing moved by 0.3%, which is within noise. Generation did not change, which is expected: decode is memory-bandwidth bound.
The reason is simple. GGUF Q4 kernels do not use FP16 accumulation, so the unlocked path is not on the critical path for this model. The project's own docs suggest that the benefit shows up in FP16/BF16 workloads such as unquantized models or diffusion pipelines. I have not verified that yet.
Lessons
Read the right README. I initially mixed up two similar projects, one of which had a diagnostics tool and different GPU support status. Check the repo you actually installed.
Check auto-switching before stopping a service. My own idle-monitor timer started mining on the 3060 as soon as I stopped the inference server. Stop the timer first.
Kernel updates can silently drop drivers. After a kernel bump, the NVIDIA module for the new kernel was missing because the metapackage was held. Confirm modprobe nvidia on the new kernel before rebooting.
Do not run nvidia-smi between building an unlock module and the cold boot. The project documentation warns about this.
Keep a stock GRUB entry. It is the fallback if a boot fails.
Rotate API keys that appear in logs or unit files. I replaced mine after exposing it in a shared output.
Reproducing the baseline
CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=0 \
llama-bench -m .gguf -ngl 99 -fa on -ctk q8_0 -ctv q8_0 \
-b 512 -ub 512 -p 512 -n 128 -r 3 -o md
CUDA_DEVICE_ORDER=PCI_BUS_ID matters. Without it, CUDA device indices can be swapped relative to nvidia-smi.
Status: unlock is installed and stable, but it does not change Q4 inference speed. I will revisit it with FP16/BF16 workloads.
RTX 3060のunlockはローカルLLMに効くのか?(結論:Q4のGGUFには効かない)
自宅サーバーにNVIDIAのGPUを2枚載せています。RTX 3060(12GB)は推論用、RTX 3070(8GB)は夜間などの空き時間にマイニングに使っています。推論には、llama.cppで動かしたGemma 4 12B QAT(Q4_K_M)を使っています。GeForceのAmpere世代には、FP16行列演算がFP32アキュムレートで半減される制限があると知り、それを外せば速くなるか試しました。
制限の中身
報告によると、GeForceではFP16の行列演算をFP32で積み上げる(アキュムレート)と、速度が半分に抑えられています。一方、プロ向けのカードでは抑えられていません。gpu-unlock(Linuxのカーネルモジュール、v2.0.0)は、起動時にカーネルのコマンドラインで指定すると、この制限を外します。作者のREADMEでは、RTX 3060は「安定(ユーザー報告100件以上)」と書かれています。NVIDIAの公式プロジェクトではなく、個人のコミュニティ製です。
やったこと
unlock前のベースラインを取る。llama-bench で3060単独のpp512とtg128、サーバー経由でMTP(投機的デコード)の速度を測る。
セキュアブートの状態(無効)、カーネルヘッダ、PCIアドレスを確認する。
GRUBの設定、systemdのユニット、initramfs、カーネルのコマンドラインをバックアップする。
3つのカーネル向けにDKMSモジュールをビルドしてインストールし、gpu_unlock.targets に3060と3070のPCIアドレスを指定する。
コールドブート(電源を完全に切ってから入れる)で起動する。
カーネルログには、両方のカードが unlocked(ret=0)と出て、NVIDIAドライバも正常に接続されました。
結果
項目
unlock前
unlock後
pp512(プロンプト処理、llama-bench)
1276 t/s
1280 t/s
tg128(生成、llama-bench)
39.5 t/s
39.48 t/s
プロンプト処理は0.3%の差で、誤差の範囲です。生成は変わりませんでした。生成はメモリ帯域で律速しているので、これは想定どおりです。
理由は単純で、GGUFのQ4カーネルはFP16アキュムレートを使わないからです。つまり、unlockで開く経路が、このモデルの計算では使われていません。プロジェクトの説明でも、効果が出るのはFP16/BF16の処理(非量子化モデルや画像生成など)とされています。そこはまだ検証できていません。
学んだこと
正しいREADMEを読む。 似た名前の2つのプロジェクトを混同してしまいました。実際にインストールしたリポジトリの説明を確認しましょう。
サービスを止める前に、自動切り替えを確認する。 私が推論サーバーを止めた途端、自作のidle-monitorタイマーが3060でマイニングを始めました。先にタイマーを止めるべきでした。
カーネル更新で、ドライバが抜けることがある。 カーネルを上げたら、新しいカーネル用のNVIDIAモジュールが入っていませんでした。メタパッケージがholdされていたのが原因です。再起動の前に、新しいカーネルで modprobe nvidia が通るかを確認しましょう。
unlockモジュールをビルドしてからコールドブートするまで、nvidia-smi は叩かない。 プロジェクトのドキュメントにも注意がありました。
元に戻せるGRUBエントリを残す。 起動に失敗した時の保険になります。
ログや設定ファイルに出たAPIキーは、ローテーションする。 共有した出力に表示してしまったので、差し替えました。
ベースラインの再現
CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=0 \
llama-bench -m .gguf -ngl 99 -fa on -ctk q8_0 -ctv q8_0 \
-b 512 -ub 512 -p 512 -n 128 -r 3 -o md
CUDA_DEVICE_ORDER=PCI_BUS_ID は必須です。これがないと、CUDAの番号と nvidia-smi の番号が入れ替わることがあります。
現状: unlockはインストール済みで、安定して動いています。ただ、Q4の推論速度は変わりません。FP16/BF16の用途(ComfyUIなど)で、改めて検証する予定です。
來源:DEV Community · dev.to