9

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.

talonmies
  • 70,661
  • 34
  • 192
  • 269
nullspace
  • 1,279
  • 13
  • 13

2 Answers2

4

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.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
  • 5
    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
  • Well it looks like the "bug" was actually my kernels taking so long to complete, TDM would reset the display driver. I disabled TDM and everything works fine. Not really sure what to do about this though. – nullspace Aug 25 '10 at 21:01
  • 6
    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.

Calvin1602
  • 9,413
  • 2
  • 44
  • 55