跳到主要内容

配置

可设项都挂在 ModelConfig 上,一律 Open() 前设好。取用 model.config(),也能直接在 model 上链式写。

可设项一览​

项类型默认说明
providerstd::string空串点名后端。空 = 自动选;非空 = 不降级,不可用直接报错
gpu_idint32_t0卡号。0 = 第一块卡
timeoutint32_t0单次推理等待预算(毫秒)。0 = 不限
default_thresholdsstd::vector<double>空按类别分数下限。空 = 不卡分
threadsint32_t0推理线程数。0 = 自动
workersint32_t1并发会话数。1 = 单会话,2..32 = 开池(硬顶 32)
queueint32_t0池队列容量。0 = 64,合法 1..4096;满了按失败返回
weightint32_t0同卡槽份额相对数。0 视同 100

连着写​

Darra::AI::Model model("model.darmodel");
model.config().provider("onnx-cuda").gpu_id(0).timeout(5000);