Hi, I’ve kept my program running on CPU for more than 30 hours, and it didn’t hangs again. After that, i run it on GPU again and it also didn’t hangs again. A detail I’d  like to mention is that when i posted this question shortly after, my machine automatically restarted, which i think helps to solve this problem.
I also get a runtime error occasionally when I use a shell script to keep running a group pytorch-based program. The error is as the follow shows:

cuda runtime error (4) : unspecified launch failure at /pytorch/aten/src/THC/THCCachingHostAllocator.cpp:257

But when the error appears ,the program just shutdowns and does’t make the program hangs. This may be another problem though, I just to give more information about the hanging since there might be some latent relations.