解决了解决了。
2023-02-01 18:05:35.446263: [cnrtWarning] [389674] [Card : NONE] Failed to initialize CNDEV. Host manage interface disabled 2023-02-01 18:05:35.448696: [cnrtError] [389674] [Card : NONE] No MLU can be found !cnmon 看一下?2023-02-01 18:05:35.448719: [cnmlError] No MLU device2023-02-01 18:05:35.448893: [cnmlError] No MLU device展开
量化代码如下:
def quantification(imgfile, mlu220 = False):
with torch.no_grad():
ckpt = torch.load(opt.weight, map_location=torch.device('cpu')) # load checkpoint
state_dict = ckpt['model'] if 'model' in ckpt else ckpt
model = Model(img_sizes = opt.img_size, conf_thres = 0.2, nms_thres = 0.4, maxBoxNum=1024, cfg=opt.cfg, ch=3, mlu_postprocess= opt.mlu_postprocess).to(torch.device('cpu')) # create
model.load_state_dict(state_dict, strict=False) # load
model.eval().float().fuse()
model = model.to(torch.device('cpu'))
model = mlu_quantize.quantize_dynamic_mlu(model, { 'iteration':1000,'mean': mean, 'std': std, 'data_scale':1.0, 'firstconv': mlu220,'perchannel':True, 'use_avg':False }, dtype='int8', gen_quant=True )
calibration(model, "./coco-eval",20)
torch.save(model.state_dict(), save_path)
请登录后评论