File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,15 @@ RegisteredMemory::Impl::Impl(const std::vector<char>& serialization) {
277277
278278RegisteredMemory::Impl::~Impl () {
279279 // Close the CUDA IPC handle if it was opened during deserialization
280- if (data && transports.has (Transport::CudaIpc) && getHostHash () == this ->hostHash && getPidHash () != this ->pidHash ) {
280+ if (data && transports.has (Transport::CudaIpc) && getHostHash () == this ->hostHash ) {
281+ if (getPidHash () == this ->pidHash ) {
282+ // For local registered memory
283+ if (fileDesc >= 0 ) {
284+ close (fileDesc);
285+ fileDesc = -1 ;
286+ }
287+ return ;
288+ }
281289 void * base = static_cast <char *>(data) - getTransportInfo (Transport::CudaIpc).cudaIpcOffsetFromBase ;
282290 if (this ->isCuMemMapAlloc ) {
283291 CUmemGenericAllocationHandle handle;
@@ -288,9 +296,6 @@ RegisteredMemory::Impl::~Impl() {
288296 MSCCLPP_CULOG_WARN (cuMemUnmap ((CUdeviceptr)base, size));
289297 MSCCLPP_CULOG_WARN (cuMemRelease (handle));
290298 MSCCLPP_CULOG_WARN (cuMemAddressFree ((CUdeviceptr)base, size));
291- if (getNvlsMemHandleType () == CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR && fileDesc >= 0 ) {
292- close (fileDesc);
293- }
294299 } else {
295300 cudaError_t err = cudaIpcCloseMemHandle (base);
296301 if (err != cudaSuccess) {
You can’t perform that action at this time.
0 commit comments