mindspore.hal.device_count ============================ .. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/br_base/resource/_static/logo_source.svg :target: https://gitee.com/mindspore/mindspore/blob/br_base/docs/api/api_python/hal/mindspore.hal.device_count.rst :alt: 查看源文件 .. py:function:: mindspore.hal.device_count(device_target=None) 查询目标设备的数量,此接口将在后续版本中废弃,请使用接口 :func:`mindspore.device_context.cpu.device_count` 、 :func:`mindspore.device_context.gpu.device_count` 、 :func:`mindspore.device_context.ascend.device_count` 代替。 .. note:: - 对于 ``"CPU"`` 设备,固定返回1。 参数: - **device_target** (str,可选) - 目标设备,可选值为 ``"CPU"`` , ``"GPU"`` 以及 ``"Ascend"`` 。默认 ``None``,表示当前已经设置的设备。 返回: int