Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ccarmatic opened this issue Nov 12, 2024 · 0 comments
Labels

Comments

@ccarmatic
Copy link

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

@ccarmatic ccarmatic added the bug label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant