---
title: 函数：get_device
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclpythondevg_01_0064.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0064.html
indexId: 7a588e786a9ca7f451e3e31835380bd0837052e8572274f0a3123e5ce685147171
---
# 函数：get_device

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |


#### 功能说明

获取当前正在使用的Device的ID。


#### 函数原型

- C函数原型
  1 aclError aclrtGetDevice(int32_t *deviceId)

- python函数
  1 device_id, ret = acl.rt.get_device()


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| device\_id | Device ID的指针。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |


#### 约束说明

如果没有提前指定Device，则调用acl.rt.get_device接口时，返回错误。指定Device的方式包括：在init接口中开启默认Device、调用acl.rt.set_device接口显式指定Device、调用acl.rt.create_context接口隐式指定Device。
