未验证 提交 e28d5b89 编写于 作者: W wanghuancoder 提交者: GitHub

fix cuda_virtual_mem_allocator a bug, test=develop (#37390)

上级 79ee6d63
...@@ -49,22 +49,25 @@ CUDAVirtualMemAllocator::CUDAVirtualMemAllocator( ...@@ -49,22 +49,25 @@ CUDAVirtualMemAllocator::CUDAVirtualMemAllocator(
// Prepare the access descriptor array indicating where and how the backings // Prepare the access descriptor array indicating where and how the backings
// should be visible. // should be visible.
access_desc_.resize(platform::GetCUDADeviceCount());
for (int dev_id = 0; dev_id < platform::GetCUDADeviceCount(); ++dev_id) { for (int dev_id = 0; dev_id < platform::GetCUDADeviceCount(); ++dev_id) {
if (place.device != dev_id) { if (place.device != dev_id) {
int capable = 0; int capable = 0;
PADDLE_ENFORCE_CUDA_SUCCESS( PADDLE_ENFORCE_CUDA_SUCCESS(
cudaDeviceCanAccessPeer(&capable, place.device, dev_id)); cudaDeviceCanAccessPeer(&capable, place.device, dev_id));
if (!capable) { if (!capable) {
VLOG(1) << "device(" << place.device
<< ") can not access peer to device(" << dev_id << ")";
continue; continue;
} }
} }
CUmemAccessDesc access_desc = {};
// Specify which device we are adding mappings for. // Specify which device we are adding mappings for.
access_desc_[dev_id].location.type = CU_MEM_LOCATION_TYPE_DEVICE; access_desc.location.type = CU_MEM_LOCATION_TYPE_DEVICE;
access_desc_[dev_id].location.id = dev_id; access_desc.location.id = dev_id;
// Specify both read and write access. // Specify both read and write access.
access_desc_[dev_id].flags = CU_MEM_ACCESS_FLAGS_PROT_READWRITE; access_desc.flags = CU_MEM_ACCESS_FLAGS_PROT_READWRITE;
access_desc_.push_back(access_desc);
} }
// Get the minimum granularity needed for all devices // Get the minimum granularity needed for all devices
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册