Is there any limit on the size of tensor of double type that can be created in onnxruntime? #4614
-
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
AFAIK there's no hardcoded limit. If there's sufficient memory, you can create it. |
Beta Was this translation helpful? Give feedback.
-
I tried to run the model on a tensor of size 22*15000 but it gives memory error. Although the tensor gets created successfully. The intraop thread is set to 8. My system has 32 GB RAM. |
Beta Was this translation helpful? Give feedback.
-
If there's a memory error it's probably running out of memory. How much memory is required depends on the model. There will be copies of data at different points if the input buffer to an operator cannot be re-used for the output. Operators may decrease or increase the size of the data (e.g. you could Resize to make the data small or larger). Memory needs to be allocated for model outputs. Memory needs to be allocated for any weights in the model. |
Beta Was this translation helpful? Give feedback.
-
I think I have a similar issue to the following: My approach is for a large size data is to-
But going by the above issue I understand that we need to create a new session to avoid memory leak, but loading a large model, again and again, will lead to performance degradation. Is there any better approach to handle large data in batches and not create a new session regularly. |
Beta Was this translation helpful? Give feedback.
-
If your model supports batches (i.e. the input shapes have a symbolic or unknown dimension value for the batch size) you should not need to create new session every time. I don't believe there's a memory leak. It's more that each session has its own copy of the model and potentially its own memory arenas if those are enabled, so having lots of sessions incurs more duplicated memory usage/overhead. Are the batches of the same size? How many times can you call Run with a single session before it runs out of memory? Are you free-ing the memory returned as the Run output each time? |
Beta Was this translation helpful? Give feedback.
-
I am not freeing the memory. Is there any method to free the memory created in the arena? Do we need to free the memory returned by CreateTensor() method also? |
Beta Was this translation helpful? Give feedback.
-
If you're using the C++ API it should release the memory for the model inputs and outputs automatically when the Ort::Value goes out of scope. You could try disabling the memory pattern planner first.
|
Beta Was this translation helpful? Give feedback.
-
@skottmckay |
Beta Was this translation helpful? Give feedback.
-
Yes. Look at the Ort::SessionOptions class in the C++ API. It has DisableMemPattern and DisableCpuMemArena methods. The CreateTensor API doesn't use the arena. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
AFAIK there's no hardcoded limit. If there's sufficient memory, you can create it.