【mindspore】mindspore查看当前跑在哪个平台上

mindspore查看当前跑在哪个平台上

mindspore支持在cpu、gpu和ascent平台上运行

查询当前平台

通过以下语句查看当前代码运行在哪个平台:

import mindspore as ms
print(ms.get_context(attr_key='device_target'))

返回值:CPU 或 GPU 或 Ascend

配置指定平台

通过以下语句修改运行的平台:

ms.set_context(device_target="GPU")

device_target (str) - 表示待运行的目标设备,支持’Ascend’、’GPU’和’CPU’。
如果未设置此参数,则使用MindSpore包对应的后端设备。

参考文档

具体接口参考文档:mindspore.set_context

你可能感兴趣的:(python,numpy,人工智能,计算机视觉,开发语言)