microsoft / microsoft/onnxruntime

[Feature Request] Exposing arena memory shrink in C#

Open
#13,936 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the feature request

In python, shrinking memory on each run is supported as following.

ro2 = onnxrt.RunOptions()
ro2.add_run_config_entry("memory.enable_memory_arena_shrinkage", "cpu:0;gpu:0")

I have tested and it works fine. I would like to use this in c# as well.

If the features are not in a job queue yet, any suggestion how I can start exposing this to c# and build myself
before the official release?

### Describe scenario use case

My case is that I have many models that infers at the same time, in order to analyze the whole database.
(OCR, Classifcation, Object Detection.. etc)
Due to gpu memory shortage, I would like the session to shrink the gpu memory on each run.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python RunOptions example and the memory.enable_memory_arena_shrinkage configuration key, then trace how RunOptions is exposed through the C# API. Check the existing C# binding and its tests, if present; done means C# users can configure equivalent CPU and GPU arena shrinking for each run.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, python
Domain
api, machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.