214 Star 808 Fork 700

Ascend / samples

 / 详情

使用昇腾模型压缩工具时报错[ERROR][RecordScaleOffset][143] Invalid record file path

DONE
Bug-Report
创建于  
2021-11-18 21:14

一、问题现象(附报错日志上下文):
使用昇腾模型压缩工具时报错
[ERROR][RecordScaleOffset][143] Invalid record file path。

二、软件版本:
-- CANN 版本: CANN 5.0.3
--Python 版本: Python 3.7.5
--操作系统版本 :Ubuntu 18.04

三、测试步骤:
下载昇腾模型压缩工具,参考sample对onnx模型进行量化
运行代码时出现record文件路径无效的问题
检查过文件权限,文件夹与record文件皆可读可写。
主函数代码:
def main():

print("[INFO] Do original model test:")
AP_top1, AR_top1 = onnx_forward(ori_model, 10)

config_file = './tmp/config.json'
skip_layers = []
batch_num = 2
amct.create_quant_config(config_file=config_file,
		 model_file=ori_model,
		 skip_layers=skip_layers,
		 batch_num=batch_num,
         activation_offset=True,
         config_defination=None)

scale_offset_record_file = './tmp/record.txt'
modified_model = './tmp/modified_model.onnx'
amct.quantize_model(config_file=config_file,
                    model_file=ori_model,
                    modified_onnx_file=modified_model,
                    record_file=scale_offset_record_file)
onnx_forward(modified_model, batch_num)

quant_model_path = './model/modified_RetinaNet_model_416.onnx'
amct.save_model(modified_onnx_file=modified_model,
                record_file=scale_offset_record_file,
                save_path=quant_model_path)

print('[INFO] Do quantized model test:')
new_AP_top1, new_AR_top1 = onnx_forward(quant_model_path, 10)
print('[INFO] ResNet101 before quantize AP_top1:{:>10} AR_top1:{:>10}'.format(AP_top1, AR_top1))
print('[INFO] ResNet101 after quantize  AP_top1:{:>10} AR_top1:{:>10}'.format(new_AP_top1, new_AR_top1))

评论 (7)

朱颖盼 创建了Bug-Report
许业涛 负责人设置为AnRuiXiang
许业涛 任务状态TODO 修改为Analysing
展开全部操作日志

你好,quantize_model这个接口的record_file这个参数是要求是量化因子记录文件路径及名称两部分,
截图
需要按照下面这种方式去传入参数
截图
截图
可以参考这种处理方式

已将参数修改
PATH = os.path.realpath('./')
OUTPUTS = os.path.join(PATH, 'outputs')
TMP = os.path.join(OUTPUTS, 'tmp')
config_file = './config/config.json'
scale_offset_record_file = os.path.join(TMP, 'record.txt')#'./tmp/record.txt'
modified_model = os.path.join(TMP, 'modified_model.onnx')
quant_model_path = os.path.join(OUTPUTS, 'modified_RetinaNet_model_608.onnx')
但仍然会出现上述问题

record文件只包含scale_w和offset_w两个值,且offset_w全是0

现在的报错是说你的record_file这个参数中的路径是无效的,你可以将TMP打印输出一下,看看是不是合法的路径

是合法的,路径就是我创建的tmp文件夹,我运行例程resnet_101的时候也会报这个错误

请确认onnxruntime 版本与资料中的一致

你好,请问该问题是否已经解决?当前暂时把该issue先关闭,如有需要,可以再打开,或者重新提新的issue,谢谢

许业涛 任务状态Analysing 修改为DONE

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(4)
1
https://gitee.com/ascend/samples.git
git@gitee.com:ascend/samples.git
ascend
samples
samples

搜索帮助

53164aa7 5694891 3bd8fe86 5694891