Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circular dependency issue #1863

Open
jamesrobertwilliams opened this issue May 17, 2024 · 1 comment
Open

circular dependency issue #1863

jamesrobertwilliams opened this issue May 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jamesrobertwilliams
Copy link

jamesrobertwilliams commented May 17, 2024

System Info

I have a fresh virtual env where I am trying to exec an onnx model like so:


# Load Locally Saved ONNX Model and use for inference
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForCustomTasks

sentence = "This is a test sentence."
local_onnx_model = ORTModelForCustomTasks.from_pretrained("./model_onnx")
tokenizer = AutoTokenizer.from_pretrained("./model_onnx")
inputs = tokenizer(
    sentence,
    padding="longest",
    return_tensors="np",
)
outputs = local_onnx_model.forward(**inputs)
print(outputs)

but I keep getting this massively annoying circular dependency error:

  File "/home/foo/miniconda3/envs/aaa/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1512, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import optimum.onnxruntime.modeling_ort because of the following error (look up to see its traceback):
Failed to import optimum.onnx.graph_transformations because of the following error (look up to see its traceback):
Failed to import optimum.exporters.onnx.__main__ because of the following error (look up to see its traceback):
cannot import name 'TasksManager' from partially initialized module 'optimum.exporters' (most likely due to a circular import) (/home/foo/miniconda3/envs/aaa/lib/python3.10/site-packages/optimum/exporters/__init__.py)

It is literally a fresh environment and I train test with no issues.

Lost to as to why this is - also tried different machines, different ve's, also installed from source etc...



### Who can help?

_No response_

### Information

- [X] The official example scripts
- [X] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction (minimal, reproducible, runnable)

Just the code above.

### Expected behavior

It should run!
@jamesrobertwilliams jamesrobertwilliams added the bug Something isn't working label May 17, 2024
@IlyasMoutawwakil
Copy link
Member

I couldn't reproduce the issue, can you please give more details about what version of optimum you're using ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants