ToTensor() gets slower in PyTorch 1.0

Hi, i want to update my project to 1.0 from 0.3.1. however, i found the dataloading becomes slower. I find out that the ToTensor function becomes slower. Here is a small example of the probelm.

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 couldn’t reproduce this issue and the nightly build 1.0.0.dev20181228 is faster on my machine then 0.3.1.post3 (6.7s vs. 8.9s).
Could you try out the nightly build (if you are using the stable version) and check the performance again?

Hi thank you for your reply. I update it to nightly build and find it still slower. btw i think the problem is in torchvision not torch as i did not import torch

Thanks for the info.
Did you install torchvision via conda/pip or build from source?
I just timed different PyTorch versions, since the transformation is basically done in PyTorch, but if you tell me your setup, I’ll try to reproduce this issue.

Hi, I install torchvision via conda along with pytorch. the version of torchvison for pytorch 1.0 is 0.2.1, and 0.2.0 for pytorch 0.3.1