caharkness.com

Home · Contact · Git


ROCm 10.0 Software Script

Here's a script for your Debian box that has ROCm-compatible hardware. You'll need to edit the script so that it suits you, but it gets llama.cpp and ComfyUI up and running pretty quickly.

#!/bin/bash

export STARTING_DIR="$(dirname "$0")"

cd "$STARTING_DIR"

# gfx1201 = Radeon 9070 XT and R9700
# gfx1151 = Strix Halo APUs
export AMD_GPU="gfx1201"

function install_rocm()
{
    apt update

    # Add the ROCm 10.0 official repo:
    cat << EOF > /etc/apt/sources.list.d/amdrocm-stable.sources
X-Repo-Id: amdrocm-stable
Types: deb
URIs: https://stable.repo.amd.com/rocm/core/packages/debian13/
Suites: stable
Components: main
Architectures: amd64
Enabled: yes
Signed-By:
$(wget https://stable.repo.amd.com/rocm/gpg/packages.gpg -O - | sed 's/^/ /')
EOF

    # Install the required dependencies for a ROCm/HIP build:
    apt install -y amdrocm-core-sdk10.0-${AMD_GPU}
    apt install -y amdrocm-core-dev10.0-${AMD_GPU}

}

function check_rocm()
{
    if [[ ! -d /opt/rocm/core-10.0 ]]
    then
        echo "/opt/rocm does not exist"
        echo "Was ROCm 10 installed correctly?"
        exit 1
    fi
}

export LD_LIBRARY_PATH=/opt/rocm/core-10.0/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/rocm/core-10.0/lib/llvm/lib:$LD_LIBRARY_PATH

if [[ "$@" =~ "--llamacpp" ]]
then

    if [[ "$@" =~ "--build" ]]
    then
        install_rocm

        # Install the common build dependencies:
        apt install build-essential ca-certificates cmake curl git libcurl4-openssl-dev libdrm-dev libdw-dev libelf-dev libgl-dev libnuma-dev libpciaccess-dev libssl-dev libudev-dev libzstd-dev ninja-build pciutils pkg-config python3 python3-pip python3-venv xxd zlib1g-dev

        # Clone llama.cpp
        git clone https://github.com/ggml-org/llama.cpp.git

        cd llama.cpp

        # Make sure it's up to date:
        git pull

        # Create a "build" configuration for ROCm:
        cmake -B build \
            -DGGML_HIP=ON \
            -DAMD_GPU_TARGETS=${AMD_GPU} \
            -DCMAKE_BUILD_TYPE=Release

        # Actually build the "build" ROCm configuration (using 8 threads):
        cmake --build build --config Release --parallel 8

        cd ..
        exit 0
    fi

    check_rocm

    export GGML_CUDA_DISABLE_GRAPHS=1
    export ROCBLAS_INTERNAL_GEMM_CACHE_SIZE=0

    ./llama.cpp/build/bin/llama-server \
        --n-gpu-layers -1 \
        --host 0.0.0.0 \
        --port 9931 \
        --ctx-size 65536 \
        --alias "qwen3.8-27b" \
        --model "/shared/Apps/llama.cpp/models/Swift-1.5-Qwen3.8-27B-Uncensored-Dynamic-MTP-RCO-IQ3_XXS.gguf" \
        --mmproj "/shared/Apps/llama.cpp/models/mmproj-Swift-1.5-Qwen3.8-27B-Uncensored-Dynamic-MTP-RCO-BF16.gguf" \
        --batch-size 2048 \
        --ubatch-size 1024 \
        --cache-type-k q4_0 \
        --cache-type-v q4_0 \
        --jinja \
        --webui-mcp-proxy \
        --reasoning on \
        --webui-config-file "config.json" \
        --flash-attn on \
        --fit off \
        --load-mode none \
        --spec-type draft-mtp \
        --spec-draft-n-max 2 \
        --spec-draft-p-min 0.1 \
        --spec-draft-device ROCm1 \
        --split-mode layer \
        --tensor-split 1,1

    exit 0
fi

if [[ "$@" =~ "--comfyui" ]]
then

    if [[ "$@" =~ "--install" ]]
    then
        install_rocm

        git clone https://github.com/Comfy-Org/ComfyUI.git

        cd ComfyUI

        git pull

        rm -rf venv
        python3 -m venv venv

        source ./venv/bin/activate

        pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ \
                "torch[device-${AMD_GPU}]==2.13.0+rocm10.0.0" \
                "torchvision[device-${AMD_GPU}]==0.28.0+rocm10.0.0" \
                "torchaudio==2.11.0.2+rocm10.0.0"

        pip install -r requirements.txt

        cd ..        
        exit 0
    fi

    check_rocm

    if [[ ! -d ./ComfyUI/venv ]]
    then
        echo "./ComfyUI/venv was not found"
        echo "Please run this script with --comfyui --install first"
        exit 1
    fi

    cd ComfyUI

    source ./venv/bin/activate

    python -u main.py \
        --listen \
        --port 8188 \
        --gpu-only \
        --disable-smart-memory \
        --disable-mmap \
        --enable-manager \
        --user-directory user

    exit 0
fi

echo "You must run this script with --llamacpp or --comfyui"
exit 1