---
title: 函数：get_device
description: "| C函数原型 | aclError aclrtGetDevice(int32\\_t \\*deviceId) |"
url: "https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application%20Development%20Guide/aadgp/aclpythondevg_01_0062.html"
---

# 函数：get_device

| C函数原型 | aclError aclrtGetDevice(int32\_t \*deviceId) |
| --- | --- |
| Python函数 | device\_id, ret = acl.rt.get\_device() |
| 函数功能 | 获取当前正在使用的Device的ID，同步接口。 |
| 输入说明 | 无 |
| 返回值说明 | device\_id：int，正在使用的Device设备号。 ret：int，错误码。 返回0表示成功。 返回其它值表示失败。 |
| 约束说明 | 如果没有调用acl.rt.set\_device接口显式指定Device或没有调用acl.rt.create\_context接口隐式指定Device，则调用acl.rt.get\_device接口时，返回错误。 |
