Skip to content

Fix CLIP inference notebook dependency conflicts on Python 3.12#124

Open
fazhangm wants to merge 1 commit into
masterfrom
fix/clip
Open

Fix CLIP inference notebook dependency conflicts on Python 3.12#124
fazhangm wants to merge 1 commit into
masterfrom
fix/clip

Conversation

@fazhangm
Copy link
Copy Markdown
Contributor

@fazhangm fazhangm commented May 11, 2026

Problem

The hf_pretrained_clip_large_inference_on_inf2.ipynb notebook was failing in CI with two dependency issues:

  1. numpy downgrade breaks neuronx-cc: The notebook pinned numpy==1.26.4, but the test environment runs Python 3.12 where neuronx-cc 2.0.254643.0a0 requires numpy>=2.0.0. Installing numpy 1.26.4 caused the Neuron compiler to become incompatible:

    ERROR: neuronx-cc 2.0.254643.0a0+306c5a11 requires numpy>=2.0.0; python_version >= "3.12", but you have numpy 1.26.4 which is incompatible.
    
  2. Unpinned transformers pulled breaking major version: Without a version pin, pip resolved transformers-5.8.0 (a major version jump from the 4.x the notebook was written for), which has breaking API changes for CLIP model outputs.

Fix

  • Removed numpy==1.26.4 pin — the pre-installed numpy 2.4.4 in the DLC is compatible with all packages including neuronx-cc.
  • Pinned transformers==4.57.6 — ensures a compatible 4.x version is used, avoiding breaking changes in transformers 5.x.
  • Added %env HF_HUB_DISABLE_PROGRESS_BARS=1 — suppresses xet progress bar rendering errors during non-interactive notebook execution in CI.
  • Updated model code to use return_dict=True with output_cpu.logits_per_image[0] — the stable, documented API for accessing CLIP similarity logits (traced Neuron model still returns tuples, accessed via output_neuron[0][0]).

Test plan

  • Run notebook on Inf2 with Neuron 2.x DLC (Python 3.12)
  • Verify pip install completes without dependency conflicts
  • Verify model compilation and inference produce correct top-5 classifications

@fazhangm fazhangm changed the title Removed numpy pin and added transformer pin Fix CLIP inference notebook dependency conflicts on Python 3.12 May 11, 2026
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