Pytorch 1.0 slower than 0.31?

I just swap my project from 0.31 to 1.0 and i found that the dataloading is getting slower. Anyone knows that reason?

Hi, did you follow all the update guides for all the intermediate versions?
If so could you give more informations about what you’re doing and what you’re observing?

Hi, thanks for your reply. could you please explain what update guides?
I write a dataloading class which includes a getitem function. The functions basically use PIL to load a image and do some transformations. I use getitem to load all images and count the time. I find that 1.0 is slower than 0.3.1. My guess is that maybe in 1.0 tensor has both the function of tensor and variable in 0.3.1, which resulting in some additional computing ?

You can check the update notes on github. They contain some details on how to updatr your code.

You should not see any slowdown in the dataloading. Would you have a small code sample to reproduce the issue?

Hi, I count the time of each component in my dataloading function. For PIL image loading and transformation, the time are the same. For the ToTensor function, V1.0 is slower than 0.3.1. I dont know why

Here is a small demo of the problem.

import torch
import torchvision
import time
from PIL import Image




ToTensor=torchvision.transforms.ToTensor()
start_time=time.time()
for i in range(10000):
    img=Image.open('out.png')
    img=ToTensor(img)
print ('time:',time.time()-start_time)

V1.0 takes more time than 0.3.1 (48s vs. 39s)

I do not see any instructions on how to update code… can you be more specific?

1 Like

Here’s the 0.4 -> 1.0 migration guide: https://pytorch.org/blog/pytorch-0_4_0-migration-guide/

I remember there was also a slightly different version of this on GitHub somewhere, but I can’t find it now.

this seems to be the ??? -> 0.4 migration guide… is there a 0.4 -> 1.0 migration guide anywhere?

Oh right … I think the was no 1.0 migration guide as the changes were more internal regarding restructuring (for users, the main features were introduced in 0.4 with deprecation warnings and then made final in 1.0).

In either case, since the OP’s code base is coming from 0.3, this 0.4 migration guide is the place to start. And then maybe having a look at some of the changes in 1.0 via the changelog: https://github.com/pytorch/pytorch/releases/tag/v1.0.0