跳到主要内容

配置

默认就是最优解,GPU 与模型都自动选路。

可设项​

配置项类型默认说明
config.provider(setProvider / getProvider)Stringnull = 自动选Provider ID,如 onnx-cpu / onnx-cuda;只在 open 前设置生效
config.gpuId(setGpuId / getGpuId)int0GPU 序号,从 0 开始;只在 open 前设置生效
config.timeout(setTimeout / getTimeout)int0 = 不限毫秒;运行期随时改,下次推理生效;只覆盖排队段,已开始的深层推理掐不断
config.defaultThresholds(setDefaultThresholds / getDefaultThresholds)Map<String,Double>空表 = 不过滤标签名到 [0,1] 分数下限;运行期随时改;非法键值抛 IllegalArgumentException,传 null 或空表清回全局
config.threads(setThreads / getThreads)int0 = 自动实例不设时取 GlobalThreads;负数抛 IllegalArgumentException;只设 threads 时 intra 取它、inter 取 0
config.workers(InferPoolOptions.maxWorkers)int0/1 = 单会话2 到 32 开并发池;open 前随 InferPoolOptions 定
config.queue(InferPoolOptions.queueCapacity)int0 = 64范围 1 到 4096;open 前定
config.weight(InferPoolOptions.weight)int0 = 100范围 1 到 10000;并发槽份额,不是 CUDA SM%;open 前定
config.overflow(InferPoolOptions.overflow)InferOverflownull = FAILFAIL / BLOCK / DROP_OLDEST;open 前定
config.parallel(SessionOptions.parallel)int0/1 = 单路2 到 32 为会话内并发,超过 32 截成 32;open 前定
config.precision(SessionOptions.precision)PrecisionFP32UNSPECIFIED / FP32 / FP16 / INT8;open 前定,兑现不了直接打开失败

进程级开关​

  • GlobalThreads:全局默认线程数,0 表示引擎默认。实例没单独设置就取它。
  • GlobalLogSink:日志出口 (level, msg),进程级单槽、后注册的生效。level:0=ERROR 1=WARN 2=INFO 3=DEBUG。