配置
默认就是最优解,GPU 与模型都自动选路。
可设项
| 配置项 | 类型 | 默认 | 说明 |
|---|---|---|---|
config.provider(setProvider / getProvider) | String | null = 自动选 | Provider ID,如 onnx-cpu / onnx-cuda;只在 open 前设置生效 |
config.gpuId(setGpuId / getGpuId) | int | 0 | GPU 序号,从 0 开始;只在 open 前设置生效 |
config.timeout(setTimeout / getTimeout) | int | 0 = 不限 | 毫秒;运行期随时改,下次推理生效;只覆盖排队段,已开始的深层推理掐不断 |
config.defaultThresholds(setDefaultThresholds / getDefaultThresholds) | Map<String,Double> | 空表 = 不过滤 | 标签名到 [0,1] 分数下限;运行期随时改;非法键值抛 IllegalArgumentException,传 null 或空表清回全局 |
config.threads(setThreads / getThreads) | int | 0 = 自动 | 实例不设时取 GlobalThreads;负数抛 IllegalArgumentException;只设 threads 时 intra 取它、inter 取 0 |
config.workers(InferPoolOptions.maxWorkers) | int | 0/1 = 单会话 | 2 到 32 开并发池;open 前随 InferPoolOptions 定 |
config.queue(InferPoolOptions.queueCapacity) | int | 0 = 64 | 范围 1 到 4096;open 前定 |
config.weight(InferPoolOptions.weight) | int | 0 = 100 | 范围 1 到 10000;并发槽份额,不是 CUDA SM%;open 前定 |
config.overflow(InferPoolOptions.overflow) | InferOverflow | null = FAIL | FAIL / BLOCK / DROP_OLDEST;open 前定 |
config.parallel(SessionOptions.parallel) | int | 0/1 = 单路 | 2 到 32 为会话内并发,超过 32 截成 32;open 前定 |
config.precision(SessionOptions.precision) | Precision | FP32 | UNSPECIFIED / FP32 / FP16 / INT8;open 前定,兑现不了直接打开失败 |
进程级开关
GlobalThreads:全局默认线程数,0 表示引擎默认。实例没单独设置就取它。GlobalLogSink:日志出口(level, msg),进程级单槽、后注册的生效。level:0=ERROR 1=WARN 2=INFO 3=DEBUG。