ROCm: HIP error: invalid device function
Cause
The HIP kernel was compiled for a different GPU architecture than the one you're running on. Each AMD GPU has a gfx target (gfx1100 = RX 7900 XTX, gfx1030 = RX 6900 XT, gfx906 = MI50, etc.). PyTorch ROCm wheels and llama.cpp ROCm builds embed kernels for a specific subset of targets; if your GPU's gfx isn't in the list, every kernel launch fails this way.
Solution
1. Identify your gfx target:
rocminfo | grep gfx
# or
rocm-smi --showproductname
2. For PyTorch: override with HSA_OVERRIDE_GFX_VERSION to the closest officially-supported target. Common case: RX 6700/6800 (gfx1031/1032) needs to pretend it's gfx1030:
export HSA_OVERRIDE_GFX_VERSION=10.3.0
python your_script.py
3. For llama.cpp: rebuild with your gfx explicitly:
make GGML_HIPBLAS=1 \
AMDGPU_TARGETS=gfx1100 \
HIPCXX=/opt/rocm/llvm/bin/clang++ -j
4. Use the official AMD PyTorch wheels matching your ROCm version:
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.2
5. RDNA3 (RX 7000) specific: ROCm 6.0+ supports gfx1100 natively — older 5.x toolchains do not. Update if you're on an older release.
Related errors
Did this fix it?
If your case was different, email Contact support with what you saw and we'll update the page. If it worked but took different commands on your platform, we want to know that too.