It could be that Spyder does not free memory after one run is completed, and so after a while you do not have any free memory left. I don’t work with Spyder so don’t know how it operates.
You can try adding torch.cuda.empty_cache() at the end of your script  to release memory and see if it helps in the next runs.