Skip to content

pycuda.gl.RegisteredBuffer causes "OverflowError: Python int too large to convert to C unsigned long" #471

Description

@ccarmatic

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions