Repository: pytorch
Issue: parallel_for may hang when called in main process and then on daemon process
Labels: module: multiprocessing,triaged,module: deadlock

## 🐛 Bug
The ```torch.Tensor()``` will be stuck or deadlock in the multiprocess if the main process did the  ```torch.Tensor()``` before the child-process start().
Please see the code below to reproduce the bug.
 If reducing the size of dummy_im to the size (3,3), it's ok. Therefore, It might be a shared memory problem.
The bug appears in the following environments:
PyTorch 1.1.0+ Python version:3.7.4 created by conda
PyTorch 1.2.0+ Python version:3.7.4 created by conda
PyTorch 1.2.0+ Python version:3.6.8 created by conda
PyTorch 1.2.0+ Python version:3.5.2 in Docker 

But it's ok in the following environments:
PyTorch 1.1.0+ Python version:3.7.3 created by conda
PyTorch 1.2.0+ Python version:3.7.3 created by conda
 
<!-- A clear and concise description of what the bug is. -->

## To Reproduce
```python
import numpy as np
import torch
import sys
import torch.multiprocessing as mp


if __name__ == '__main__':
    print("Python version=", sys.version)  # Python3.4.4
    print("torch version=", torch.__version__) # torch 1.2.0
    image_queue = mp.Queue(50)

    #########################################
    #comment two lines below and no deadlock, otherwise deadlock in line 23
    dummy_im = np.random.randn(300, 400)
    dummy_im = torch.Tensor(dummy_im)
    #########################################

    def _read_worker():
        im = image_queue.get(block=True)
        print(type(im))
        print(im.shape)
        # stuck here: deadlock? line 23
        im = torch.Tensor(im)
        print(im)

    w = mp.Process(target=_read_worker)
    w.daemon = True  # ensure that the worker exits on process exit
    w.start()
    im = np.random.randn(300, 400)
    image_queue.put(im, block=True)
    w.join()
    print("done")
```

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

- stuck in the line ```im = torch.Tensor(im)``` with no exception error message.

- Reduce the dummy_im to the size (3,3), it becomes work.

- if move the ```dummy_im = torch.Tensor(dummy_im)``` after ```w.start()```, it's ok.

- My Python version is 3.7.4 but if I downgrade to 3.7.3, everything is ok.



## Expected behavior
The normal expected result in torch 1.1.0:
```
Python version= 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0]
torch version= 1.1.0
<class 'numpy.ndarray'>
(300, 400)
tensor([[-0.8363,  1.3835, -0.7603,  ..., -0.0222, -0.4916, -1.2512],
        [-0.2285, -0.6330,  0.4084,  ...,  0.9458,  1.0684,  0.3801],
        [-0.5260,  1.4498, -0.8997,  ...,  0.2333, -0.8163,  1.1754],
        ...,
        [-0.2710,  0.7194, -0.2842,  ...,  0.5777,  1.1365, -0.1534],
        [-0.6067,  0.1561, -1.2539,  ...,  1.6007,  0.4443, -2.6501],
        [ 0.1211, -1.1745, -0.0238,  ...,  1.0563,  1.2978, -2.9615]])
done
```
The stuck output in torch 1.2.0:
```
Python version= 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0]
torch version= 1.2.0
<class 'numpy.ndarray'>
(300, 400)
```

<!-- A clear and concise description of what you expected to happen. -->

## Environment
 - PyTorch Version (e.g., 1.0): 1.2.0
 - OS (e.g., Linux): Ubuntu 16.04 LTS
 - How you installed PyTorch (`conda`, `pip`, source): pip
 - Build command you used (if compiling from source):
 - Python version:3.7.4
 - CUDA/cuDNN version:10.0
 - GPU models and configuration:Geforce GTX 1080Ti
 - Any other relevant information: