# cudaGraphicsGLRegisterBuffer and cudaErrorMemoryAllocation

**URL:** <https://forums.developer.nvidia.com/t/cudagraphicsglregisterbuffer-and-cudaerrormemoryallocation/21998>\
**Category:** CUDA Programming and Performance\
**Created:** [April 13, 2011, 5:22pm UTC](https://forums.developer.nvidia.com/t/cudagraphicsglregisterbuffer-and-cudaerrormemoryallocation/21998 "2011-04-13T17:22:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GregA](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@GregA](https://forums.developer.nvidia.com/u/GregA)\
**Post date:** [April 13, 2011, 5:22pm UTC](https://forums.developer.nvidia.com/t/cudagraphicsglregisterbuffer-and-cudaerrormemoryallocation/21998/1 "2011-04-13T17:22:45Z")

</div>

Got a problem interoperating CUDA/OpenGL on linux, using 3.2. After a lot of device-memory allocating and freeing (cudaMalloc3DArray, cudaMalloc, VBOs with glBufferData) cudaGraphicsGLRegisterBuffer fails, reporting cudaErrorMemoryAllocation. The reference manual doesn’t indicate that cudaErrorMemoryAllocation is ever returned by cudaGraphicsGLRegisterBuffer, and when it happens, cudaMemGetInfo reports 3.6 GB of 4.2 GB available, while the buffer its trying to register is ~7.8 MB. Any ideas out there?

---

<div class="post-metadata">

**Author:** ![Snowball\_Two](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Snowball\_Two](https://forums.developer.nvidia.com/u/Snowball_Two)\
**Post date:** [September 29, 2011, 10:34am UTC](https://forums.developer.nvidia.com/t/cudagraphicsglregisterbuffer-and-cudaerrormemoryallocation/21998/2 "2011-09-29T10:34:31Z")

</div>

Same problem here, with Cuda 4.0 and Geforce 9800 GT.

Everything works fine for thousands of VBO’s, but after a certain number of calls to cudaGraphicsGLRegisterBuffer the function fails with cudaErrorMemoryAllocation. There are still hundrets of MB available…at host AND device.

Also the function cudaGraphicsGLRegisterBuffer gets slower and slower with increasing number of registered VBOs…

---

<div class="post-metadata">

**Author:** ![cmaster.matso](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/cmaster.matso/32/12153_2.png) [@cmaster.matso](https://forums.developer.nvidia.com/u/cmaster.matso)\
**Post date:** [September 29, 2011, 11:32am UTC](https://forums.developer.nvidia.com/t/cudagraphicsglregisterbuffer-and-cudaerrormemoryallocation/21998/3 "2011-09-29T11:32:28Z")

</div>

> [@](#):
>
> Got a problem interoperating CUDA/OpenGL on linux, using 3.2. After a lot of device-memory allocating and freeing (cudaMalloc3DArray, cudaMalloc, VBOs with glBufferData) cudaGraphicsGLRegisterBuffer fails, reporting cudaErrorMemoryAllocation. The reference manual doesn’t indicate that cudaErrorMemoryAllocation is ever returned by cudaGraphicsGLRegisterBuffer, and when it happens, cudaMemGetInfo reports 3.6 GB of 4.2 GB available, while the buffer its trying to register is ~7.8 MB. Any ideas out there?

CUDA reference mentions: “Note that this function may also return error codes from previous, asynchronous launches.” Posting some code would be helpful, I think.

Regards,

MK

---

<div class="post-metadata">

**Author:** ![Snowball\_Two](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Snowball\_Two](https://forums.developer.nvidia.com/u/Snowball_Two)\
**Post date:** [September 29, 2011, 11:36am UTC](https://forums.developer.nvidia.com/t/cudagraphicsglregisterbuffer-and-cudaerrormemoryallocation/21998/4 "2011-09-29T11:36:50Z")

</div>

No other CUDA calls have been made before (except some initialization stuff, but this ain’t async).

Also, i check every call for errors. And everything works, until it fails after call #xxxx.

---

<div class="post-metadata">

**Author:** ![opengpu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@opengpu](https://forums.developer.nvidia.com/u/opengpu)\
**Post date:** [December 1, 2023, 2:58am UTC](https://forums.developer.nvidia.com/t/cudagraphicsglregisterbuffer-and-cudaerrormemoryallocation/21998/5 "2023-12-01T02:58:16Z")

</div>

still got this return value now, any good way to detect where the bug is? thanks!  
cudaGraphicsGLRegisterBuffer fail and return cudaErrorMemoryAllocation
