Are you getting this error only if you execute CUDA code or also CPU operations?
Could you try to get a stack trace via:
$ gdb --args python my_script.py
...
Reading symbols from python...done.
(gdb) run
...
(gdb) backtrace
...

and post it here?
Also, could you post the versions of PyTorch, CUDA, NVIDIA driver?