• mindspore.ops.Pow()等算子不能处理float64类型的数据


    原文地址:

    https://gitee.com/mindspore/mindspore/issues/I3ZG99

    Software Environment:
    -- MindSpore r1.2 GPU ( pip install this package)
    -- Python 3.7.5
    -- Linux Ubuntu 18.04

    显卡1660ti  nvidia

    Intel i7 cpu

    代码:

    import mindspore
    from mindspore import Tensor
    import mindspore.ops as ops
    import numpy as np
    from mindspore import context
    
    #context.set_context(mode=context.PYNATIVE_MODE, device_target='GPU')
    context.set_context(mode=context.GRAPH_MODE, device_target='GPU')
    
    input_x = Tensor(np.array([[1.0], [2.0], [4.0]]), mindspore.float32)
    input_y = 3
    _pow = ops.Pow()
    _mean = ops.ReduceMean()
    #out = _pow(input_x, input_y)
    out = _mean(input_x)
    
    
    print(out)
    print(out.dtype)

    运行结果:

    如果把数据的类型该为float64, 则报错:

    input_x = Tensor(np.array([[1.0], [2.0], [4.0]]), mindspore.float64)

    代码:

    import mindspore
    from mindspore import Tensor
    import mindspore.ops as ops
    import numpy as np
    from mindspore import context
    
    #context.set_context(mode=context.PYNATIVE_MODE, device_target='GPU')
    context.set_context(mode=context.GRAPH_MODE, device_target='GPU')
    
    input_x = Tensor(np.array([[1.0], [2.0], [4.0]]), mindspore.float64)
    input_y = 3
    _pow = ops.Pow()
    _mean = ops.ReduceMean()
    #out = _pow(input_x, input_y)
    out = _mean(input_x)
    
    
    print(out)
    print(out.dtype)
    View Code

    系统提示:

    [ERROR] DEVICE(11003,python):2021-07-07-13:08:40.312.582 [mindspore/ccsrc/runtime/device/gpu/kernel_info_setter.cc:118] SelectAkgKernel] Not find op[ReduceMean] in akg
    [ERROR] DEVICE(11003,python):2021-07-07-13:08:40.312.602 [mindspore/ccsrc/runtime/device/gpu/kernel_info_setter.cc:347] PrintUnsupportedTypeException] Select GPU kernel op[ReduceMean] fail! Incompatible data type!
    The supported data types are in[float32], out[float32]; in[float16], out[float16]; , but get in [float64 ] out [float64 ]
    Traceback (most recent call last):
      File "/home/devil/mindSpore_Projects/3.py", line 15, in <module>
        out = _mean(input_x)
      File "/home/devil/anaconda3/envs/mindspore/lib/python3.7/site-packages/mindspore/ops/operations/math_ops.py", line 331, in __call__
        output = _run_op(self, self.name, args)
      File "/home/devil/anaconda3/envs/mindspore/lib/python3.7/site-packages/mindspore/common/api.py", line 75, in wrapper
        results = fn(*arg, **kwargs)
      File "/home/devil/anaconda3/envs/mindspore/lib/python3.7/site-packages/mindspore/ops/primitive.py", line 559, in _run_op
        output = real_run_op(obj, op_name, args)
    TypeError: mindspore/ccsrc/runtime/device/gpu/kernel_info_setter.cc:347 PrintUnsupportedTypeException] Select GPU kernel op[ReduceMean] fail! Incompatible data type!
    The supported data types are in[float32], out[float32]; in[float16], out[float16]; , but get in [float64 ] out [float64 ]

    本博客是博主个人学习时的一些记录,不保证是为原创,个别文章加入了转载的源地址还有个别文章是汇总网上多份资料所成,在这之中也必有疏漏未加标注者,如有侵权请与博主联系。
  • 相关阅读:
    LeetCode 110: Balanced Binary Tree
    LeetCode 101: Symmetric Tree
    LeetCode 100: Same Tree
    Cannot resolve plugin org.apache.maven.plugins:maven-site-plugin:3.3
    idea 创建springboot项目失败
    spring5中log4j2.xml文件的配置信息
    CPU占用过高定位分析
    GC基础参数 -XX:+PrintGCDetails
    idea springboot项目报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured
    git克隆指定分支到指定文件夹(仓库不存在,自动创建)
  • 原文地址:https://www.cnblogs.com/devilmaycry812839668/p/14981082.html
Copyright © 2020-2023  润新知