intel / intel-npu-acceleration-library

Intel® NPU Acceleration Library
Apache License 2.0
434 stars 42 forks source link

Library .dll is not loaded when not built from source #102

Open enricorampazzo opened 1 month ago

enricorampazzo commented 1 month ago

Describe the bug If you install the binary npu library (i.e. you don't try to compile it from source), backends\bindings.py will not try to load it from the virtual environment, defaulting to look for it where it would be if it was built from source

Error message

C:\Users\enric\source\n\venv2\Scripts\python.exe C:\Users\enric\source\n\examples\llama3.py 
Traceback (most recent call last):
  File "C:\Users\enric\source\n\examples\llama3.py", line 9, in <module>
    from intel_npu_acceleration_library import NPUModelForCausalLM, int4
  File "C:\Users\enric\source\n\intel_npu_acceleration_library\__init__.py", line 6, in <module>
    from .compiler import compile
  File "C:\Users\enric\source\n\intel_npu_acceleration_library\compiler.py", line 10, in <module>
    from intel_npu_acceleration_library.quantization import quantize_model
  File "C:\Users\enric\source\n\intel_npu_acceleration_library\quantization.py", line 5, in <module>
    import intel_npu_acceleration_library.backend.compression as compression
  File "C:\Users\enric\source\n\intel_npu_acceleration_library\backend\__init__.py", line 5, in <module>
    from .bindings import lib
  File "C:\Users\enric\source\n\intel_npu_acceleration_library\backend\bindings.py", line 272, in <module>
    lib = initialize_bindings()
          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\enric\source\n\intel_npu_acceleration_library\backend\bindings.py", line 263, in initialize_bindings
    lib = load_library()
          ^^^^^^^^^^^^^^
  File "C:\Users\enric\source\n\intel_npu_acceleration_library\backend\bindings.py", line 43, in load_library
    os.add_dll_directory(os.path.abspath(dll_path))
  File "<frozen os>", line 1154, in add_dll_directory
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\enric\\source\\n\\intel_npu_acceleration_library\\lib\\Release'

To Reproduce Steps to reproduce the behavior:

  1. run the llama3.py example

Expected behavior The example should run successfully

Desktop (please complete the following information):

enricorampazzo commented 1 month ago

I have a patch to fix the issue, but I cannot push a new branch to this repo. I attached the patch file for your consideration Now_if_the_library_was_not_built_from_source_it_will_try_to_load_the__dll_from_the_virtual.patch

alessandropalla commented 1 month ago

thanks I'll investigate