Repository: pytorch
Issue: [BUG Report]Integrate libtorch to ffmpeg but memory leak happened!
Labels: module: build,triaged,module: vision

## 🐛 Bug
```
<!-- A clear and concise description of what the bug is. -->
==58309== 3,120 (1,800 direct, 1,320 indirect) bytes in 15 blocks are definitely lost in loss record 14,673 of 15,041
==58309==    at 0x4C2A4C3: operator new(unsigned long) (vg_replace_malloc.c:344)
==58309==    by 0x287075D3: c10::cuda::CUDACachingAllocator::THCCachingAllocator::malloc(void**, unsigned long, CUstream_st*) (in /data/source/pytorch/build/lib/libc10_cuda.so)
==58309==    by 0x28708A49: c10::cuda::CUDACachingAllocator::CudaCachingAllocator::allocate(unsigned long) const (in /data/source/pytorch/build/lib/libc10_cuda.so)
==58309==    by 0xC0C5DE5: THCStorage_resize (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0x9A51EAB: at::native::empty_strided_cuda(c10::ArrayRef<long>, c10::ArrayRef<long>, c10::TensorOptions const&) (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0xBF9C018: at::CUDAType::empty_strided(c10::ArrayRef<long>, c10::ArrayRef<long>, c10::TensorOptions const&) (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0xA14729C: at::TensorIterator::allocate_outputs() (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0xA148A59: at::TensorIterator::build() (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0xA148CA6: at::TensorIterator::binary_op(at::Tensor&, at::Tensor const&, at::Tensor const&, bool) (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0x9F8E535: at::native::add(at::Tensor const&, at::Tensor const&, c10::Scalar) (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0xBF9D0F0: at::CUDAType::add(at::Tensor const&, at::Tensor const&, c10::Scalar) (in /data/source/pytorch/build/lib/libtorch.so)
==58309==    by 0xB987737: torch::autograd::VariableType::add(at::Tensor const&, at::Tensor const&, c10::Scalar) (in /data/source/pytorch/build/lib/libtorch.so)
## To Reproduce
```
Steps to reproduce the behavior:

1. compile libtorch from pytorch source master and tag v1.2.0.
2. integrate libtorch to ffmpeg and compile ffmpeg debug version(not release version)
3. detect memory leak and that happend!

## Environment
```
PyTorch version: 1.1.0
Is debug build: No
CUDA used to build PyTorch: 9.0.176

OS: CentOS Linux 7 (Core)
GCC version: (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
CMake version: version 3.14.0

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 9.0.176
GPU models and configuration: 
GPU 0: Tesla V100-SXM2-32GB
GPU 1: Tesla V100-SXM2-32GB

Nvidia driver version: 410.79
cuDNN version: Could not collect

Versions of relevant libraries:
[pip] numpy==1.16.4
[pip] torch==1.1.0
[pip] torchsummary==1.5.1
[pip] torchvision==0.3.0
[conda] magma-cuda90              2.5.0                         1    pytorch
[conda] mkl                       2019.4                      243    defaults
[conda] mkl-include               2019.4                      243    defaults
[conda] mkldnn                    0.16.1                        0    mingfeima
[conda] pytorch                   1.1.0           py3.6_cuda9.0.176_cudnn7.5.1_0  
[conda] torchsummary              1.5.1                    pypi_0    pypi
[conda] torchvision               0.3.0           py36_cu9.0.176_1   
```
## Additional context

<!-- Add any other context about the problem here. -->