huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
132.79k stars 26.46k forks source link

importing `xgboost` before `transformers.pipeline` breaks pipeline loading for `image-feature-extraction` pipelines #33789

Open dan-jacobson opened 2 days ago

dan-jacobson commented 2 days ago

System Info

Who can help?

@Rocketknight1, @amyeroberts, @qubvel

Information

Tasks

Reproduction

mkdir pipeline_test && cd pipeline_test
uv init
uv add transformers torch pillow xgboost
uv run python

import xgboost
from transformers import pipeline
pipe = pipeline(task="image-feature-extraction")

This fails silently in my terminal. For some reason I can't get a good error. In VSCode I can sometimes get: [1] 88800 segmentation fault python.

Interestingly, it's the order of xgboost/transformers import that matters. This works on my machine:

from transformers import pipeline
import xgboost

pipe = pipeline(task="image-feature-extraction")

A couple other things I noticed:

Expected behavior

I expected my pipeline to load.

LysandreJik commented 4 hours ago

Hey @dan-jacobson, I'm not sure it's transformers, I have reason to believe it's torch :grin:

Can you let me know if doing import xgboost followed by import torch fails?

LysandreJik commented 4 hours ago

Or, another potential thing to look into: uninstall torch and install tensorflow as a backend for pipelines; now do the same: import xgboost and pipeline. Does that still fail?