Skip to main content

RunOptions

The RunOptions class allows you to configure options for individual calls to InferenceSession.run(). Unlike SessionOptions which configure the entire session, RunOptions apply to a single inference execution.

Constructor

Creates a new RunOptions object with default settings.

Properties

int
Logging severity level for this run (0=Verbose, 1=Info, 2=Warning, 3=Error, 4=Fatal). Default is 2.
int
VLOG level for verbose logging during this run. Default is 0.
str
Tag to identify this particular run in profiling and logs. Useful for debugging.
bool
Set to True to terminate all pending run() calls. Default is False.
bool
Only execute the subgraph that computes the requested outputs. Can improve performance when requesting a subset of outputs. Default is False.

Methods

add_run_config_entry()

Add a custom configuration entry for this run.
str
required
Configuration key.
str
required
Configuration value.
Common Configuration Keys:
  • disable_synchronize_execution_providers - Skip EP synchronization
  • enable_cuda_graph - Enable CUDA graphs for this run
  • memory.enable_memory_arena_shrinkage - Allow memory arena to shrink

Example Usage

Basic Usage

Partial Graph Execution

Profiling Individual Runs

Cancellation

CUDA Graph Optimization

Custom Run Configuration

Performance Optimization