onnx 内存占用非常大
app_onnx.py 占用 6g内存 app.py 占用 600m内存 差距这么大么
Yes, the ONNX version can use more memory than the PyTorch version. One thing that can make memory usage worse is changing CPU Threads, because ONNX Runtime sessions are created with a fixed thread count. If the app starts with one thread count but the UI requests another one, the app may create another cached runtime instance.
As a temporary workaround, please start the ONNX app with the same CPU thread count you use in the UI, for example:
python app_onnx.py --cpu-threads 4
and keep CPU Threads = 4 in the web UI.
This should reduce unnecessary extra runtime instances, although the ONNX version may still use more memory than the PyTorch version. We may look into further reducing the ONNX memory usage in the future.