pycuda.gl.RegisteredBuffer causes "OverflowError: Python int too large to convert to C unsigned long"
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 298
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Description
Windows 11, CUDA 12.1 , Python 3.10
Here is my Python script
```
from OpenGL.GL import *
import pygame
import pycuda.driver as cuda
import pycuda.gl
import pycuda.autoinit
import numpy as np
gpu=pycuda.autoinit.device
pygame.init()
pygame.display.set_caption('Test')
pygame.display.set_mode((640, 480),
pygame.OPENGL | pygame.DOUBLEBUF)
cudagl=pycuda.gl.make_context(gpu)
TextureID = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, TextureID)
pbo = glGenBuffers(1) # create a pixel buffer object
openglframe =np.random.randint(low=0,high=255,size=(640,480,4)) # array with the resolution of the image I want to use, in 4 channels for RGBA, used for the byte size of glBufferData
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo)
glBufferData(GL_PIXEL_PACK_BUFFER,openglframe , GL_DYNAMIC_READ) # configures the pixel buffer
glActiveTexture(GL_TEXTURE0) # activate the OpenGL texture slot
glBindTexture(GL_TEXTURE_2D, TextureID) # selects the texture
glTexImage2D(GL_TEXTURE_2D, 0, 3, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, openglframe) # Load the image into OpenGL
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo) #selects the pixel buffer
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE,0)
map = glMapBuffer(GL_PIXEL_PACK_BUFFER,GL_READ_WRITE)
openglmap=pycuda.gl.RegisteredBuffer(map)
```
running it causes this:
> Traceback (most recent call last):
> File "C:\Users\fdasfasdfasd\Documents\test.py", line 32, in
> openglmap=pycuda.gl.RegisteredBuffer(map)
> OverflowError: Python int too large to convert to C unsigned long
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the supplied Windows 11/Python 3.10 reproduction and inspect the call to pycuda.gl.RegisteredBuffer(map) after glMapBuffer returns. Compare the value passed from the mapped OpenGL pixel buffer with the RegisteredBuffer entry point; done means the reproduction no longer raises the reported OverflowError and the buffer can be registered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- computer-graphics, hpc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100