Is-there a way to bind an array that is already on the gpu to a texture using PyCuda ?
There is already a cuda.bind_array_to_texref(cuda.make_multichannel_2d_array(...), texref)
that binds an array on the CPU to a texture, but I couldn't find the equivalent of cudaBindTextureToArray
in PyCuda if the array is already on the device. For example, doing :
myArray = [1, 2, 3]
myArray_d = gpu.to_gpu(myArray) # then performs some computations on it, and then
cuda.bind_texture_to_array(myArray_d, texref)
If you want to bind an existing CUDA array in GPU memory to a texture reference, then pycuda.driver.TextureReference.set_array()
is probably what you want. Note the PyCUDA is built on the driver API, so the call you are looking for is actually cuTexRefSetArray
rather than cudaBindTextureToArray
.