Re-pin numpy<2 after jax install in alphafold2 dockerfile#622
Merged
Conversation
The `pip install --upgrade "jax[cuda12]"==0.5.3` step pulls in numpy 2.x, which breaks AlphaFold multimer at runtime: alphafold/data/msa_pairing.py does `np.sum(x for x in feats)` and numpy>=2 raises `TypeError: Calling np.sum(generator) is deprecated`, so every multimer prediction fails during feature pairing (before inference). The existing numpy<2 pins (conda block + pyproject) run before the jax upgrade and therefore do not stick. Commit fff6305 ("Tests (#600)") removed the trailing `RUN pip install "numpy<2"` (added by 69af382) that previously force-downgraded numpy as the final dependency step. Restore it. jax 0.5.3 runs fine with numpy 1.26.x. Co-Authored-By: Claude Opus 4.8 <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.
Problem
The current
alphafold2container (docker://kosinskilab/alphafold2:2.4.0, freshly built) ships numpy 2.4.4, which breaks every AlphaFold-Multimer prediction at the feature-pairing step, before inference:np.sum(generator)is a hard error in numpy ≥ 2.0. So any pulldown/multimer job dies ~40 s in (pure CPU feature-merge), regardless of GPU.Root cause
docker/alphafold2.dockerfileline ~63-65 runspip install --upgrade "jax[cuda12]"==0.5.3as the last dependency step, and that--upgradepulls in numpy 2.x. Thenumpy<2pins that exist (conda block +pyproject.toml+environment.yml) all run before the jax upgrade, so they don't stick.Commit
fff63051("Tests (#600)") removed the trailingRUN pip install --no-cache-dir "numpy<2"(originally added in69af382a, "Force numpy<2 installation") that previously force-downgraded numpy as the final step. Without it, rebuilds of:2.4.0bake in numpy 2.x. (Docker tags are mutable, so older pulls still worked — which is why this surfaced only on a recent rebuild.)Fix
Restore a trailing
RUN pip install --no-cache-dir "numpy<2"after the jax install, so numpy is re-pinned as the final dependency step.Verified: a working AF2 image and the broken one both have jax 0.5.3; the only difference is numpy (1.26.4 works vs 2.4.4 broken). jax 0.5.3 runs fine with numpy 1.26.x, and full multimer inference (
model_1_multimer_v3, relaxation, ranking) completes with numpy 1.26.4.Note: a clean AF2 image also needs
setuptools<82(already pinned at line 51) — without it, pdbfixer fails withModuleNotFoundError: pkg_resources.