Repository: pytorch
Issue: TORCH_USE_CUDA_DSA compiler flag not working
Labels: module: cuda,triaged

### 🐛 Describe the bug

I did `export TORCH_USE_CUDA_DSA=1` before building using `python3 setup.py develop`, but when cuda error happens, it still ask me to compile with this option.
Also tried to replace all instances of `#ifdef TORCH_USE_CUDA_DSA` in the code base with `#if 1` to force it, also no use.
What am I missing here or is there something that resets this option during build?

I'm building on top of the tagged commit for 2.2.1 stable release (also not sure why is the version `2.2.0a0+git6c8c5ad` instead of `2.2.1` but that's not an issue for me)

### Versions

```
PyTorch version: 2.2.0a0+git6c8c5ad
Is debug build: False
CUDA used to build PyTorch: 12.3
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.28.3
Libc version: glibc-2.35

Python version: 3.9.18 (main, Aug 25 2023, 13:20:14)  [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.19.0-051900rc6-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.3.107
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: Tesla V100-PCIE-16GB
GPU 1: Tesla V100-PCIE-16GB

Nvidia driver version: 545.23.08
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.7
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
Address sizes:                   46 bits physical, 48 bits virtual
Byte Order:                      Little Endian
CPU(s):                          40
On-line CPU(s) list:             0-39
Vendor ID:                       GenuineIntel
Model name:                      Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
CPU family:                      6
Model:                           85
Thread(s) per core:              1
Core(s) per socket:              20
Socket(s):                       2
Stepping:                        4
CPU max MHz:                     3700.0000
CPU min MHz:                     1000.0000
BogoMIPS:                        4800.00
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 monitor ds_cpl 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 pti intel_ppin ssbd mba ibrs ibpb stibp 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 hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke md_clear flush_l1d arch_capabilities
L1d cache:                       1.3 MiB (40 instances)
L1i cache:                       1.3 MiB (40 instances)
L2 cache:                        40 MiB (40 instances)
L3 cache:                        55 MiB (2 instances)
NUMA node(s):                    2
NUMA node0 CPU(s):               0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38
NUMA node1 CPU(s):               1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39
Vulnerability Itlb multihit:     KVM: Mitigation: VMX unsupported
Vulnerability L1tf:              Mitigation; PTE Inversion
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Mmio stale data:   Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Mitigation; Clear CPU buffers; SMT disabled

Versions of relevant libraries:
[pip3] flake8==7.0.0
[pip3] numpy==1.26.4
[pip3] optree==0.10.0
[pip3] pytest-flake8==1.1.1
[pip3] torch==2.2.0a0+git6c8c5ad
[pip3] torchaudio==2.2.1
[pip3] torcheval==0.0.7
[pip3] torchvision==0.17.1
[pip3] triton-nightly==2.1.0.post20240108192258
[conda] Could not collect
```

cc @ptrblck