Skip to content

GPU Docker image for NVIDIA (CUDA) and AMD (ROCm), plus GPU and config-persistence docs - #444

Merged
lstein merged 3 commits into
masterfrom
lstein/feature/docker-gpu
Nov 30, 2026
Merged

lstein merged 3 commits into
masterfrom
lstein/feature/docker-gpu

Conversation

@lstein

@lstein lstein commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Summary

The published Docker images ship CPU-only PyTorch, so docker run --gpus all can't turn on GPU indexing. This adds docker/Dockerfile.gpu, which builds the same app with a GPU build of PyTorch, and documents how to set up the host and run it.

  • NVIDIA (default): PyPI's own torch. On Linux x86-64 that is already a CUDA build of the newest release (currently 2.15 / CUDA 13.2). It needs driver ≥ 580 and an RTX 20 / GTX 16-series card or newer.
  • Older NVIDIA drivers or cards: --build-arg TORCH_INDEX=cu126 (or cu128).
  • AMD: --build-arg TORCH_INDEX=rocm7.14. PyPI has no ROCm torch. The build installs libatomic1, which the ROCm wheels need and python:3.11-slim lacks.
  • Build check: the build fails if the installed torch has neither CUDA nor HIP support, or isn't the build that TORCH_INDEX asked for.
  • Make targets: make docker-gpu [TORCH_INDEX=…] and make docker-rocm [ROCM_INDEX=…]. Both honour DOCKER_CONTEXT, so they can build on a remote engine.
  • Startup log: says ROCm (AMD GPU) detected on ROCm builds. ROCm drives AMD GPUs through the torch.cuda API, so no indexing code changes.

Why install torch from the index first

Each download.pytorch.org/whl/<tag> index carries only a few torch releases; cu128 stops at 2.11, for example. Adding it with --extra-index-url lets pip pick PyPI's newer torch and ignore the tag without any warning. That happened in the first test build, which asked for cu128 and got cu132. So the Dockerfile installs torch and torchvision from the chosen index with --index-url first, then installs PhotoMapAI.

The CPU image's --extra-index-url whl/cpu has the same weakness. If the CPU index ever lags PyPI, the "CPU" image would ship CUDA torch. It's fine today, since both are at 2.15, and this PR leaves that image alone.

Docs (docs/docker.md)

  • GPU Acceleration, with NVIDIA and AMD parts:
    • NVIDIA: Container Toolkit + CDI setup, a build-option table by driver and card, a recipe that adds GPU support to the published image without the source code, and troubleshooting for the CDI "no known GPU vendor", libcudart and "no kernel image" errors.
    • AMD: supported cards, the --device /dev/kfd --device /dev/dri run flags, and the render group, which has to be given by number because the container has no group with that name.
  • Keeping Your Albums Between Runs: mounting /root/.config/photomap and /root/.local/share/photomap. Album definitions otherwise vanish with --rm or with service scripts that remove the container.

Test plan

  • NVIDIA RTX 5060 Ti: default build (2.15.0+cu132) and TORCH_INDEX=cu128 (2.11.0+cu128) both run GPU matmuls; the server logs CUDA detected.
  • AMD, 2× Radeon Pro W7900 (gfx1100), built through an SSH docker context:
    • both GPUs visible;
    • ViT-B/32 embeddings match the CPU (cosine ≥ 0.9999);
    • 36 images in 0.07 s after a 4.6 s first-batch kernel compile;
    • the server logs ROCm (AMD GPU) detected;
    • the documented docker run command works as written.
  • pytest tests: 1371 passed.
  • mkdocs build --strict: no new warnings.

Not included

  • No Docker Hub publishing for the GPU images. They're about 7 GB (CUDA) and about 30 GB on disk (ROCm).

🤖 Generated with Claude Code

lstein and others added 3 commits November 29, 2026 18:19
…ence

The published images ship CPU-only PyTorch, so `docker run --gpus all`
can't enable CUDA. docker/Dockerfile.gpu builds the same app with a CUDA
PyTorch: PyPI's own torch by default (newest release, CUDA 13.x), or a
specific PyTorch CUDA index via --build-arg TORCH_CUDA=cu126/cu128 for
older drivers and cards. That index is installed from with --index-url
before PhotoMapAI, because each CUDA index carries only a few releases
and as an --extra-index-url pip silently prefers PyPI's newer torch. The
build fails if torch lacks CUDA or isn't the requested variant.

docs/docker.md gains a GPU Acceleration section (NVIDIA Container
Toolkit + CDI setup, build options by driver/card, a no-source recipe on
top of the published image, troubleshooting for the CDI, libcudart and
no-kernel-image errors) and a section on mounting the config and data
directories so album definitions survive container removal. Adds a
`make docker-gpu` target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dockerfile.gpu's build arg becomes TORCH_INDEX and accepts a rocmX.Y
PyTorch index as well as cuXXX; PyPI has no ROCm torch, so AMD always
names one. ROCm wheels link libatomic, which python:3.11-slim lacks, so
it is apt-installed for rocm* builds only. The build check now accepts a
torch with torch.version.hip (ROCm leaves torch.version.cuda as None).
`make docker-rocm` (ROCM_INDEX ?= rocm7.14) builds <user>/photomapai-rocm;
both GPU targets honour DOCKER_CONTEXT for building on a remote engine.

ROCm drives AMD GPUs through the torch.cuda API, so no indexing code
changes; the startup log now says "ROCm (AMD GPU) detected" instead of
"CUDA detected" on such builds.

docs/docker.md splits GPU Acceleration into NVIDIA and AMD parts. The AMD
part covers supported cards, the --device /dev/kfd /dev/dri run flags, and
the render group, which must be passed by number because the container has
no "render" group.

Verified on 2x Radeon Pro W7900 (gfx1100): both GPUs visible, ViT-B/32
embeddings match CPU (cosine >= 0.9999), 36 images in 0.07s after a 4.6s
first-batch kernel compile; server logs the ROCm line. CUDA build re-verified
on an RTX 5060 Ti.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lstein
lstein merged commit 90306ba into master Nov 30, 2026
10 checks passed
@lstein
lstein deleted the lstein/feature/docker-gpu branch November 30, 2026 01:22
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.

1 participant