Repository: pytorch
Issue: pybind11_object_dealloc error
Labels: module: crash,triaged,module: pybind

## 🐛 Bug

when I use pytorch1.6 to train resnet50-imagenet, I get the following error:

 09:43:47 2020[1,0]<stderr>:terminate called after throwing an instance of 'std::runtime_error'
Mon Aug 24 09:43:47 2020[1,0]<stderr>:  what():  pybind11_object_dealloc(): Tried to deallocate unregistered instance!
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] *** Process received signal ***
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] Signal: Aborted (6)
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] Signal code:  (-6)
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 0] /usr/lib64/libpthread.so.0(+0xf5f0)[0x7f129b11d5f0]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 1] Mon Aug 24 09:43:47 2020[1,0]<stderr>:/usr/lib64/libc.so.6(gsignal+0x37)[0x7f129a66d337]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 2] Mon Aug 24 09:43:47 2020[1,0]<stderr>:/usr/lib64/libc.so.6(abort+0x148)[0x7f129a66ea28]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 3] Mon Aug 24 09:43:47 2020[1,0]<stderr>:/usr/local/conda/lib/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0xbc)[0x7f126b17b84a]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 4] /usr/local/conda/lib/libstdc++.so.6(+0xabf47)[0x7f126b179f47]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 5] /usr/local/conda/lib/libstdc++.so.6(+0xabf7d)[0x7f126b179f7d]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 6] /usr/local/conda/lib/libstdc++.so.6(__cxa_rethrow+0x0)[0x7f126b17a15a]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 7] /usr/local/lib64/python3.6/site-packages/torch/lib/libtorch_python.so(+0x280767)[0x7f126a241767]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 8] /usr/local/lib64/python3.6/site-packages/torch/lib/libtorch_python.so(+0x28ea4c)[0x7f126a24fa4c]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [ 9] /usr/local/lib64/python3.6/site-packages/torch/lib/libtorch_python.so(+0x28f26e)[0x7f126a25026e]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [10] /usr/lib64/libpython3.6m.so.1.0(+0x151adf)[0x7f129b47badf]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [11] /usr/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f129b4700a7]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [12] /usr/lib64/libpython3.6m.so.1.0(+0x150a7c)[0x7f129b47aa7c]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [13] /usr/lib64/libpython3.6m.so.1.0(+0x1518da)[0x7f129b47b8da]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [14] /usr/lib64/libpython3.6m.so.1.0(+0x151b63)[0x7f129b47bb63]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [15] /usr/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f129b4700a7]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [16] /usr/lib64/libpython3.6m.so.1.0(+0x150a7c)[0x7f129b47aa7c]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [17] /usr/lib64/libpython3.6m.so.1.0(+0x1518da)[0x7f129b47b8da]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [18] /usr/lib64/libpython3.6m.so.1.0(+0x151b63)[0x7f129b47bb63]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [19] /usr/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f129b4700a7]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [20] /usr/lib64/libpython3.6m.so.1.0(+0x150ef7)[0x7f129b47aef7]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [21] /usr/lib64/libpython3.6m.so.1.0(+0x1518da)[0x7f129b47b8da]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [22] /usr/lib64/libpython3.6m.so.1.0(+0x151b63)[0x7f129b47bb63]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [23] /usr/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x1639)[0x7f129b471339]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [24] /usr/lib64/libpython3.6m.so.1.0(+0x15182a)[0x7f129b47b82a]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [25] /usr/lib64/libpython3.6m.so.1.0(+0x151b63)[0x7f129b47bb63]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [26] /usr/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f129b4700a7]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [27] /usr/lib64/libpython3.6m.so.1.0(PyEval_EvalCodeEx+0x1b2)[0x7f129b47be62]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [28] /usr/lib64/libpython3.6m.so.1.0(PyEval_EvalCode+0x3b)[0x7f129b47cafb]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] [29] /usr/lib64/libpython3.6m.so.1.0(+0x1dc1ee)[0x7f129b5061ee]
Mon Aug 24 09:43:47 2020[1,0]<stderr>:[set-zw-yarn-training13:02208] *** End of error message ***
Mon Aug 24 09:44:13 2020[1,0]<stderr>:train.sh: line 9:  2208 Aborted                 (core dumped) python -u train.py $@

## Environment
 - PyTorch Version (e.g., 1.6.0):
 - OS (e.g., centos 6.5):
 - build PyTorch ( source):
 - Python version: 3.6
 - CUDA  version: 10.0

## Additional context

I don't know this error is occured since whether the problem of pytorch environment or my code? Sincerely hope you can give answers.