huggingface / huggingface/optimum-intel

Failed to remove Tmp directory on Windows after export openvino model

Open
#826 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
620
Forks
270
Avg merge
3d 10h
Merged PRs (30d)
22

Description

openvino 2024.2.0
openvino-telemetry 2024.1.0
optimum 1.22.0.dev0
optimum-intel 1.18.0.dev0

**Script**
```python
from optimum.intel import OVModelForCausalLM
from transformers import AutoTokenizer

MODEL_ID = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"

model = OVModelForCausalLM.from_pretrained(MODEL_ID, export=True)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
```
**Error log**
```
(optimum-intel-sd-controlnet) PS C:\Users\openvino\chen\demo_optimum-intel-sd-controlnet> python .\test.py
Framework not specified. Using pt to export the model.
The model will be converted with no weights quantization. Quantization of the weights to int8 requires nncf.please install it with `pip install nncf`
Using framework PyTorch: 2.3.1+cpu
Overriding 1 configuration item(s)
- use_cache -> True
C:\Users\openvino\chen\venv\optimum-intel-sd-controlnet\lib\site-packages\optimum\exporters\openvino\model_patcher.py:467: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if sequence_length != 1:
Compiling the model to CPU ...
Traceback (most recent call last):
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 618, 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\\openvino\\AppData\\Local\\Temp\\tmpjab0hfix\\openvino_model.bin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 843, in onerror
_os.unlink(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\openvino\\AppData\\Local\\Temp\\tmpjab0hfix\\openvino_model.bin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\weakref.py", line 667, in _exitfunc
f()
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\weakref.py", line 591, in __call__
return info.func(*info.args, **(info.kwargs or {}))
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 859, in _cleanup
cls._rmtree(name, ignore_errors=ignore_errors)
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 855, in _rmtree
_shutil.rmtree(name, onerror=onerror)
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 750, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 620, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 846, in onerror
cls._rmtree(path, ignore_errors=ignore_errors)
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 855, in _rmtree
_shutil.rmtree(name, onerror=onerror)
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 750, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 601, in _rmtree_unsafe
onerror(os.scandir, path, sys.exc_info())
File "C:\Users\openvino\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 598, in _rmtree_unsafe
with os.scandir(path) as scandir_it:
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\openvino\\AppData\\Local\\Temp\\tmpjab0hfix\\openvino_model.bin'
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.