Repository: pytorch
Issue: [profiler] are CUDA events mutually exclusive with _ExperimentalConfig.profiler_metrics?
Labels: oncall: profiler

### 🐛 Describe the bug

Trying to profile with the _ExperimentalConfig options, looks like with non-empty 'profiler_metrics' CUDA events are not captured, given the following case trace_handler displays nothing, are they mutually exclusive or I'm using the API (and the metrics) the wrong way? Thanks.

Minimal repro:
```python
import torch
import torchvision.models as models
from torch.profiler import profile, record_function, ProfilerActivity
from torch._C._profiler import _ExperimentalConfig

model = models.resnet18().cuda()

def trace_handler(prof):
    print(prof.key_averages().table(sort_by="self_cuda_time_total", row_limit=10))
    prof.export_chrome_trace("trace.json")


with profile(
    #activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA],
    activities=[ProfilerActivity.CUDA],
    on_trace_ready=trace_handler,
    experimental_config=_ExperimentalConfig(
        # For the record, not sure whether they are valid metrics, comments are appreciated
        profiler_metrics=["achieved_occupancy", "branch_efficiency", "dram_read_bytes", "inst_executed"],
    )
) as prof:
    model(torch.randn(1, 3, 224, 224).cuda())
```

### Versions

PyTorch version: 2.4.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux 11 (bullseye) (x86_64)
GCC version: (Debian 12.2.0-14) 12.2.0
Clang version: Could not collect
CMake version: version 3.30.2
Libc version: glibc-2.36

Python version: 3.11.9 (main, Aug 13 2024, 15:13:18) [GCC 12.2.0] (64-bit runtime)
Python platform: Linux-5.4.143.bsk.8-amd64-x86_64-with-glibc2.36
Is CUDA available: True
CUDA runtime version: 12.5.82
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA L4
Nvidia driver version: 550.54.15
cuDNN version: Probably one of the following:
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn.so.9
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn_adv.so.9
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn_cnn.so.9
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn_engines_precompiled.so.9
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn_engines_runtime_compiled.so.9
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn_graph.so.9
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn_heuristic.so.9
/usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudnn_ops.so.9
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:                   52 bits physical, 48 bits virtual
CPU(s):                          12
On-line CPU(s) list:             0-11
Thread(s) per core:              2
Core(s) per socket:              6
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           143
Model name:                      Intel(R) Xeon(R) Platinum 8457C
Stepping:                        8
CPU MHz:                         2600.000
BogoMIPS:                        5200.00
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       288 KiB
L1i cache:                       192 KiB
L2 cache:                        12 MiB
L3 cache:                        97.5 MiB
NUMA node0 CPU(s):               0-11
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx512_bf16 wbnoinvd arat avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b md_clear arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] pytorch-triton==3.0.0+dedb7bdf33
[pip3] torch==2.4.0
[pip3] torch-tb-profiler==0.4.3
[pip3] torchaudio==2.4.0.dev20240812+cu124
[pip3] torchvision==0.19.0
[pip3] triton==3.0.0
[conda] Could not collect

cc @robieta @chaekit @guotuofeng @guyang3532 @dzhulgakov @davidberard98 @briancoutinho @sraikund16 @sanrise