@@ -156,6 +156,7 @@ int GPUReconstructionCUDABackend::InitDevice_Runtime()
156156 const int reqVerMaj = 2 ;
157157 const int reqVerMin = 0 ;
158158 std::vector<bool > devicesOK (count, false );
159+ std::vector<size_t > devMemory (count, 0 );
159160 bool contextCreated = false ;
160161 for (int i = 0 ; i < count; i++) {
161162 if (mDeviceProcessingSettings .debugLevel >= 4 ) {
@@ -200,7 +201,7 @@ int GPUReconstructionCUDABackend::InitDevice_Runtime()
200201 } else if (cudaDeviceProp.major < reqVerMaj || (cudaDeviceProp.major == reqVerMaj && cudaDeviceProp.minor < reqVerMin)) {
201202 deviceOK = false ;
202203 deviceFailure = " Too low device revision" ;
203- } else if (free < mDeviceMemorySize ) {
204+ } else if (free < std::max ( mDeviceMemorySize , ( size_t ) 512 * 1024 * 1024 ) ) {
204205 deviceOK = false ;
205206 deviceFailure = " Insufficient GPU memory" ;
206207 }
@@ -213,6 +214,7 @@ int GPUReconstructionCUDABackend::InitDevice_Runtime()
213214 continue ;
214215 }
215216 devicesOK[i] = true ;
217+ devMemory[i] = free ;
216218 if (deviceSpeed > bestDeviceSpeed) {
217219 bestDevice = i;
218220 bestDeviceSpeed = deviceSpeed;
@@ -226,7 +228,7 @@ int GPUReconstructionCUDABackend::InitDevice_Runtime()
226228 bool noDevice = false ;
227229 if (bestDevice == -1 ) {
228230 GPUWarning (" No %sCUDA Device available, aborting CUDA Initialisation" , count ? " appropriate " : " " );
229- GPUImportant (" Requiring Revision %d.%d, Mem: %lld" , reqVerMaj, reqVerMin, (long long int )mDeviceMemorySize );
231+ GPUImportant (" Requiring Revision %d.%d, Mem: %lld" , reqVerMaj, reqVerMin, (long long int )std::max ( mDeviceMemorySize , ( size_t ) 512 * 1024 * 1024 ) );
230232 noDevice = true ;
231233 } else if (mDeviceProcessingSettings .deviceNum > -1 ) {
232234 if (mDeviceProcessingSettings .deviceNum >= (signed )count) {
@@ -303,6 +305,12 @@ int GPUReconstructionCUDABackend::InitDevice_Runtime()
303305 return (1 );
304306 }
305307
308+ if (mDeviceMemorySize == 2 ) {
309+ mDeviceMemorySize = devMemory[mDeviceId ] * 2 / 3 ; // Leave 1/3 of GPU memory for event display
310+ } else if (mDeviceMemorySize == 1 ) {
311+ mDeviceMemorySize = devMemory[mDeviceId ] - 512 * 1024 * 1024 ; // Take all GPU memory but 1/2 GB
312+ }
313+
306314 if (mDeviceMemorySize > cudaDeviceProp.totalGlobalMem || GPUFailedMsgI (cudaMalloc (&mDeviceMemoryBase , mDeviceMemorySize ))) {
307315 GPUError (" CUDA Memory Allocation Error" );
308316 GPUFailedMsgI (cudaDeviceReset ());
0 commit comments