跳到主要内容

配置

打开前配置全在 model.config。

配置项类型默认说明
config.providerstr | NoneNone期望的 Provider,None/空 = 自动选路,指名的打不开会回落。open() 前设。
config.gpu_idint0用哪块 GPU,0 为第一块;CPU / NPU 下忽略。open() 前设。
config.timeoutint0推理超时毫秒数,0 不限,到点调用失败读结果里的错误码。运行期可改,下一次推理生效。
config.default_thresholdsdict[int, float] | Sequence[float] | NoneNone类别下标 → 分数下限,低于阈值的条目滤掉;序列按顺序当类别下标,值须在 [0,1]。运行期可改,单次 infer_* 的 thresholds= 只盖本次。
config.threadsint0算子内线程数,0 = 自动。open() 前设。
config.workersint1并发会话数,1 单会话,2..32 池并发(上限 32)。open() 前设。
config.queueint0池模式排队上限,仅 workers>1 生效,0 = 64,取值 1..4096;队列满时按 InferOverflow 处理。open() 前设。
config.weightint0同卡多实例的分槽相对份额,按 slots*weight/wsum 分槽,0 = 100,取值 1..10000。open() 前设。