torch / torch7

http://torch.ch
Other
9k stars 2.38k forks source link

Segmentation fault when loading a dataset #1163

Open kurohi opened 6 years ago

kurohi commented 6 years ago

I have tried installing torch and torchvision from different sources but still cannot figure out why I am getting a segmentation fault error when running the following code.

#!/usr/bin/python
import matplotlib.pyplot as plt

import torch
from torchvision import datasets, transforms

data_dir = 'Cat_Dog_data/train'

transform = transforms.Compose([transforms.Resize(255),
                                 transforms.CenterCrop(224),
                                 transforms.ToTensor()])
dataset = datasets.ImageFolder(data_dir, transform=transform)
dataloader = torch.utils.data.DataLoader(dataset, batch_size=64, shuffle=True)

images, labels = next(iter(dataloader))

after searching for the exact line that gives me the segmentation fault with the python debugger, I found out that this line from torch/utils/data/dataloader.py is causing it base_seed = torch.LongTensor(1).random_().item() it is the line 255 of the file.

More unsetling is that the same program works perfectly on a different computer with the same OS (gentoo)

Thank you in advance for any help.

kurohi commented 6 years ago

After changing to gcc-6 and recompiling both pytorch and torchvision the code worked perfectly. so this can be closed