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

Failed to remove Tmp directory on Windows after export openvino model #826

Open
TianmengChen opened this issue Jul 16, 2024 · 2 comments
Open

Comments

@TianmengChen
Copy link

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

Script

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'
@sammysun0711
Copy link
Contributor

sammysun0711 commented Jul 16, 2024

@helena-intel, I see that you try to fix similar issue: #749, which is already available on https://github.com/huggingface/optimum-intel/releases/tag/v1.18.0
But it seems not fix this issue in optimum-intel 1.18.0dev, Could you please kindly check this issue with reproducer above?

@sammysun0711
Copy link
Contributor

sammysun0711 commented Oct 21, 2024

@TianmengChen please verify potential fix after #925 merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants