allocated Memory Problem

Hello,

I have written a small program, where Ram is being tested by video card and wanted total Memory to allocate, but not at all possible, if can help me?

As a piece of code is:

//Calculate size of allocatable memory

//Allocate device memory

extern "C" __declspec(dllexport) void FSC_cudaMemTest(int device, size_t *errors0, size_t *errorsComp, size_t *allocatedMem, size_t *totalMem)  

{

	//Declarations

	unsigned char	*ptr;

	unsigned char	value = 0;

	unsigned int	available = 0,

					total = 0;

	size_t			factor = 0,

					size = 0;

	dim3			blocks(8, 1, 1),

					threads(510, 1, 1);

	

	//Set device

	cudaSetDevice(device);	

	

	//Get meminfo

	FSC_cudaGetMemInfo(&available, &total, device);

	

	//Set factor

	factor = (size_t)(total * 0.1);

	//Calculate allocatable memory

	while(factor > 0)

	{

		while(cudaMalloc((void**)&ptr, size += factor) == cudaSuccess)

			cudaFree(ptr);

		size -= factor;

		factor = (size_t)(factor * 0.1);

	}

	while (cudaMalloc((void**)&ptr, ++size) == cudaSuccess)

		cudaFree(ptr);

	//Allocate global memory

	CUDA_SAFE_CALL(cudaMalloc((void**)&ptr, --size));	

	

	*errors0 = FSC_cudaMemInit(blocks, threads, size, value, ptr);

	//Set complement

	value = ~value;

	

	*errorsComp = FSC_cudaMemInit(blocks, threads, size, value, ptr);

	

	//Free device memory

	cudaFree(ptr);

	

	//Set variables

	*totalMem = total;

	*allocatedMem = size;

	

	//Reset cudaSetDevice(device)

	cudaThreadExit();

}

Output is total Memory : 1610285056 Bytes

    allocated Memory : 1510408192 Bytes

Some parts of the video card (or telsa card) is already reserved:

  • Video Buffer and/or OpenGL treatment (if used video)
  • nVidia Driver intrnal structures on video card
  • Kernel code
  • Kernel Parameters
  • Threads Local Memory (will be 0 in your case)

In your case, where you just allocate memory, there’s always memory used by cuda driver, nvidia video driver itself, and room for kernel code, even if no screen is connected.