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

#### 产品支持情况

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


#### 功能说明

使能当前Device与指定Device之间的数据交互。使能内存复制是Device级的。

可提前调用acl.rt.device_can_access_peer接口查询当前Device与指定Device之间能否进行数据交互。需调用两次acl.rt.device_enable_peer_access接口使能两个Device之间的数据交互功能（例如，调用一次acl.rt.device_enable_peer_access接口使能Device 0到Device 1的数据交互，再调用一次acl.rt.device_enable_peer_access接口使能Device 1到Device 0的数据交互）。

使能Device间的数据交互功能后，若想关闭该功能，可调用acl.rt.device_disable_peer_access接口。


#### 函数原型

- C函数原型

```
aclError aclrtDeviceEnablePeerAccess(int32_t peerDeviceId, uint32_t flags)
```


- python函数
  1 ret = acl.rt.device_enable_peer_access(peer_dev_id, flag)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| peer\_dev\_id | int，Device ID，该ID不能与当前Device的ID相同。 用户调acl.rt.get\_device\_count接口获取可用的Device数量后，这个Device ID的取值范围：[0, (可用的Device数量\-1)]。 |
| flag | 保留参数，当前必须设置为0。 |


#### 返回值说明

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