Skip to content

Commit 42978b6

Browse files
committed
GPU: report free memory on GPU memory allocation failure
1 parent f60bda1 commit 42978b6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ int GPUReconstructionCUDA::InitDevice_Runtime()
307307
}
308308

309309
if (mDeviceMemorySize > cudaDeviceProp.totalGlobalMem || GPUFailedMsgI(cudaMalloc(&mDeviceMemoryBase, mDeviceMemorySize))) {
310-
GPUError("CUDA Memory Allocation Error (trying %lld bytes, %lld available)", (long long int)mDeviceMemorySize, (long long int)cudaDeviceProp.totalGlobalMem);
310+
size_t free, total;
311+
GPUFailedMsg(cudaMemGetInfo(&free, &total));
312+
GPUError("CUDA Memory Allocation Error (trying %lld bytes, %lld available on GPU, %lld free)", (long long int)mDeviceMemorySize, (long long int)cudaDeviceProp.totalGlobalMem, (long long int)free);
311313
GPUFailedMsgI(cudaDeviceReset());
312314
return (1);
313315
}

GPU/GPUTracking/Base/hip/GPUReconstructionHIP.hip

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ int GPUReconstructionHIPBackend::InitDevice_Runtime()
393393
}*/
394394

395395
if (mDeviceMemorySize > hipDeviceProp.totalGlobalMem || GPUFailedMsgI(hipMalloc(&mDeviceMemoryBase, mDeviceMemorySize))) {
396-
GPUError("HIP Memory Allocation Error (trying %lld bytes, %lld available)", (long long int)mDeviceMemorySize, (long long int)hipDeviceProp.totalGlobalMem);
396+
size_t free, total;
397+
GPUFailedMsg(hipMemGetInfo(&free, &total));
398+
GPUError("HIP Memory Allocation Error (trying %lld bytes, %lld available on GPU, %lld free)", (long long int)mDeviceMemorySize, (long long int)hipDeviceProp.totalGlobalMem, (long long int)free);
397399
GPUFailedMsgI(hipDeviceReset());
398400
return (1);
399401
}

0 commit comments

Comments
 (0)