I cannot allocate even only 4 bytes of memory with cudaMallocHost()
because of 'out of memory' error. I tried cudaSetDevice(0)
, cudaDeviceSynchronize()
, cudaThreadSynchronize()
, and cudaFree(0)
at the very first of my code for initializing, but they don't work.
I think this link : cudaMalloc always gives out of memory - has the answer what I want but I cannot understand it. How can I solve this problem?
Here is my full code.
/* test.cu */
#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <assert.h>
inline cudaError_t checkCuda(cudaError_t result)
{
if (result != cudaSuccess) {
fprintf(stderr, "CUDA Runtime Error: %s\n", cudaGetErrorString(result));
assert(result == cudaSuccess);
}
return result;
}
int main()
{
cudaSetDevice(0);
cudaDeviceSynchronize();
cudaThreadSynchronize();
cudaFree(0);
int *test_ptr;
checkCuda( cudaMallocHost((void **)&test_ptr, sizeof(int)) );
cudaFreeHost(test_ptr);
printf("Test Success.\n");
return 0;
}
I compiled with this instruction:
nvcc test.cu -o test
and when I execute this:
me@me:~$ ./test
CUDA Runtime Error: out of memory
test: test.cu:10: cudaError_t checkCuda(cudaError_t): Assertion `result == cudaSuccess' failed.
Aborted
My cuda version is 5.0, I'll post more specific device information if you need.