But it takes 435 seconds in the first time,then I re-run this code,it also takes 440 seconds.I use pdb to check which part takes the most time,I find in /anaconda3/lib/python3.6/site packages/torch/cuda/__init__:
def _lazy_new(cls, *args, **kwargs):
_lazy_init()
# We need this method only for lazy init, so we can remove it
del _CudaBase.__new__
return super(_CudaBase, cls).__new__(cls, *args, **kwargs)
super(_CudaBase, cls).__new__(cls, *args, **kwargs) takes the most time.
I add torch.cuda.synchronize() in front of the previous code,but I get the same result.But the torch.cuda.synchronize() takes the most time(434 seconds),and the previous code takes only one second.
My enviroment is:ubuntu16.04+cuda9.1+GTX1060 6GB
I’m a beginner of pytorch and CUDA,so I don’t know how to solve this problem by these imformation.Can anyone help me?
I thought this commond will install proper pytorch version for me before,I checked the pytorch version,its version is 0.2.0.There may be some problems with it.Thanks,you give me the inspiration to solve this problem.