1 系统环境
硬件环境(Ascend/GPU/CPU): Ascend
MindSpore版本: mindspore=2.2.0
执行模式(PyNative/ Graph): 不限
Python版本: Python=3.9
操作系统平台: Linux
2 报错信息
2.1 问题描述
在将CANN升级到7.0之后,原有的MindSpore 2.2模型无法加载,报“Unsupported model version”
2.2 报错信息
RuntimeError: Model file version is not compatible with current CANN.
3 根因分析
CANN 7.0要求MindSpore ≥ 2.3,且模型需重新导出为新OM格式。
4 解决方案
- 升级
MindSpore
pip install --upgrade mindspore==2.3.1 -f https://www.mindspore.cn/versions
- 重新导出模型(从
.ckpt到.om)
python export_model.py --ckpt_path model.ckpt --output qwen-7b.om
export_model.py内容:
from mindspore import export, load_checkpoint, load_param_into_net
from qwen import QwenForCausalLM
model = QwenForCausalLM(...)
param_dict = load_checkpoint("model.ckpt")
load_param_into_net(model, param_dict)
export(model, input_tensor, file_name="qwen-7b", file_format="OM")