openvino: [Build]: Cannot access the file because it is being used by another process
OpenVINO Version
2024.4.0-16579-c3152d32c9c-releases/2024/4
Operating System
Windows System
Hardware Architecture
x86 (64 bits)
Target Platform
Host Name: LAPTOP-DE17RPQT OS Name: Microsoft Windows 10 Home OS Version: 10.0.19045 N/A Build 19045 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Workstation OS Build Type: Multiprocessor Free Registered Owner: - Registered Organization: HP Product ID: 00325-97258-54349-AAOEM Original Install Date: 9/26/2024, 9:07:47 AM System Boot Time: 9/28/2024, 7:37:14 PM System Manufacturer: HP System Model: HP Laptop 15s-fq2xxx System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: Intel64 Family 6 Model 140 Stepping 1 GenuineIntel ~2803 Mhz BIOS Version: AMI F.15, 9/15/2021 Windows Directory: C:\WINDOWS System Directory: C:\WINDOWS\system32 Boot Device: \Device\HarddiskVolume1 System Locale: en-us;English (United States) Input Locale: en-us;English (United States) Time Zone: (UTC+01:00) Brussels, Copenhagen, Madrid, Paris Total Physical Memory: 11,931 MB Available Physical Memory: 7,140 MB Virtual Memory: Max Size: 27,612 MB Virtual Memory: Available: 18,264 MB Virtual Memory: In Use: 9,348 MB Page File Location(s): C:\pagefile.sys Domain: WORKGROUP Logon Server: \LAPTOP-DE17RPQT Hotfix(s): 42 Hotfix(s) Installed. [01]: KB5042097 [02]: KB5028951 [03]: KB4534170 [04]: KB4537759 [05]: KB4545706 [06]: KB4562830 [07]: KB4586864 [08]: KB5003791 [09]: KB5011048 [10]: KB5012170 [11]: KB5015684 [12]: KB5008575 [13]: KB5043064 [14]: KB5006753 [15]: KB5007273 [16]: KB5011352 [17]: KB5011651 [18]: KB5014035 [19]: KB5014671 [20]: KB5015895 [21]: KB5016705 [22]: KB5018506 [23]: KB5020372 [24]: KB5022924 [25]: KB5023794 [26]: KB5025315 [27]: KB5026879 [28]: KB5028318 [29]: KB5028380 [30]: KB5029709 [31]: KB5031539 [32]: KB5032392 [33]: KB5032907 [34]: KB5034224 [35]: KB5036447 [36]: KB5037018 [37]: KB5037240 [38]: KB5037995 [39]: KB5039336 [40]: KB5041579 [41]: KB5043935 [42]: KB5005699 Network Card(s): 2 NIC(s) Installed. [01]: Intel® Wi-Fi 6 AX201 160MHz Connection Name: Wi-Fi DHCP Enabled: Yes DHCP Server: 192.168.1.1 IP address(es) [01]: 192.168.1.116 [02]: fe80::d585:3ad8:bb56:d6b4 [02]: Bluetooth Device (Personal Area Network) Connection Name: Bluetooth Network Connection Status: Media disconnected Hyper-V Requirements: VM Monitor Mode Extensions: Yes Virtualization Enabled In Firmware: Yes Second Level Address Translation: Yes Data Execution Prevention Available: Yes
Build issue description
I have intel hardware so I wanted to try running a llm using OpenVINO following this youtube video example: Hugging Face + OpenVINO
I’ve made a few changes to the code so I’ll leave the full file bellow, but all the installed packages (used in the video) should be the latest as of today.
When the model loading completes the weight compression it throws and error: PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:\Users\{user}\AppData\Local\Temp\tmpqs8oj2zf\openvino_model.bin’
Once the code errors out it clears all the temp files, so there is no way for me to check the “openvino_model.bin” file. I’ve tried enabling developer mode, running python on admin mode and changing multiple model loading parameters like: “export, compile, etc…”. I’ve also tried clearing all the saved models using “huggingface-cli delete-cache” and rebooting my PC, but even with no models saved I still get the error.
Any help or guidance is appreciated 😄
Build script or step-by-step to reproduce
from optimum.intel import OVModelForCausalLM
from transformers import AutoTokenizer, pipeline
model_id = "mistralai/Mistral-7B-Instruct-v0.3"
model = OVModelForCausalLM.from_pretrained(model_id, export = True, compile = False)
model.save_pretrained("/ov_model");
tokenizer = AutoTokenizer.from_pretrained(model_id, clean_up_tokenization_spaces = True)
tokenizer.save_pretrained("/ov_model");
pipe = pipeline("text-generation-with-past", model = model, tokenizer = tokenizer)
outputs = pipe('User: Hello, how are you?\nAssitant:')
print(outputs)
This is my exact python file.
Relevant log output
Traceback (most recent call last):
File "D:\Dev\python_intel_llms\app.py", line 6, in <module>
model = OVModelForCausalLM.from_pretrained(model_id, export = True, compile = False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Dev\python_intel_llms\_env\Lib\site-packages\optimum\intel\openvino\modeling_base.py", line 373, in from_pretrained
return super().from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Dev\python_intel_llms\_env\Lib\site-packages\optimum\modeling_base.py", line 424, in from_pretrained
return from_pretrained_method(
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Dev\python_intel_llms\_env\Lib\site-packages\optimum\intel\openvino\modeling_decoder.py", line 285, in _from_transformers
main_export(
File "D:\Dev\python_intel_llms\_env\Lib\site-packages\optimum\exporters\openvino\__main__.py", line 432, in main_export
submodel_path.with_suffix(".bin").unlink()
File "D:\Langs\Python\Lib\pathlib.py", line 1342, in unlink
os.unlink(self)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\{user}\\AppData\\Local\\Temp\\tmpqs8oj2zf\\openvino_model.bin'
Traceback (most recent call last):
File "D:\Langs\Python\Lib\shutil.py", line 633, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\{user}\\AppData\\Local\\Temp\\tmpqs8oj2zf\\openvino_model.bin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Langs\Python\Lib\weakref.py", line 666, in _exitfunc
f()
File "D:\Langs\Python\Lib\weakref.py", line 590, in __call__
return info.func(*info.args, **(info.kwargs or {}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Langs\Python\Lib\tempfile.py", line 935, in _cleanup
cls._rmtree(name, ignore_errors=ignore_errors)
File "D:\Langs\Python\Lib\tempfile.py", line 930, in _rmtree
_shutil.rmtree(name, onexc=onexc)
File "D:\Langs\Python\Lib\shutil.py", line 781, in rmtree
return _rmtree_unsafe(path, onexc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Langs\Python\Lib\shutil.py", line 635, in _rmtree_unsafe
onexc(os.unlink, fullname, err)
File "D:\Langs\Python\Lib\tempfile.py", line 905, in onexc
_os.unlink(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\{user}\\AppData\\Local\\Temp\\tmpqs8oj2zf\\openvino_model.bin'
Issue submission checklist
- I’m reporting an issue. It’s not a question.
- I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 19 (8 by maintainers)
@richard087 @Nicogs43 sorry for long waiting time without update, recently on optimum-intel side were merged changes hat unblocking model export on windows https://github.com/huggingface/optimum-intel/pull/959. Could you please check that your issues are resolved?
you can install optimum-intel from git using this command: