Skip to content

feat(docker): ROCm AMD image, device_utils, CI, and Ruff gate#98

Open
BlackFoxgamingstudio wants to merge 1 commit into
edenaion:mainfrom
BlackFoxgamingstudio:main
Open

feat(docker): ROCm AMD image, device_utils, CI, and Ruff gate#98
BlackFoxgamingstudio wants to merge 1 commit into
edenaion:mainfrom
BlackFoxgamingstudio:main

Conversation

@BlackFoxgamingstudio

Copy link
Copy Markdown

Related to #92.

Summary

Adds optional AMD GPU (ROCm) support via docker/Dockerfile.rocm:

  • rocm-runtime (default build target): uv run python main.py.
  • rocm-vnc: same baked environment plus noVNC / x11vnc / filebrowser / supervisord (parity with the default docker/Dockerfile UX).

ROCm PyTorch + pytorch-triton-rocm are applied only inside the image (uv pip install … --reinstall after uv sync). No rocm optional extra in pyproject.toml.

Also includes device_utils.setup_rocm_env() (HIP detection, HSA_OVERRIDE_GFX_VERSION, stderr logging before setup_logging), main._try_setup_rocm_env(), mocked ROCm tests, Compose profile rocm, .github/workflows/rocm-ci.yml, device_utils in wheel/sdist via hatch force-include, torch-backend = "auto" under [tool.uv.pip], a Ruff workflow (ruff.yml) + [tool.ruff], pinned filebrowser get.sh in both Dockerfiles, .gitignore fix so tests/test_*.py under tests/ are tracked, and docs under docs/ROCm_Setup.md / docs/ROCm_PR_handoff.md.

How to test

uv sync --extra dev
uv run ruff check .
uv run ruff format --check .
uv run pytest tests/test_rocm_setup.py -m rocm -v --tb=short --noconftest

Docker (optional; large pull):

docker build -f docker/Dockerfile.rocm --target rocm-runtime -t ez-corridorkey-rocm .
docker build -f docker/Dockerfile.rocm --target rocm-vnc -t ez-corridorkey-rocm-vnc .

Docs

  • docs/ROCm_Setup.md
  • docs/ROCm_PR_handoff.md

Note: The contributor does not have AMD hardware; ROCm paths are designed for review and validation by someone with a suitable GPU.

…ning

Add optional AMD GPU support via docker/Dockerfile.rocm (rocm-runtime and
rocm-vnc targets), Compose profile rocm, and device_utils.setup_rocm_env()
hooked from main. Include mocked ROCm tests, rocm-ci workflow, and docs.

Add merge-gate Ruff workflow plus [tool.ruff] in pyproject.toml; apply
ruff format and fix lint across the tree. Fix .gitignore so tests/test_*.py
under tests/ are tracked (/test_*.py for root scripts only).

Pin filebrowser get.sh to a fixed commit in both Dockerfiles; tighten
supervisord/entrypoint env for CORRIDORKEY_CONTAINER_MODE; document
security and Compose profiles in docker/README and ROCm docs.

Made-with: Cursor
@stuaxo

stuaxo commented Apr 13, 2026

Copy link
Copy Markdown

Nice work - I'll try and make some time to test it.

It might be worth separating out Ruff (and anything else not directly related to ROCm support if it's there) to another PR - that way those bits can be applied without someone requiring AMD graphics.

With PRs it tends to be best to do one per feature / topic.

@le-patenteux

Copy link
Copy Markdown

Hello, I am in the process of testing this.
Was there a reason why you went with FROM rocm/pytorch:rocm6.1-py3.10-ubuntu22.04 AS rocm-base instead of FROM rocm/pytorch:latest AS rocm-base ??

Is there something in this perticular version that should have been used? if so, this version exactly does not exist in the docker repo anymore.

@le-patenteux

Copy link
Copy Markdown

AMD ROCm Docker — Tested on RX 6700 XT (RDNA2) — Fixes Required

I successfully tested PR #98 (ROCm Docker support) on a RX 6700 XT (RDNA2 / gfx1031) running Debian 13 with Docker. No ROCm or HIP installed on the host — everything is containerized.

Several fixes were required to get full GPU-accelerated inference and proper FFmpeg hardware decoding working. Documenting everything here for other AMD users and to help improve the PR.

System Info
GPU: AMD RX 6700 XT (Navi 22 / gfx1031)
Host OS: Debian 13 (Bookworm)
Docker: Default engine
ROCm (in container): 7.2.4
PyTorch (in container): 2.10.0+rocm7.2.4


Dockerfile.rocm Fixes

Base image tag doesn't exist on Docker Hub, and libgl1-mesa-glx was removed in Ubuntu 24.04:

# Line 9 — fix base image
FROM rocm/pytorch:latest AS rocm-base

# Line 20 — fix package name
    libgl1 \

PyTorch .venv Ignores System ROCm Torch

The .venv installs its own CPU-only PyTorch (2.9.1+cpu), ignoring the ROCm build (2.10.0+rocm7.2.4) in /opt/venv/. App reports Compute device: cpu despite torch.cuda.is_available() returning True at system level.

FFmpeg Too Old — No VAAPI

The base image ships with FFmpeg 6.1.1 but the app requires 7.0+. The apt default for Ubuntu 24.04 doesn't provide a newer version. Installing from ppa:ubuntuhandbook1/ffmpeg7 gives FFmpeg 7.1.1 with VAAPI hardware decoding support for AMD.

Docker Compose Issues

  • group_add: render fails — must use numeric GID (e.g. 992)
  • ipc: host is required or GPU init fails with amdgpu_query_info(ACCEL_WORKING) failed (-13)

Working Setup

All runtime fixes applied via an init script mounted into the container:

init-rocm.sh

#!/bin/bash
set -e

# Fix PyTorch: use ROCm system torch instead of CPU .venv torch
sed -i 's/include-system-site-packages = false/include-system-site-packages = true/' \
    /opt/corridorkey/.venv/pyvenv.cfg 2>/dev/null || true
echo "/opt/venv/lib/python3.12/site-packages" > \
    /opt/corridorkey/.venv/lib/python3.12/site-packages/rocm-torch.pth
uv pip uninstall torch torchvision torchaudio \
    --python /opt/corridorkey/.venv/bin/python 2>/dev/null || true

# Fix FFmpeg: install 7.x with VAAPI from PPA
if ! ffmpeg -version 2>&1 | grep -q "ffmpeg version 7"; then
    echo "Installing FFmpeg 7.x with VAAPI..."
    apt-get update -qq
    apt-get install -y --no-install-recommends software-properties-common
    add-apt-repository -y ppa:ubuntuhandbook1/ffmpeg7
    apt-get update -qq
    apt-get install -y ffmpeg mesa-va-drivers libva2 libva-drm2
    rm -rf /var/lib/apt/lists/*
fi
rm -f /usr/local/bin/ffmpeg /usr/local/bin/ffprobe

# Fix FFmpeg threading
sed -i 's/"-vsync",/"-threads", "0", "-vsync",/g' \
    /opt/corridorkey/backend/ffmpeg_tools/extraction.py 2>/dev/null || true

exec /usr/bin/supervisord -c /etc/supervisor/conf.d/corridorkey-vnc.conf

docker-compose-rocm.yml

services:
  ez-corridorkey:
    image: ez-corridorkey-rocm-vnc
    container_name: ez-corridorkey-rocm
    ipc: host
    entrypoint: ["/bin/bash", "/init-rocm.sh"]

    devices:
      - /dev/kfd
      - /dev/dri
    group_add:
      - video
      - 992  # render GID — check yours with: getent group render

    environment:
      - DISPLAY=:1
      - QT_QPA_PLATFORM=xcb
      - CORRIDORKEY_CONTAINER_MODE=1
      - CORRIDORKEY_RESOLUTION=1920x1080x24
      - HSA_OVERRIDE_GFX_VERSION=10.3.0
      - HIP_VISIBLE_DEVICES=0
      - HF_HUB_DISABLE_PROGRESS_BARS=1

    ports:
      - "6080:6080"
      - "6081:6081"
      - "5900:5900"

    volumes:
      - ./init-rocm.sh:/init-rocm.sh:ro
      - corridorkey_models_corridorkey:/opt/corridorkey/CorridorKeyModule/checkpoints
      - corridorkey_models_gvm:/opt/corridorkey/gvm_core/weights
      - corridorkey_models_videomama:/opt/corridorkey/VideoMaMaInferenceModule/checkpoints
      - corridorkey_hf_cache:/root/.cache/huggingface/hub
      - ./ClipsForInference:/opt/corridorkey/ClipsForInference
      - ./Projects:/opt/corridorkey/Projects
      - ./Output:/opt/corridorkey/Output
      - ./corridorkey_config:/root/.config/corridorkey
      - ./corridorkey_logs:/opt/corridorkey/logs

    security_opt:
      - seccomp=unconfined
    stdin_open: true
    tty: true
    restart: unless-stopped

volumes:
  corridorkey_models_corridorkey:
    name: corridorkey_models_corridorkey
  corridorkey_models_gvm:
    name: corridorkey_models_gvm
  corridorkey_models_videomama:
    name: corridorkey_models_videomama
  corridorkey_hf_cache:
    name: corridorkey_hf_cache

Build & run:

git clone https://github.com/edenaion/EZ-CorridorKey.git
cd EZ-CorridorKey
git fetch origin pull/98/head:test-rocm
git checkout test-rocm
sed -i 's|rocm/pytorch:rocm6.1-py3.10-ubuntu22.04|rocm/pytorch:latest|; s|libgl1-mesa-glx|libgl1|' docker/Dockerfile.rocm
docker build -f docker/Dockerfile.rocm --target rocm-vnc -t ez-corridorkey-rocm-vnc .
cd docker-rocm  # directory containing compose + init script
docker compose -f docker-compose-rocm.yml up -d
GPU Family HSA_OVERRIDE_GFX_VERSION
RX 6000 (RDNA2) 10.3.0
RX 7000 (RDNA3) 11.0.0

@le-patenteux

Copy link
Copy Markdown

Quick update — still need to test the rest of the pipeline past frame extraction, but I'm calling it a night. The EXR frame extraction is taking forever (single-threaded bottleneck in FFmpeg's image sequence writer). I have a lead on improving that with additional threading flags, will test tomorrow morning.

Other than that, nothing suggests there will be any issues downstream. The entire application behaves as if it has access to an NVIDIA GPU — it just happens to be going through ROCm instead. Pretty seamless once all the fixes above are in place.

@edenaion

edenaion commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@le-patenteux Awesome, well done! Please keep me posted as you're the link to the AMD community currently. Appreciate your efforts <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants