Thank you for your explanation,
In my experience, the problem without if __name__ == "__main__" will make our code can not execute, and I used it while running my code. However, the code runs normally in this case, the problem is the increase in RAM.
Now we don’t have to worry about this anymore. At the time I raised this question, I used the nightly version, but they published the stable version for torch 1.7 cuda 11 and it solved the problem.
About your explanation, if I understand correctly, you are talking about the RAM of PC but we are discussing GPU RAM, I think they are different.