Accessing devices freeze the program on Linux

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

You need to release every OpenCL object that you create. I have found in long running loops that not freeing clEvent objects frequently would eventually cause my code to freeze when enqueueing kernels. Not exactly the same problem as you are having, but yeah Nvidia’s driver could start freezing if you don’t release every single object.

Good point!

However, I’ve figured it was freezing I was trying to access wrong part of the memory.