(Possible) Memory leak on deleting a compiled model
Labels: high priority, triaged, has workaround, module: cuda graphs, oncall: pt2

### 🐛 Describe the bug

Even after deleting a compiled model, cuda allocated memory persists and not freed.

Seems like it may related to `nn.Sequential` since I couldn't reproduce it without `nn.Sequential()`

I wonder if there is something I am missing? or it's an intended behavior?

### Error logs

```
tests/img2img/test_memory_leak.py test 0
[before compile ] alloc: 0.00244140625, reserved: 2.0, max reserved: 2.0
[after compile ] alloc: 57.00341796875, reserved: 92.0, max reserved: 92.0
[after delete] alloc: 57.00341796875, reserved: 92.0, max reserved: 92.0
test 1
[before compile ] alloc: 57.005859375, reserved: 92.0, max reserved: 92.0
[after compile ] alloc: 114.0068359375, reserved: 182.0, max reserved: 182.0
[after delete] alloc: 114.0068359375, reserved: 182.0, max reserved: 182.0
test 2
[before compile ] alloc: 114.00927734375, reserved: 182.0, max reserved: 182.0
[after compile ] alloc: 171.01025390625, reserved: 252.0, max reserved: 252.0
[after delete] alloc: 171.01025390625, reserved: 252.0, max reserved: 252.0
test 3
[before compile ] alloc: 171.0126953125, reserved: 252.0, max reserved: 252.0
[after compile ] alloc: 228.013671875, reserved: 342.0, max reserved: 342.0
[after delete] alloc: 228.013671875, reserved: 342.0, max reserved: 342.0
test 4
[before compile ] alloc: 228.01611328125, reserved: 342.0, max reserved: 342.0
[after compile ] alloc: 285.01708984375, reserved: 412.0, max reserved: 412.0
[after delete] alloc: 285.01708984375, reserved: 412.0, max reserved: 412.0
```

### Minified repro

```python
def print_cuda_memory(name = "none"):
    print(f"[{name}] alloc: {torch.cuda.memory_allocated() / 1024**2}, reserved: {torch.cuda.memory_reserved() / 1024**2}, max reserved: {torch.cuda.max_memory_reserved() / 1024 ** 2}")

def create_and_compile():
    graph = nn.Sequential(nn.Conv2d(3, 16, 3, padding=1)).cuda()
    print_cuda_memory("before compile ")
    graph = torch.compile(graph, mode="reduce-overhead")
    graph(torch.randn((3, 3, 512, 512)).cuda())
    print_cuda_memory("after compile ")

for i in range(5):
    print(f"test {i}")
    create_and_compile()
    print_cuda_memory("after delete")
    sleep(1)
```

### Versions

```
Collecting environment information...
PyTorch version: 2.0.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.26.4
Libc version: glibc-2.31

Python version: 3.10.8 (main, Nov 24 2022, 14:13:03) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-4.19.93-1.nbp.el7.x86_64-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: Quadro RTX 6000
Nvidia driver version: 510.47.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          72
On-line CPU(s) list:             0-71
Thread(s) per core:              2
Core(s) per socket:              18
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           85
Model name:                      Intel(R) Xeon(R) Gold 5220 CPU @ 2.20GHz
Stepping:                        7
CPU MHz:                         2699.996
BogoMIPS:                        4400.00
Virtualization:                  VT-x
L1d cache:                       1.1 MiB
L1i cache:                       1.1 MiB
L2 cache:                        36 MiB
L3 cache:                        49.5 MiB
NUMA node0 CPU(s):               0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70
NUMA node1 CPU(s):               1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71
Vulnerability Itlb multihit:     KVM: Vulnerable
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1:        Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
Vulnerability Spectre v2:        Vulnerable, IBPB: disabled, STIBP: disabled
Vulnerability Tsx async abort:   Vulnerable
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] clip-anytorch==2.5.2
[pip3] mypy==1.3.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.24.3
[pip3] open-clip-torch==2.20.0
[pip3] pytorch-lightning==1.9.5
[pip3] torch==2.0.1
[pip3] torchdiffeq==0.2.3
[pip3] torchmetrics==0.11.4
[pip3] torchsde==0.2.5
[pip3] torchvision==0.15.2
[pip3] triton==2.0.0.post1
[conda] numpy                     1.23.5                   pypi_0    pypi
```

cc @ezyang @gchanan @zou3519 @mcarilli @msaroufim @wconstab @bdhirsh @anijain2305