'Error in from torch.utils.data import utils

Following is the code used with PyTorch 1.0.1

import torch
import torch.utils
import torch.multiprocessing as multiprocessing
from torch.utils.data import DataLoader
from torch.utils.data import SequentialSampler
from torch.utils.data import RandomSampler
from torch.utils.data import BatchSampler
from torch.utils.data import _utils
from torch.utils.data.dataloader import _DataLoaderIter

from torch.utils.data._utils import collate
from torch.utils.data._utils import signal_handling
from torch.utils.data._utils import MP_STATUS_CHECK_INTERVAL
from torch.utils.data._utils import ExceptionWrapper
from torch.utils.data._utils import IS_WINDOWS
from torch.utils.data._utils.worker import ManagerWatchdog

Upon execution, I get the following error:

ImportError                               Traceback (most recent call last)
<ipython-input-8-34f56ac3615b> in <module>()

         12 from torch.utils.data import RandomSampler
         13 from torch.utils.data import BatchSampler
    ---> 14 from torch.utils.data import _utils
         15 from torch.utils.data.dataloader import _DataLoaderIter
         16 

ImportError: cannot import name 'utils' from 'torch.utils.data' (/usr/local/lib/python3.7/dist-packages/torch/utils/data/__init__.py)


Solution 1:[1]

Maybe the official documentation torchdata.datapipes could guide on solving these issues. Or in the worst, try to tun pip list to see all environments and packages altogether.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Snowflake