Visitar URL original
IDLE: torch DataLoader crashes with num_workers>0 · Issue #92571 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20260830093841/https://github.com/python/cpython/issues/92571
Skip to content
/ cpython Public

IDLE: torch DataLoader crashes with num_workers>0 #92571

Description

@ylevental

CPython versions tested on: 3.9.12
Operating system and architecture: Fedora 34

I imported DataLoader from torch.utils.data in IDLE. I included everything under if __name__ == '__main__': and still get "do you want to kill it?" message. Then the process stops running.

This program has no errors when run from the command line, just when it's run in IDLE.

from torchvision import datasets
from torchvision.transforms import ToTensor
from matplotlib import pyplot as plt

training_data = datasets.FashionMNIST(
    root="data",
    train=True,
    download=True,
    transform=ToTensor()
)

test_data = datasets.FashionMNIST(
    root="data",
    train=False,
    download=True,
    transform=ToTensor()
)

from torch.utils.data import DataLoader

train_dataloader = DataLoader(training_data, batch_size=64, num_workers=10, shuffle=True)
test_dataloader = DataLoader(test_data, batch_size=64, num_workers=10, shuffle=True)

# Display image and label.
train_features, train_labels = next(iter(train_dataloader))
print(f"Feature batch shape: {train_features.size()}")
print(f"Labels batch shape: {train_labels.size()}")
img = train_features[0].squeeze()

label = train_labels[0]
print(f"Label: {label}")

plt.imshow(img, cmap="gray")
plt.show()

Your environment

  • CPython versions tested on: 3.9.12
  • Operating system and architecture: Fedora 34

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions