But when I write a network using the first method, it takes 3 hours to run; but when using the second method, it takes only less than 1 hour. I know cuda is asynchronous, and if I use torch.cuda.synchronize() ,  the first method will be faster. But in application, we will always use asynchronous cuda.