Mindspore使用报错——原因与解决

1.报错信息如下:

RuntimeError: BUG: Failed to find context for: SequentialCell.3, parent: Default_wrapper.1 from contexts: [{FuncGraph: hasattr.4 Args:

 出错代码如下:

解决方案:

将hasattr删除!!该代码是从pytorch迁移过来的,难免出一些奇奇怪怪的问题。

不应该在construct()中使用hasattr(),换成其它形式判断,比如:

if self.small_conv==True:...... 


2.报错信息如下:

AttributeError: The 'ReparamLargeKernelConv' object has no attribute 'compile_cache'.

TypeError: __init__() takes from 7 to 8 positional arguments but 9 were given

 解决方案:

只看TypeError就行,参数给多了


3.报错信息如下:

RuntimeError: The 'getitem' operation does not support the type [Int64, Tuple[Slice[None : None : None],None]].
The supported types of overload function `getitem` is:

 解决方案:

网络的输入类型出错了,比如网络要(1,)维度的[20],而给了int类型的20。

如果是维度不匹配的话,报错信息中会指出。这里不属于维度问题。

代码如下:

4、报错信息如下

PRE_ACT(195,ffff8c04da40,python):2023-05-26-19:21:00.307.467 [mindspore/ccsrc/plugin/device/ascend/optimizer/format_type/check_consistency.cc:68] CheckFormatForConsistency]

Found inconsistent format! input format 1: DefaultFormat, selected input format: NC1HWC0

File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/common/api.py", line 555, in staging_specialize out = _MindsporeFunctionExecutor(func, hash_obj, input_signature, process_obj, jit_config)(*args)

File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/common/api.py", line 97, in wrapper results = fn(*arg, **kwargs)

File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/common/api.py", line 295, in __call__ phase = self.compile(args_list, self.fn.__name__)

File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/common/api.py", line 357, in compile is_compile = self._graph_executor.compile(self.fn, compile_args, phase, True)

RuntimeError: Found inconsistent format or data type! Op: Concat[@kernel_graph_16:[CNode]1899{[0]: ValueNode<Primitive> Concat, [1]: [CNode]1899, [2]: [CNode]1899}], fullname: Default/online_model-GaussianDiffusion/model-Unet/Concat-op51609

解决方案

检查一下create_dataset()相关的代码,应该是对数据进行预处理trans时出了错误

5.报错信息如下

AttributeError: The 'Conv2d' object does not inherit attribute from 'cell'. Please use 'super().__init__()

解决方案

Conv2d的group参数,写成了groups

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值