Page 1 of 1

Problem with memory allocation when using CULA

PostPosted: Mon Jul 26, 2010 7:25 am
by dzovejn
I have NVIDIA GeForce 8400 GS with 256MB of memory. I noticed that when I use CULA functions amount of memory that can be allocated is significantly reduced. I used this simple code to find the difference between the amount of memory you can allocate when CULA is initialized and when it is not.

culaInitialize(); // This command is commented when CULA is not initialized

void * p=0;

int N;
printf("Size = ");
scanf("%d", &N);

size_t size =N*1000000;

cudaMalloc((void **) &p, size);

if(p != 0)
{
printf("Memory allocated on GPU.\n");
}
else
{
printf("ERROR: Can not allocate memory on GPU. CUDA: ");
printf(cudaGetErrorString(cudaGetLastError()));
printf("\n");
}

In the first case, when CULA is not initialized, maximum N for which memory allocation is successful is 245.
In the second case, when CULA is initialized, maximum N for which memory allocation is successful is 110.
Does anyone know what may be causing this difference in memory that can be allocated in the first and in the second case?
I have one more question.
I noticed that when I use culaDeviceCgesv() function, CPU usage is 100%. I thought that CPU is idle while CULA functions perform on the GPU. Does CULA use CPU resources during function execution?

Re: Problem with memory allocation when using CULA

PostPosted: Mon Jul 26, 2010 1:44 pm
by kyle
The amount of GPU memory can fluctuate depending on the amount of memory being used to draw your desktop, etc. This can easily account for varying amount of free memory.

To answer your second question, CULA uses CPU resources to maximize performance while the GPU is processing.

Re: Problem with memory allocation when using CULA

PostPosted: Mon Jul 26, 2010 2:49 pm
by dzovejn
Thank you, Kyle.
I understand that graphics card is used by other processes, but this is a very simple example, where the amount of free memory is significantly reduced when CULA is activated. Namely, one after another, two codes are executed. State of the system in terms of other applications that run in parallel and everything else is the same in both cases. The only difference is that in the first case CULA is initialized, and in the other it is not, and the difference in amount of memory that can be allocated is more than 100MB. The only thing that seems logical to me is that this memory is occupied by CULA.

Re: Problem with memory allocation when using CULA

PostPosted: Mon Jul 26, 2010 2:53 pm
by kyle
How do your results compare if you initialize CUDA or CUDA & CUBLAS? These are both initialized implicitly by culaInitialize.

Re: Problem with memory allocation when using CULA

PostPosted: Tue Jul 27, 2010 2:42 am
by dzovejn
When only CUBLAS is initialized, it is possible to allocate about 150MB, about 40MB more than when CULA is initialized.