Repository: pytorch
Issue: [TensorBoard] The different order of import SummaryWriter may cause Segmentation fault
Labels: needs reproduction,oncall: visualization

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->
If I use `from torch.utils.tensorboard import SummaryWriter` to import  `SummaryWriter` at the begin of code, the code `SummaryWriter('path')` works well. But if I have imported something else firstly, then import `SummaryWriter` cause `Segmentation fault`.
## To Reproduce

Steps to reproduce the behavior:
The code sample should not be run in jupyter notebook, because the jupyter's kernel may restart automatically when `Segmentation fault` occurs. 
The following code cause `Segmentation fault`
```bash
fanxp@n101:~/jupyter_notebook/runs$ ipython3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import matplotlib.pyplot as plt 
   ...: import numpy as np 
   ...:  
   ...: import torch 
   ...: import torchvision 
   ...: import torchvision.transforms as transforms 
   ...:  
   ...: import torch.nn as nn 
   ...: import torch.nn.functional as F 
   ...: import torch.optim as optim 

In [2]: from torch.utils.tensorboard import SummaryWriter 
   ...:        
In [3]: writer = SummaryWriter('runs/fashion_mnist_experiment_2')            
Segmentation fault (core dumped)
fanxp@n101:~/jupyter_notebook/runs$
```
And the following code works well
```bash
fanxp@n101:~/jupyter_notebook$ ipython3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:  from torch.utils.tensorboard import SummaryWriter                                                                       

In [2]:  writer = SummaryWriter('runs/fashion_mnist_experiment_2')                                                               

In [3]: import matplotlib.pyplot as plt 
   ...: import numpy as np 
   ...:  
   ...: import torch 
   ...: import torchvision 
   ...: import torchvision.transforms as transforms 
   ...:  
   ...: import torch.nn as nn 
   ...: import torch.nn.functional as F 
   ...: import torch.optim as optim 
   ...:                                                                                                                          

In [4]:                          
```
<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior
when to import SummaryWriter should not cause Segmentation fault
<!-- A clear and concise description of what you expected to happen. -->

## Environment
- PyTorch version: 1.3.0a0+ee77ccb
- Is debug build: No
- CUDA used to build PyTorch: 10.1.243

- OS: Ubuntu 18.04.1 LTS
- GCC version: (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
- CMake version: version 3.10.2

- Python version: 3.6
- Is CUDA available: Yes
- CUDA runtime version: 10.1.243
- GPU models and configuration: GPU 0: Tesla K40c
- Nvidia driver version: 430.50
- cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.2

Versions of relevant libraries:
- [pip3] numpy==1.17.1
- [pip3] torch==1.3.0a0+ee77ccb
- [pip3] torchvision==0.5.0a0+a44d55d
- [conda] Could not collect
- tensorboard 2.0.2

## Additional context

<!-- Add any other context about the problem here. -->
The `torch` and `torchvision` is installed from source code, because the GPU is not supported by the torch binary package.