The problems keep on coming. My latest issue:
this is happening on both linux and windows (mac does it right), with two separate video cards. please help me
cudaGLUnregisterBufferObject does NOT free up GPU memory that cudaGLRegisterBufferObject allocates.
I have a vbo class that upon construction, allocates vbos on construction and deallocates them on destruction. I was noticing it wasn’t giving the memory back. Finally I narrowed it down to the simplest example of the problem:
static void print_mem()
{
CUresult res;
uint free, total;
res = cuMemGetInfo(&free, &total);
cout << "Free memory: " << (free>>20) << " MB" << endl;
}
//ignore the safecall routines, they do the same thing as cutil but put up a dialog box
static void test()
{
const size_t num_verts = 1024*1024*50;
print_mem();
GLuint vbo = 0;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, num_verts*sizeof(float)*4, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
cbctSafeCall(cudaGLRegisterBufferObject(vbo));
print_mem();
cbctSafeCall(cudaGLUnregisterBufferObject(vbo)); //doesn't free a damn thing
print_mem();
glDeleteBuffers(1, &vbo);
print_mem();
}
this code produces:
Total memory: 1023MB
Free memory: 852MB
Free memory: 852 MB
Free memory: 52 MB
Free memory: 52 MB
Free memory: 52 MB