I've written a short OpenCL code that using NVIDIA CUDA platform to run a vector addition. However, the program runs once on the system fine and won't start on the second run. And once, I run the program gnome gets super laggy.

It freeze on

clCreateContext(NULL, device, NULL, NULL, &err);

But I figured even on

clGetDeviceInfo(device[0], CL_DEVICE_NAME,100, String, NULL);

It stops forever. I guess when it gets run first time it's not releasing the device? am not sure.

I'm also releasing memory, kernel, command queue, program, and context.

I'm using GTX 660 with cudatoolkit5.0.35 on Linux 11.10 Ubuntu(which is recommended from NVIDIA). Is there anyway I can "reset" the device without rebooting it? I've tried different drivers and still the same. I'm not sure if it's a problem with the driver or sdk.

Thanks in advance