서혁준
서혁준

Reputation: 11

module 'torch' has no attribute 'frombuffer' in Google Colab

data_root = os.path.join(os.getcwd(), "data")
transform = transforms.Compose(
[
 transforms.ToTensor(),
 transforms.Normalize([0.5], [0.5]),
]
)
fashion_mnist_dataset = FashionMNIST(data_root, download = True, train = True, transform = transform)

Error Message

/usr/local/lib/python3.7/dist-packages/torchvision/datasets/mnist.py in read_sn3_pascalvincent_tensor(path, strict) 524 # we need to reverse the bytes before we can read them with torch.frombuffer(). 525 needs_byte_reversal = sys.byteorder == "little" and num_bytes_per_value > 1 --> 526 parsed = torch.frombuffer(bytearray(data), dtype=torch_type, offset=(4 * (nd + 1))) 527 if needs_byte_reversal: 528 parsed = parsed.flip(0)

AttributeError: module 'torch' has no attribute 'frombuffer'

what can i do for this err in Colab

Upvotes: 1

Views: 8159

Answers (1)

hac81acnh
hac81acnh

Reputation: 82

I tried your code in my Google Colab by adding the codes (to import the libraries) below, but it works well without errors.

import os
from torchvision import transform
from torchvision.datasets import FashionMNIST

I used

  • torchvision 0.13.0+cu113
  • google-colab 1.0.0
  • Runtime GPU (when I set "None," it also works)

Do you get errors when you also use the same codes above? Do you use another versions?

Upvotes: 1

Related Questions