Open mifikri opened 3 years ago
Could you say more about onnxruntime+torch? Do you load both onnxruntime and torch? And what is your build option?
i just create session using onnxruntime, there is no invoke torch library.
the point is: if the build option linking to onnxruntime, the gpu memory allocate 207 MiB.
and if both onnxruntime and torch are linking, the gpu memory allocate 825MiB.
As you built from source, I want to know if you built with training enabled by asking for the build option. Our training has dependency on torch in certain cases.
I was using the build script from https://github.com/microsoft/onnxruntime/blob/v1.8.2/dockerfiles/Dockerfile.tensorrt#L21 .
...
'-Donnxruntime_ENABLE_TRAINING=OFF',
'-Donnxruntime_ENABLE_TRAINING_OPS=OFF'
Does it introduce effect for create session?
FYI, i just test onnxruntime v1.4.0 with torch 1.6. has same effect. The build command same too https://github.com/microsoft/onnxruntime/blob/v1.4.0/dockerfiles/Dockerfile.tensorrt#L21
model | linking ort 1.4.0 | linking ort 1.4.0 and torch 1.6.0 |
---|---|---|
yolov4 | 311 MiB | 611 MiB |
the pattern is likely same as ort 1.8.2 version.
linking ort 1.4.0
linking ort 1.4.0 + torch 1.6.0
looks like similar problem occur in python, as described in #8823
I will do some digging into this
I couldn't repro this on Windows (K620) or Ubuntu 20 (V100). Any chance you could try with ORT 1.10 and check if the issue persists ?
Hi @hariharans29, I could replicate this in python by importing or not importing torch in the same script:
import onnxruntime as ort
sess = ort.InferenceSession("resnet18-v2-7.onnx", providers=['CUDAExecutionProvider'])
assert 'CUDAExecutionProvider' in sess.get_providers()
while True:
pass
gets 345MB of memory:
while when adding import torch:
import onnxruntime as ort
import torch
sess = ort.InferenceSession("resnet18-v2-7.onnx", providers=['CUDAExecutionProvider'])
assert 'CUDAExecutionProvider' in sess.get_providers()
while True:
pass
I get 1031MB:
I'm using:
I got around the same memory usage when using onnxruntime 1.10. I'm using resnet model from onnx repo https://github.com/onnx/models/blob/master/vision/classification/resnet/model/resnet18-v2-7.onnx
This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.
Describe the bugs:
Create session has different gpu memory (EP: CUDA)
System information:
Discussed in https://github.com/microsoft/onnxruntime/discussions/9137