Skip to content

Commit

Permalink
🐛 Bugfix win del file err (#17697)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe your changes. -->

Fix for this issue which raise the error of FileNotAccessd in windows
when the context of TemporaryDirectory finished.
#17627

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
#17627
  • Loading branch information
trajepl authored Sep 26, 2023
1 parent 2be4dc6 commit bcc6205
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion onnxruntime/python/tools/quantization/shape_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def quant_pre_process(
sess_option = onnxruntime.SessionOptions()
sess_option.optimized_model_filepath = opt_model_path
sess_option.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_BASIC
_ = onnxruntime.InferenceSession(input_model_path, sess_option, providers=["CPUExecutionProvider"])
sess = onnxruntime.InferenceSession(input_model_path, sess_option, providers=["CPUExecutionProvider"])
# Close the session to avoid the cleanup error on Windows for temp folders
# https://github.com/microsoft/onnxruntime/issues/17627
del sess
except Exception:
logger.error(
"ONNX Runtime Model Optimization Failed! Consider rerun with option `--skip_optimization'."
Expand Down

0 comments on commit bcc6205

Please sign in to comment.