Skip to content

Instantly share code, notes, and snippets.

@daskol
Last active June 30, 2023 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daskol/0837c4331017d6eba66b788fb7a5a416 to your computer and use it in GitHub Desktop.
Save daskol/0837c4331017d6eba66b788fb7a5a416 to your computer and use it in GitHub Desktop.
Reset CUDA device if program counter was corrupted.
/**
* reset-device.cc
*
* Simple program which resets a devices if kernel launch was failed. This
* could happend due to invalida program counter as an example.
*
* $ nvcc -o reset-device reset-device.cc
* $ ./reset-device
* cudaSuccess: no error
*/
#include <iostream>
#include <cuda.h>
int main(int argc, char *argv[]) {
cudaError_t err = cudaDeviceSynchronize();
std::cout << cudaGetErrorName(err) << ": " << cudaGetErrorString(err)
<< std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment