huggingface / optimum-intel

🤗 Optimum Intel: Accelerate inference with Intel optimization tools
https://huggingface.co/docs/optimum/main/en/intel/index
Apache License 2.0
409 stars 112 forks source link

Error during import of OVModelForCausalLM on Windows #993

Closed kshpv closed 5 days ago

kshpv commented 2 weeks ago

Running the following code leads ot an error

import datasets
import openvino
from optimum.intel.openvino import OVModelForCausalLM
Traceback (most recent call last):
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\transformers\utils\import_utils.py", line 1603, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\onnx\graph_transformations.py", line 19, in <module>
    import onnx
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\onnx\__init__.py", line 77, in <module>
    from onnx.onnx_cpp2py_export import ONNX_ML
ImportError: DLL load failed while importing onnx_cpp2py_export: A dynamic link library (DLL) initialization routine failed.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\intel\openvino\__init__.py", line 51, in <module>
    from .quantization import OVQuantizer
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\intel\openvino\quantization.py", line 42, in <module>
    from optimum.exporters.onnx.convert import check_dummy_inputs_are_allowed
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\exporters\__init__.py", line 16, in <module>
    from .tasks import TasksManager  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\exporters\tasks.py", line 173, in <module>
    class TasksManager:
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\exporters\tasks.py", line 338, in TasksManager
    "clip-text-model": supported_tasks_mapping(
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\exporters\tasks.py", line 117, in supported_tasks_mapping
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\optimum\exporters\onnx\model_configs.py", line 23, in <module>
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\akashapo\IntelProjects\my_env\Lib\site-packages\transformers\utils\import_utils.py", line 1605, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import optimum.onnx.graph_transformations because of the following error (look up to see its traceback):
DLL load failed while importing onnx_cpp2py_export: A dynamic link library (DLL) initialization routine failed.

While this code works fine

import openvino
import datasets
from optimum.intel.openvino import OVModelForCausalLM

This happens on Windows machine with the following packages:

Package                   Version                    Editable project location
------------------------- -------------------------- ------------------------------------
about-time                4.2.1
aiohappyeyeballs          2.4.3
aiohttp                   3.10.10
aiosignal                 1.3.1
alive-progress            3.2.0
attrs                     24.2.0
autograd                  1.7.0
certifi                   2024.8.30
charset-normalizer        3.4.0
cma                       3.2.2
colorama                  0.4.6
coloredlogs               15.0.1
contourpy                 1.3.0
cycler                    0.12.1
datasets                  3.1.0
Deprecated                1.2.14
dill                      0.3.8
fastcore                  1.7.19
fastdownload              0.0.7
fastprogress              1.0.3
filelock                  3.16.1
flatbuffers               24.3.25
fonttools                 4.54.1
frozenlist                1.5.0
fsspec                    2024.9.0
grapheme                  0.6.0
huggingface-hub           0.26.2
humanfriendly             10.0
idna                      3.10
Jinja2                    3.1.4
joblib                    1.4.2
jsonschema                4.23.0
jsonschema-specifications 2024.10.1
jstyleson                 0.0.2
kiwisolver                1.4.7
markdown-it-py            3.0.0
MarkupSafe                3.0.2
matplotlib                3.9.2
mdurl                     0.1.2
mpmath                    1.3.0
multidict                 6.1.0
multiprocess              0.70.16
natsort                   8.4.0
networkx                  3.3
ninja                     1.11.1.1
nncf                      2.14.0.dev0+b280eb7d6dirty C:\Users\akashapo\IntelProjects\nncf
numpy                     1.26.4
onnx                      1.17.0
openvino                  2024.4.0
openvino-telemetry        2023.2.1
openvino-tokenizers       2024.4.0.0
optimum                   1.23.3
optimum-intel             1.19.0
packaging                 24.1
pandas                    2.2.3
pillow                    11.0.0
pip                       24.3.1
propcache                 0.2.0
protobuf                  5.28.3
psutil                    6.1.0
pyarrow                   18.0.0
pyarrow-hotfix            0.6
pydot                     2.0.0
Pygments                  2.18.0
pymoo                     0.6.1.3
pyparsing                 3.2.0
pyreadline3               3.5.4
python-dateutil           2.9.0.post0
pytz                      2024.2
PyYAML                    6.0.2
referencing               0.35.1
regex                     2024.11.6
requests                  2.32.3
rich                      13.9.3
rpds-py                   0.21.0
safetensors               0.4.5
scikit-learn              1.5.2
scipy                     1.14.1
sentence-transformers     3.2.1
sentencepiece             0.2.0
setuptools                75.3.0
six                       1.16.0
sympy                     1.13.1
tabulate                  0.9.0
threadpoolctl             3.5.0
tiktoken                  0.8.0
tokenizers                0.19.1
torch                     2.5.1
torchvision               0.20.1
tqdm                      4.66.6
transformers              4.44.0
typing_extensions         4.12.2
tzdata                    2024.2
urllib3                   2.2.3
whowhatbench              1.0.0
wrapt                     1.16.0
xxhash                    3.5.0
yarl                      1.17.1
AlexKoff88 commented 5 days ago

this is fixable by downgrading the onnx version to 1.16. The new one will be enabled soon.

kshpv commented 5 days ago

this is fixable by downgrading the onnx version to 1.16. The new one will be enabled soon.

ok! cool