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

#### 产品支持情况

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


#### 功能说明

查询Device之间是否支持内存复制。


#### 函数原型

- C函数原型
  1 aclError aclrtDeviceCanAccessPeer(int32_t *canAccessPeer, int32_t deviceId, int32_t peerDeviceId)

- python函数
  1 can_access_peer, ret = acl.rt.device_can_access_peer(dev_id, peer_dev_id)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| dev\_id | int，指定Device的ID，不能与peer\_dev\_id参数值相同。 用户调用acl.rt.get\_device\_count接口获取可用的Device数量后，这个Device ID的取值范围：[0, (可用的Device数量\-1)]。 |
| peer\_dev\_id | int，指定Device的ID，不能与dev\_id参数值相同。 用户调用acl.rt.get\_device\_count接口获取可用的Device数量后，这个Device ID的取值范围：[0, (可用的Device数量\-1)]。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| can\_access\_peer | int，通过dev\_id参数指定的Device和通过peer\_dev\_id参数指定的Device之间是否支持内存复制，1表示支持，0表示不支持。 |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |


#### 约束说明

- 仅支持物理机和容器场景。
- 仅支持同一个PCIe Switch内Device之间的内存复制。AI Server场景下，虽然是跨PCIe Switch，但也支持Device之间的内存复制。
- 仅支持同一个物理机或容器内的Device之间的内存复制操作。
- 仅支持同一个进程内、线程间的Device之间的内存复制，不支持不同进程间Device之间的内存复制。
- Host的相关端口要已使能（例如Host BIOS等），同一个PCIe Switch内Device之间的拷贝才能端到端可用。
