From e28d5b892eb7afa5262da7e24a776576527b0009 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Mon, 22 Nov 2021 09:28:44 +0800 Subject: [PATCH] fix cuda_virtual_mem_allocator a bug, test=develop (#37390) --- .../memory/allocation/cuda_virtual_mem_allocator.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc b/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc index ef64c3bdb35..e3780f2f113 100644 --- a/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc +++ b/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc @@ -49,22 +49,25 @@ CUDAVirtualMemAllocator::CUDAVirtualMemAllocator( // Prepare the access descriptor array indicating where and how the backings // should be visible. - access_desc_.resize(platform::GetCUDADeviceCount()); for (int dev_id = 0; dev_id < platform::GetCUDADeviceCount(); ++dev_id) { if (place.device != dev_id) { int capable = 0; PADDLE_ENFORCE_CUDA_SUCCESS( cudaDeviceCanAccessPeer(&capable, place.device, dev_id)); if (!capable) { + VLOG(1) << "device(" << place.device + << ") can not access peer to device(" << dev_id << ")"; continue; } } + CUmemAccessDesc access_desc = {}; // Specify which device we are adding mappings for. - access_desc_[dev_id].location.type = CU_MEM_LOCATION_TYPE_DEVICE; - access_desc_[dev_id].location.id = dev_id; + access_desc.location.type = CU_MEM_LOCATION_TYPE_DEVICE; + access_desc.location.id = dev_id; // 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 -- GitLab