feat(api): add make run-gpu for native CUDA serving#52
Merged
Conversation
The released Docker image stays CPU-only on purpose (torch pinned to the pytorch-cpu wheel index keeps it small). For GPU benchmarking/dev, run-gpu swaps the venv's torch/torchvision for cu130 wheels and serves uvicorn with --no-sync so the CUDA wheels survive startup. Verified end-to-end on an RTX 4070 Ti SUPER: /predict on a real 7-frame sequence returns the same prediction as CPU serving, with the server process on the GPU.
…llback Review follow-ups on the GPU recipe: - Pin the cu130 install to the uv.lock releases (torch==2.12.0, torchvision==0.27.0) so the GPU venv cannot silently drift to a newer torch than the one CI tests; the pin also keeps shared deps (numpy) at their locked versions. - Split the one-time wheel swap (gpu-setup) from serving (run-gpu) so restarts skip the multi-GB venv churn and need no network. - run-gpu now asserts CUDA is available before serving instead of silently falling back to CPU after a plain uv run/uv sync reverted the wheels. - README: document that MODEL_PATH must be set natively (the /models/model.zip default is container-only), that make test/lint/format revert the wheels, and to set TEMPORAL_API_TOKEN on shared networks since run-gpu binds 0.0.0.0.
Remaining review follow-ups: - gpu-setup's help text now points at the README instead of repeating the driver floor, so the requirement lives in one place. - README: note that the compose api service publishes the same port 8000 as run-gpu; start only minio/createbuckets when compose is just providing S3. Kept --reinstall-package (not the shorter --reinstall): tested the swap and --reinstall force-reinstalls the whole resolution, bumping numpy past its locked 1.26.4 — the same drift the version pins exist to prevent.
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
api/Makefilefor serving the API on a CUDA GPU natively (the published Docker image intentionally stays CPU-only — no second image variant):gpu-setup(one-time): re-syncs the venv, then swaps torch/torchvision forcu130wheels pinned to theuv.lockreleases (2.12.0/0.27.0) so the GPU venv can't silently drift from the tested versions.run-gpu: serves withuv run --no-sync, after asserting CUDA is actually available — it refuses to start (instead of silently serving on CPU) when a plainuv run/uv synchas reverted the venv to the locked CPU wheels. Restarts do no reinstall work and need no network.api/README.md: native runs must setTEMPORAL_API_MODEL_PATH(the/models/model.zipdefault is container-only),make test/lint/formatrevert the CUDA wheels, andrun-gpubinds0.0.0.0:8000so setTEMPORAL_API_TOKENon shared networks.Test Plan
make gpu-setup+make run-gpuend-to-end on an RTX 4070 Ti SUPER (driver 580.159.03): server holds GPU memory (1172 MiB),POST /predicton a real 7-frame MinIO-backed sequence returnsis_smoke=true, probability=0.87009— identical to CPU serving.gpu-setupinstalls exactlytorch==2.12.0+cu130/torchvision==0.27.0+cu130, with numpy staying at the locked 1.26.4 (the unpinned form had bumped it to 2.4.4).make run-gpuon a CPU venv exits 2 withCUDA torch not available - run: make gpu-setup.run-gpugoes straight to uvicorn — no sync/reinstall churn.pytest(122 passed, 1 skipped) andruff checkclean.