Repository: pytorch
Issue: Sparse tensors can't be used in DataLoader running many workers
Labels: module: sparse,module: multiprocessing,feature,triaged

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

Sparse tensors can't be used in DataLoader running many workers

## To Reproduce

Steps to reproduce the behavior:

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

```python
import torch.utils.data as D
from scipy.sparse import csr_matrix
import numpy as np
import torch

row  = np.array([0, 3, 0, 7])
col  = np.array([0, 3, 1, 9])
data = np.array([4, 5, 7, 9])
# using CSR matrix as can be row indexed
sparse = csr_matrix((data, (row, col)), shape=(8, 10))

class Dataset(D.Dataset):
    
    def __init__(self, sparse):
        self.data = sparse

    def __len__(self):
        return self.data.shape[0]
    
    def __getitem__(self, index):
        # convert it to COO so to get the atributes to create a sparse tensor
        data = self.data[index].tocoo()
        i = torch.LongTensor(np.vstack((data.row, data.col)))
        v = torch.FloatTensor(data.data)
        data = torch.sparse.FloatTensor(i, v, torch.Size(data.shape))
        return data

d = Dataset(sparse)

loader = torch.utils.data.DataLoader(d, 
                                     batch_size=2,
                                     num_workers=2)

for i in loader:
    print(i)
```

```
RuntimeError: Traceback (most recent call last):
  File "/Users/efelix/miniconda3/envs/release3.7/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/Users/efelix/miniconda3/envs/release3.7/lib/python3.6/site-packages/torch/utils/data/_utils/collate.py", line 41, in default_collate
    storage = batch[0].storage()._new_shared(numel)
RuntimeError: sparse tensors do not have storage
```

## Expected behavior

The same one that I have when not setting n_workers parameter.

```python
loader = torch.utils.data.DataLoader(d, 
                                     batch_size=2)
for i in loader:
    print(i)
```

```
tensor(indices=tensor([[0, 0],
                       [0, 0],
                       [0, 1]]),
       values=tensor([4., 7.]),
       size=(2, 1, 10), nnz=2, layout=torch.sparse_coo)
tensor(indices=tensor([[1],
                       [0],
                       [3]]),
       values=tensor([5.]),
       size=(2, 1, 10), nnz=1, layout=torch.sparse_coo)
tensor(indices=tensor([], size=(3, 0)),
       values=tensor([], size=(0,)),
       size=(2, 1, 10), nnz=0, layout=torch.sparse_coo)
tensor(indices=tensor([[1],
                       [0],
                       [9]]),
       values=tensor([9.]),
       size=(2, 1, 10), nnz=1, layout=torch.sparse_coo)
```

<!-- A clear and concise description of what you expected to happen. -->

## Environment

PyTorch version: 1.1.0
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 10.14.4
GCC version: Could not collect
CMake version: version 3.14.3

Python version: 3.6
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip3] numpy==1.16.3
[conda] blas                      1.0                         mkl  
[conda] mkl                       2019.1                      144  
[conda] mkl-service               1.1.2            py36hfbe908c_5  
[conda] mkl_fft                   1.0.10           py36h5e564d8_0  
[conda] mkl_random                1.0.2            py36h27c97d8_0  
[conda] pytorch                   1.1.0                   py3.6_0    pytorch
[conda] torchvision               0.2.2.post3              pypi_0    pypi

## Additional context

<!-- Add any other context about the problem here. -->