I am teaching myself CUDA with pyCUDA. In this exercise, I want to send over a simply array of 1024 floats to the GPU and store it in shared memory. As I specify below in my arguments, I run this kernel on just a single block with 1024 threads.
import pycuda.driver as cuda
from pycuda.compiler import SourceModule
import pycuda.autoinit
import numpy as np
import matplotlib.pyplot as plt
arrayOfFloats = np.float64(np.random.sample(1024))
mod = SourceModule("""
__global__ void myVeryFirstKernel(float* arrayOfFloats) {
extern __shared__ float sharedData[];
// Copy data to shared memory.
sharedData[threadIdx.x] = arrayOfFloats[threadIdx.x];
}
""")
func = mod.get_function('myVeryFirstKernel')
func(cuda.InOut(arrayOfFloats), block=(1024, 1, 1), grid=(1, 1))
print str(arrayOfFloats)
Strangely, I am getting this error.
[dfaux@harbinger CUDA_tutorials]$ python sharedMemoryExercise.py
Traceback (most recent call last):
File "sharedMemoryExercise.py", line 17, in <module>
func(cuda.InOut(arrayOfFloats), block=(1024, 1, 1), grid=(1, 1))
File "/software/linux/x86_64/epd-7.3-1-pycuda/lib/python2.7/site-packages/pycuda-2012.1-py2.7-linux-x86_64.egg/pycuda/driver.py", line 377, in function_call
Context.synchronize()
pycuda._driver.LaunchError: cuCtxSynchronize failed: launch failed
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: launch failed
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: launch failed
I have tried to debug this error by changing the type of elements I am sending to my GPU (instead of float64, I use float32 for instance). I have also tried altering my block and grid sizes to no avail.
What could be wrong? What is a dead context? Any advice or ideas appreciated.