Repository: pytorch
Issue: [utils.bottleneck] throws initialization error for cuda profiling
Labels: module: dataloader,triaged

## 🐛 Bug
When I execute example/mnist/main.py on Colab/Local Machine with cuda,
it throws initialization error.
If I add --no-cuda flag, it works fine

```
terminate called after throwing an instance of 'std::runtime_error'
  what():  /pytorch/torch/csrc/autograd/profiler_cuda.cpp:22: initialization error
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 511, in _try_get_batch
    data = self.data_queue.get(timeout=timeout)
  File "/usr/lib/python3.6/queue.py", line 173, in get
    self.not_empty.wait(remaining)
  File "/usr/lib/python3.6/threading.py", line 299, in wait
    gotit = waiter.acquire(True, timeout)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/signal_handling.py", line 63, in handler
    _error_if_any_worker_fails()
RuntimeError: DataLoader worker (pid 6815) is killed by signal: Aborted. 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/bottleneck/__main__.py", line 231, in <module>
    main()
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/bottleneck/__main__.py", line 210, in main
    autograd_prof_cpu, autograd_prof_cuda = run_autograd_prof(code, globs)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/bottleneck/__main__.py", line 104, in run_autograd_prof
    result.append(run_prof(use_cuda=True))
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/bottleneck/__main__.py", line 98, in run_prof
    exec(code, globs, None)
  File "examples/mnist/main.py", line 116, in <module>
    main()
  File "examples/mnist/main.py", line 109, in main
    train(args, model, device, train_loader, optimizer, epoch)
  File "examples/mnist/main.py", line 30, in train
    for batch_idx, (data, target) in enumerate(train_loader):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 576, in __next__
    idx, batch = self._get_batch()
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 543, in _get_batch
    success, data = self._try_get_batch()
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 519, in _try_get_batch
    raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str))
RuntimeError: DataLoader worker (pid(s) 6815) exited unexpectedly
```
## To Reproduce

Steps to reproduce the behavior:
On Google Colab, execute as follows,

```
!git clone http://github.com/pytorch/examples
!python -m torch.utils.bottleneck examples/mnist/main.py --epochs 1 --batch-size=256
```

## Expected behavior

Profiling works, not throws initialization error.

## Environment
```
processor   =>2

processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 63
model name	: Intel(R) Xeon(R) CPU @ 2.30GHz
stepping	: 0
microcode	: 0x1
cpu MHz		: 2300.000
cache size	: 46080 KB


PyTorch version: 1.1.0
Is debug build: No
CUDA used to build PyTorch: 10.0.130

OS: Ubuntu 18.04.2 LTS
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
CMake version: version 3.12.0

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 10.0.130
GPU models and configuration: GPU 0: Tesla T4
Nvidia driver version: 410.79
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.5.1

Versions of relevant libraries:
[pip3] msgpack-numpy==0.4.3.2
[pip3] numpy==1.16.3
[pip3] torch==1.1.0
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.3.1
[pip3] torchvision==0.2.2.post3
[conda] Could not collect
```

## Additional context