Hello,
Is there a way to get the size of a cuda tensor as if it were encoded as PNG?
I’ve tried this way:
inv_trans = transforms.Compose([ transforms.Normalize(mean = [ 0., 0., 0. ],
                                                     std = [ 1/0.229, 1/0.224, 1/0.225 ]),
                                transforms.Normalize(mean = [ -0.485, -0.456, -0.406 ],
                                                     std = [ 1., 1., 1. ]),
                                lambda x: x*255
                               ])
def get_size_as_png(input_tensor):
  k = inv_trans(input_tensor)
  a = torchvision.io.encode_png(k.type(torch.uint8)) 
  return sys.getsizeof(a.storage())

But when I have tensors in cuda I get the following error:
RuntimeError: Input tensor should be on CPU

Many thanks in advance