8

I would like to know how much free memory there is on my device before allocating buffers. Is this possible? I know there's CL_DEVICE_GLOBAL_MEM_SIZE for total memory, and CL_DEVICE_MAX_MEM_ALLOC_SIZE for max size of a single object, but I would like to know the current memory state.

As it stands I'm probably going to have to use OpenGL vendor-specific extensions.

3

No, there is no way, and there is no need to know it, GPU memory can be virtualized and the driver will swap in/out memory from the GPU when it is/not needed.

6
  • 4
    It's good to know there's no way, but why would you say there's no need? I don't want to swap in/out memory, and since I'm working with GL as well, I don't want to eat up all of GL's memory. – nullspace Aug 25 '10 at 17:06
  • There is no need because the driver takes care of that. GL resources are also virtualized. Swapping is not really bad, it just will copy data in VRAM to RAM, and viceversa when necessary. What would you do if you find out there's not enough VRAM left? – Dr. Snoopy Aug 25 '10 at 17:34
  • 1
    Currently, it's crashing the GL subsytem and waits for TDR to restart it. It's possible this is due to a bug in my code, but allocating smaller buffers fixes it. I would like to determine an optimal buffer size. So it's more of a preventative thing. – nullspace Aug 25 '10 at 18:21
  • 1
    That looks like a bug in the GL/CL implementation, your code should not crash the GL/CL impl. – Dr. Snoopy Aug 25 '10 at 18:27
  • 5
    What about the case where I don't want the overhead of swapping? For example, I'm writing a plugin for a 3d animation package (Maya). If I have two characters in a scene and one uses up all the VRAM, I just want the other to use a CPU device. Won't the swapping overhead kill performance when they are both animating? – Chad Vernon Mar 20 '13 at 21:38
2

You can use GL_NVX_gpu_memory_info on nVidia.

1
  • 2
    That's what I ended up using, and ATI_meminfo on ATI, but that's GL, not CL. – nullspace Aug 27 '10 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.