2

Let us say I have numerous CUDA kernels that I can ask the GPU to execute. I don't want to modify the kernel code in anyway (to include a trap for eg).

Is there a way to kill such a running kernel?

I intend to auto generate kernels (Genetic Programming). These kernels are likely to have behavior where they may take a very long time to complete. If I can kill a kernel while it is running I can maintain a timer and kill if required.

Prashanth Ellina
  • 374
  • 3
  • 15
  • Will you have to check the output of the kernels to determine if they should be killed? Then it makes more sense to use a regular model where you create kernels that run for brief periods of time and examine their output to determine if they should be relaunched. – Roger Dahl Sep 29 '13 at 03:04
  • In my use case the output cannot be interpreted to take actions. I need a mechanism to preempt as running kernel. – Prashanth Ellina Sep 29 '13 at 03:57
  • 3
    I think you are almost certainly on the wrong track in your design. If you manage to come up with a way to kill a running kernel, it will be a hack -- not something CUDA was designed to do. You should consider how you can modify your design in such a way that it works within the regular CUDA paradigm. – Roger Dahl Sep 29 '13 at 04:04

1 Answers1

5

cudaDeviceReset() will kill any running kernel(s).

It will also wipe out any allocations done on the device, so you will need to re-allocate any data areas if you intend to use them again.

Note that cudaDeviceReset() by itself is insufficient to restore a GPU to proper functional behavior. In order to accomplish that, the "owning" process must also terminate. See here.

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257