Skip to main content
XsiSec.com
HomeReposBlogProjectsPortfolio
© 2026 XsiSec.com
Security rules |security.txt
Updated 2026-08-15 · v1.0.0+2026-08-14.82f92cb · 82f92cb
← Back to overview
Security article

Running ComfyUI on AMD GPUs with ROCm (Pop!_OS / Ubuntu)

Documented a clean, ROCm-only setup for running ComfyUI on AMD GPUs. Covers installing ROCm, locking PyTorch to ROCm builds, blocking CUDA entirely, and keeping the environment stable, reproducible, and easy to reset on Linux systems

2026-02-077 tags
Tags

I originally wrote this as a “do it once, then never let CUDA creep back in” setup for running ComfyUI on AMD GPUs using ROCm.
The key idea is:

  • Install ROCm cleanly
  • Verify GPU detection
  • Build a dedicated Python venv for ComfyUI
  • Force ROCm PyTorch wheels
  • Block CUDA/NVIDIA wheels from being reinstalled (especially via ComfyUI-Manager)
  • Add a few quality-of-life shell helpers (aliases/functions)

🧠 What You Get

  • ROCm installed + verified
  • ComfyUI running with ROCm (HIP)
  • A one-command reset script for ComfyUI + ROCm 7.2 torch wheels
  • Shell helpers:
    • comfy (launch ComfyUI with ROCm tuning)
    • torchcheck (sanity check torch + HIP)
    • detect_rocm (quick ROCm version check)
    • hfd (Hugging Face downloader helper)

1) Add AMD ROCm Repository + Pin Priority

bash
wget https://repo.radeon.com/rocm/rocm.gpg.key -qO - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null

echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/latest $(lsb_release -cs 2>/dev/null) main" | sudo tee --append /etc/apt/sources.list.d/rocm.list

echo -e 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600

2) Install ROCm

bash
sudo apt update
sudo apt install rocm

3) Add User to render Group

bash
sudo usermod -a -G render $USER

⚠️ Reboot or log out/in so group membership applies.


4) Verify ROCm Installation

bash
rocminfo

Expected output includes:

  • ROCk module is loaded
  • A GPU agent such as gfx1035

5) Shell Aliases (Add to ~/.bashrc or ~/.zshrc)

These are the helpers I actually use day-to-day.

bash
comfy(){
  ai && \
  HSA_OVERRIDE_GFX_VERSION=11.0.0 \
  HSA_ENABLE_SDMA=0 \
  PYTORCH_HIP_ALLOC_CONF="garbage_collection_threshold:0.8,max_split_size_mb:512" \
  python /home/$USER/Documents/ComfyUI/main.py \
  --disable-pinned-memory
}

torchcheck() {
  source ~/.virtualenvs/ai/bin/activate
  python - <<'PY'
import torch
print("torch:", torch.__version__)
print("cuda available:", torch.cuda.is_available())
print("hip:", getattr(torch.version, "hip", None))
if torch.cuda.is_available():
    print("device:", torch.cuda.get_device_name(0))
PY
}

detect_rocm() {
  if [[ -f /opt/rocm/.info/version ]]; then
    cat /opt/rocm/.info/version
  else
    rocminfo | head
  fi
}

6) Full ComfyUI + ROCm 7.2 Reset Script (One Command)

⚠️ WARNING: This deletes existing ComfyUI and the ai virtualenv.

bash
resetcomfy_rocm72() (
  LOGFILE="$HOME/resetcomfy_rocm72.log"

  {
    echo "================================================="
    echo " resetcomfy_rocm72 started at $(date)"
    echo " Log file: $LOGFILE"
    echo "================================================="

    set -x

    echo "⚠️  This will DELETE ComfyUI and the ai virtualenv. Ctrl+C to cancel."
    sleep 3

    # --- Cleanup ---
    rm -rf /home/$USER/Documents/ComfyUI
    rm -rf /home/$USER/.virtualenvs/ai
    rm -rf /home/$USER/config/comfy

    # --- Virtualenv ---
    python3 -m venv ~/.virtualenvs/ai
    source ~/.virtualenvs/ai/bin/activate

    pip install -U pip wheel

    # --- Clone ComfyUI ---
    cd /home/$USER/Documents
    git clone https://github.com/comfyanonymous/ComfyUI.git
    cd ComfyUI

    # --- Install ComfyUI requirements WITHOUT deps (never pull CUDA torch) ---
    pip install --no-deps -r requirements.txt

    # =========================================================
    # FORCE ROCm TORCH 7.2 (KNOWN GOOD)
    # =========================================================

    # Remove CUDA / NVIDIA torch stack
    pip uninstall -y torch torchvision torchaudio triton cuda-pathfinder >/dev/null 2>&1 || true

    # Remove any installed nvidia-*-cu12 wheels safely
    NVID_PKGS="$(pip freeze | sed -n 's/^\(nvidia-.*-cu12\)==.*/\1/p')"
    if [[ -n "$NVID_PKGS" ]]; then
      echo "$NVID_PKGS" | xargs -r pip uninstall -y
    fi

    # Install ROCm 7.2 wheels (Python 3.12)
    cd /tmp
    rm -rf rocm72_torch && mkdir rocm72_torch && cd rocm72_torch

    curl -L -O "https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp312-cp312-linux_x86_64.whl"
    curl -L -O "https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp312-cp312-linux_x86_64.whl"
    curl -L -O "https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchaudio-2.9.0%2Brocm7.2.0.gite3c6ee2b-cp312-cp312-linux_x86_64.whl"

    pip install --no-deps ./torch-*.whl ./torchvision-*.whl ./torchaudio-*.whl

    # --- Torch sanity check ---
    python - <<'PY'
import torch
print("torch:", torch.__version__)
print("hip:", getattr(torch.version, "hip", None))
PY

    # =========================================================
    # COMFYUI-MANAGER PROTECTION (STOP CUDA REINSTALL)
    # =========================================================

    mkdir -p /home/$USER/Documents/ComfyUI/user/__manager

    cat > /home/$USER/Documents/ComfyUI/user/__manager/pip_blacklist.list <<'EOF'
torch
torchvision
torchaudio
triton
cuda-pathfinder
nvidia-cublas-cu12
nvidia-cuda-cupti-cu12
nvidia-cuda-nvrtc-cu12
nvidia-cuda-runtime-cu12
nvidia-cudnn-cu12
nvidia-cufft-cu12
nvidia-cufile-cu12
nvidia-curand-cu12
nvidia-cusolver-cu12
nvidia-cusparse-cu12
nvidia-cusparselt-cu12
nvidia-nccl-cu12
nvidia-nvjitlink-cu12
nvidia-nvshmem-cu12
nvidia-nvtx-cu12
EOF

    # --- Install ComfyUI Manager ---
    cd /home/$USER/Documents/ComfyUI/custom_nodes
    git clone https://github.com/ltdrdata/ComfyUI-Manager comfyui-manager
    cd comfyui-manager
    pip install --no-deps -r requirements.txt

    # =========================================================
    # PURE-PYTHON DEPS (NO CUDA, NO TORCH)
    # =========================================================

    pip install -U \
      filelock sympy networkx jinja2 fsspec setuptools typing-extensions \
      aiohttp yarl multidict frozenlist aiosignal attrs \
      alembic SQLAlchemy greenlet Mako \
      pydantic pydantic-settings annotated-types pydantic-core typing-inspection \
      certifi charset-normalizer urllib3 \
      httpx httpcore regex trampoline \
      kornia_rs \
      comfyui-workflow-templates \
      comfyui-frontend-package

    echo "================================================="
    echo " ✅ SUCCESS at $(date)"
    echo "================================================="
  } 2>&1 | tee -a "$LOGFILE"
)

7) Hugging Face Downloader Helper (hfd)

This helper assumes you already have the huggingface-cli / hf binary available in a venv.

bash
hfd() {
    if [ -z "$1" ]; then
        echo "Usage: hfd <repo_id> [optional_include_pattern]"
        return 1
    fi

    local VENV_PATH="/home/$USER/.virtualenvs/home/bin/hf"

    if [ -z "$2" ]; then
        # If no second argument, download the whole repo
        $VENV_PATH download "$1" --local-dir "./$(basename $1)"
    else
        # If second argument provided, download specific file/pattern
        $VENV_PATH download "$1" --include "$2" --local-dir "./$(basename $1)"
    fi
}

✅ Done

At this point you have:

  • ROCm installed and verified
  • ComfyUI isolated in a venv
  • ROCm torch wheels pinned
  • CUDA/NVIDIA blocked from reinstalling
  • Helpful shell commands for launching and debugging
Navigate

In this post

  1. 01🧠 What You Get
  2. 021) Add AMD ROCm Repository + Pin Priority
  3. 032) Install ROCm
  4. 043) Add User to render Group
  5. 054) Verify ROCm Installation
  6. 065) Shell Aliases (Add to /.bashrc or /.zshrc)
  7. 076) Full ComfyUI + ROCm 7.2 Reset Script (One Command)
  8. 087) Hugging Face Downloader Helper (hfd)
  9. 09✅ Done
Search
Explore

Popular tags

Browse all 30 tags

Comments

0 comments

No comments yet — be the first to comment.