# MindSpore模型加载报错RuntimeError: build from file failed! Error is Common error code.

**1. 系统环境**

硬件环境\(Ascend/GPU/CPU\): Ascend

软件环境: MindSpore 版本: 2.2.13

执行模式（静态图/动态图）： 不限

Python 版本: 3.9

操作系统平台: linux

**2. 报错信息**

2.1 问题描述

运行mindspore/mindspore/lite/examples/cloud\_infer/quick\_start\_python/quick\_start\_cloud\_infer\_python.py脚本时，输出结果和文档也一致，但是运行过程会报warning:

2.2 报错信息

```
[WARNING] LITE( 14505, 7f48893eb680,python3):2024-07-31-14:45:46.239.787 [mindspore/lite/tools /optimizer/common/gllo_ut ils.cc:1107] GenTransposeNode] Convert abstract failed for	node: Default/backbone-MobileNetV2Backbone/features- Sequent ialCell/0-ConvBNReLU/features -SequentialCell/1 -BatchNorm2d/TupleGetI tem-op192_post	[WARNING] LITE(14505,7f48893eb680 ,python3):2024-07-31-14:45:46.239.808 [mindspore/lite/tools/optimizer/common/gllo_utils.cc:1107] GenTransposeNode] Convert abstract failed for	node: Default/backbone-MobileNetV2Backbone/features -Sequent ialCell/17-InvertedResidual/conv-Sequent ialcell/2 -Conv2d/Conv2D-op194_pre_0
[WARNING] LITE(14505,7f48893eb680 ,python3):2024-07-31-14:45:46.239.828 [mindspore/l ite/tools/optimizer/common/gllo_utils.cc:1107] GenTransposeNode] Convert abstract failed for	node: Default/backbone-Mob ileNetV2Backbone/features -Sequentialcel l/17-InvertedRes idual/conv-SequentialCell/2-Conv2d/Conv20-op194_post	[WARNING] LITE( 14505,7f48893eb680 ,python3):2024-07-31-14:45:46.239.848 [mindspore/l ite/tools/opt imizer/common/gl lo_utils.cc:1107] GenTransposeNode] Convert abstract failed for	node: Default/backbone-MobileNetV2Backbone/features -Sequent ialCell/17-InvertedRes idual/conv-Sequent ialcell/3-BatchNo rm2d/BatchNorm-op195_pre_0	[WARNING] LITE(14505, 7f48893eb680,python3):2024-07-31-. 14:45:46.239.869 [mindspo re/lite/tools/optimizer/common/gllo_utils.cc:1107] GenTransposeNode] Convert abstract failed for	node: Default/backbone-MobileNetV2Backbone/features- SequentialCell/0-ConvBNReLU/features -SequentialCell/1 -BatchNorm2d/TupleGetI tem-op196_post	[WARNING] LITE( 14505,7f48893eb680,python3):2024-07-31-i4:45:46.239.889 [mindspore/lite/ tools/opt imizer/common/gllo_utils.cc:1107] GenTransposehlode] Convert abstract failed for	node: Default/backbone-MobileNetV2Backbone/features -Sequent ialCell/18-ConvBNReLU/features-Sequentialcell/0-Conv2d/Conv2D-op197_pre_0	[WARNING] LITE(14505,7f48893eb680, python3):2024-07-31-14:45:46.239.909 [mindspore/lite/tools/optimiz er/common/gllo_utils.cc:1107] GenTransposeNode] Convert abstract failed for
node: Default/backbone-Mob ileNetV2Backbone/features-SequentialCell/18 -ConvBNReLU/features -Sequent ialCell/0-Conv2d/Conv2D-op197_post
[WARNING] LITE(14505,7f48893eb680,python3):2024-07-31-14:45:46.239.929 [mindspore/lite/tools /optimizer/common/gllo_ut ils.cc:1107] GenTransposeNode] Convert abstract failed for
node: Default/backbone-Mob ileNetV2Backbone/features -SequentialCell/18 -ConvBNReLU/features -SequertialCell/1-BatchNorm2d/BatchNorm-op198_pre_0
[WARNING] LITE( 14505,7f48893eb680 ,python3):2024-07-31-14:45:46.239.950 [mindspore/lite/ tools/optimizer/common/gllo_utils . cc:1107] GenTransposeNode] Convert abstract failed for	node: Default/backbone-MobileNetV2Backbone/features- SequentialCell/0-ConvBNReLU/features -SequentialCell/1-BatchNorm2d/TupleGetItem-op199_post	
[WARNING] LITE( 14505,7f48893eb680 ,python3):2024-07-31-14:45:46.893.990 [mindspore/l ite/tools/optimizer/common/gllo_utils.cc:1107] GenTransposeNode] Convert abstract failed for
node: Default/backbone-MobileNetV2Backbone/featu res-SequentialCell/0-ConvBNReLU/features -SequentialCell/0-Conv2d/Conv2D-opO_pre_0
[WARNING] ME( 14505,7f48893eb680 ,python3):2024-07-31-14:45:46.927.145 [mindspore/l ite/src/extendrt/numa_adapter . cc:36] NUMAAdapter] Open libnuma.so failed!try libnuma.so.1 aga in
tensor's name is:shape1 data size is:4000 tensor elements num is:1000
output data is: 5.3937547e-05 0.00037763786 0.00034193686 0.00037316754 0.00022436169 9.953917e-05 0.00025308868 0.00032044895 0.00025788433 0.00018915901 0.00079509866 0.00338
2262 0.0016214572 0.0010760546 0.0023826156 0.0011769629 0.00088481285 0.000534926 0.0006929171 0.0010826243 0.0005747609 0.0014443205 0.0010454883 0.0016276307 0.00034437355 0
.0001039985 0.00022641376 0.00035307938 0.00014567627 0.00051178376 0.00016933997 0.00075814105 9.704676e-05 0.00066705025 0.00087511574 0.00034623547 0.00026317223 0.000319407
0.0015627446 0.0004044049 0.0008798965 0.0005202293 0.00044808138 0.0006453716 0.00044969268 0.0003431648 0.0009871059 0.00020436312 7.405098e-05 8.805057e-05
```

当把例子中的设备从cpu改成ascend，在构建模型处报错：

```
[ERROR] ME( 15817,7f6610386680,python3):2024-07-31-16:28: 16.656.831_ [mindspore/l ite/src/extendrt/kernel /ascend/plugin/ascend_kernel_plugin.cc:50] Register] DLSo0pen failed, so p	ath: /usr/local/python3.7.5/lib/python3.7/site-packages/mindspore_lite/l ib/libascend kernel_plugin.so
[ERROR] ME( 15817,7f6610386680,python3):2024-07-31-16:28: 16.656.840 [mindspore/lite/src/extendrt/sess ion/s ingle_op_sess ion.cc:56] AscendInit] Failed to register Ascend plugin
[ERROR] ME( 15817,7f6610386680,Python3):2024-07-31-16:28:16.656.855 [mindspore/lite/src/extendrt/sess ion/s ingle_op_sess ion.cc:84] Init] Init ascend failed.	ERROR] ME( 15817,7f6610386680,python3):2024-07-31- 16:28: 16.656.866 [mindspore/lite/src/extendrt/session/single_op_sess ion.cc:559] Single0psess ionCreator] Init session failed.
(ERROR] ME( 15817,7f6610386680,python3):2024-07-31-16:28:16.656.878 [mindspore/lite/src/extendrt/cxx_api/model/model_impl.cc:375] BuildByBufferImpl] Create sess ion failed.
Traceback (most recent call last):
    File "quick_start_cloudinfer_python.py", line 31, in <module>
        model.build_from_file(MODEL PATH , mslite.ModelType.MINDIR, context
    File "/usr/local/python3.7.5/T ib/python3.7/s ite-packages/mindspore_lite/model.py", line 111, in wrapper
        return func(*args, **kwargs
    File "/usr/local/python3.7.5/1 ib/python3.7/s ite-packages/mindspore_l ite/model.py", line 263, in build_from_file
        f"build_from_file failed! Error is {ret.ToString( )}")
RuntimeError:build from file - failed! Error is Common error code.
```

**3. 根因分析**

从报错信息Register\] DLSo0pen failed, so path: /usr/local/python3.7.5/lib/python3.7/site-packages/mindspore\_lite/lib/libascend kernel\_plugin.so

可以看出是昇腾CANN环境变量未设置

**4. 解决方案**

执行cann安装目录下的set\_env.sh。

