Repository navigation
GPU Docker image for NVIDIA (CUDA) and AMD (ROCm), plus GPU and config-persistence docs - #444
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The published Docker images ship CPU-only PyTorch, so
docker run --gpus allcan't turn on GPU indexing. This addsdocker/Dockerfile.gpu, which builds the same app with a GPU build of PyTorch, and documents how to set up the host and run it.--build-arg TORCH_INDEX=cu126(orcu128).--build-arg TORCH_INDEX=rocm7.14. PyPI has no ROCm torch. The build installslibatomic1, which the ROCm wheels need andpython:3.11-slimlacks.TORCH_INDEXasked for.make docker-gpu [TORCH_INDEX=…]andmake docker-rocm [ROCM_INDEX=…]. Both honourDOCKER_CONTEXT, so they can build on a remote engine.ROCm (AMD GPU) detectedon ROCm builds. ROCm drives AMD GPUs through thetorch.cudaAPI, 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;cu128stops at 2.11, for example. Adding it with--extra-index-urllets 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-urlfirst, then installs PhotoMapAI.The CPU image's
--extra-index-url whl/cpuhas 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)libcudartand "no kernel image" errors.--device /dev/kfd --device /dev/drirun flags, and therendergroup, which has to be given by number because the container has no group with that name./root/.config/photomapand/root/.local/share/photomap. Album definitions otherwise vanish with--rmor with service scripts that remove the container.Test plan
TORCH_INDEX=cu128(2.11.0+cu128) both run GPU matmuls; the server logsCUDA detected.ROCm (AMD GPU) detected;docker runcommand works as written.pytest tests: 1371 passed.mkdocs build --strict: no new warnings.Not included
🤖 Generated with Claude Code