Skip to content

fix(docker): install python3.12-dev so Triton can JIT in the container (#453) - #456

Open
Anai-Guo wants to merge 1 commit into
theroyallab:mainfrom
Anai-Guo:fix-docker-python-headers
Open

fix(docker): install python3.12-dev so Triton can JIT in the container (#453)#456
Anai-Guo wants to merge 1 commit into
theroyallab:mainfrom
Anai-Guo:fix-docker-python-headers

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

Is your pull request related to a problem? Please describe.

Fixes #453. Starting the container logs a burst of build failures before the server comes up:

/tmp/tmpe68t6sye/cuda_utils.c:6:10: fatal error: Python.h: No such file or directory
    6 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
/opt/venv/lib/python3.12/site-packages/fla/utils/_device.py:100: UserWarning: Triton is not supported on current platform, roll back to CPU.

triton is a declared dependency of both the cu12 and cu13 groups
(pyproject.toml L74-76 / L101-102), so it is always in the image. Triton compiles its
cuda_utils extension at runtime, which needs the CPython development headers.

Both Dockerfiles install python3.12, python3-pip and python3.12-venv, but not
python3.12-dev — so Python.h is not in the image. build-essential is already there,
so the headers are the only missing piece.

Putting them in the venv would not help: sysconfig reports the interpreter's include
path from the base prefix even inside a venv, which is where Triton looks —

$ /opt/venv/bin/python -c "import sysconfig; print(sysconfig.get_paths()['include'])"
/usr/include/python3.12

and on Ubuntu 24.04 that path is owned by python3.12-dev (via libpython3.12-dev):

$ dpkg -S /usr/include/python3.12/Python.h
libpython3.12-dev:amd64: /usr/include/python3.12/Python.h

Why should this feature be added?

The failure is not only log noise. The compile error is what flash-linear-attention's
Triton probe hits, and it responds by rolling back to CPU — so an image that ships Triton
on purpose silently runs without it.

Both docker/Dockerfile and docker/Dockerfile.cu13 have the identical apt-get block
and the identical gap, so both are fixed here.

Examples

Before:

$ docker compose -f docker/docker-compose.yml up
tabbyapi-1  | /tmp/tmpe68t6sye/cuda_utils.c:6:10: fatal error: Python.h: No such file or directory
tabbyapi-1  | compilation terminated.
tabbyapi-1  | .../fla/utils/_device.py:100: UserWarning: Triton is not supported on current platform, roll back to CPU.

After: Python.h resolves, the JIT build succeeds, and the rollback warning is gone.

Additional context

One package added per Dockerfile; no change to the venv, the install steps, or the
entrypoint. The added layer is a few MB. The existing Docker smoke test workflow builds
both files on any docker/** change, so this PR exercises both images.

I do not have a CUDA host to run the image on, so I verified the mechanism rather than the
container: the sysconfig include path and the dpkg -S ownership above were both checked
on Ubuntu 24.04 with CPython 3.12. Worth a maintainer running the image once to confirm the
warning is gone end to end.

🤖 Generated with Claude Code

theroyallab#453)

The image installs triton (a cu12/cu13 dependency), which compiles its
cuda_utils extension at runtime and therefore needs Python.h. Only
python3.12/-venv/-pip were installed, so every JIT attempt failed with
'fatal error: Python.h: No such file or directory' and
flash-linear-attention rolled back to CPU.
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.

[BUG] Docker container reports missing Python.h upon startup

1 participant