# RuntimeError: NVRTC compilation failed: error: Ptx assembly requires .target sm_52 or higher. Current target: sm_50

- **ID:** `cuda/nvrtc-ptx-arch-mismatch`
- **Domain:** cuda
- **Category:** build_error
- **Error Code:** `NVRTC_ERROR_COMPILATION (6)`
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

PTX assembly (inline or via nvrtc) requires a minimum compute capability of 5.2 (Maxwell) to support certain instructions; targeting sm_50 (Maxwell 5.0) lacks features like unified memory addressing and native atomics needed for PTX.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CUDA 11.7 | active | — | — |
| CUDA 12.0 | active | — | — |
| NVRTC 11.7 | active | — | — |
| NVRTC 12.0 | active | — | — |

## Workarounds

1. **Update the target architecture to sm_52 or higher in the NVRTC compilation options. Example: pass '-arch=sm_52' or set the environment variable CUDAARCHS to include sm_52.** (95% success)
   ```
   Update the target architecture to sm_52 or higher in the NVRTC compilation options. Example: pass '-arch=sm_52' or set the environment variable CUDAARCHS to include sm_52.
   ```
2. **If the GPU actually supports sm_52 (e.g., Tesla M40 or newer), ensure the CUDA toolkit version is >= 8.0 which added sm_52 support. If the GPU is sm_50 only (e.g., Tesla K80), replace PTX assembly with equivalent CUDA C code that compiles without PTX.** (85% success)
   ```
   If the GPU actually supports sm_52 (e.g., Tesla M40 or newer), ensure the CUDA toolkit version is >= 8.0 which added sm_52 support. If the GPU is sm_50 only (e.g., Tesla K80), replace PTX assembly with equivalent CUDA C code that compiles without PTX.
   ```

## Dead Ends

- **** — Removing PTX instructions entirely may break the kernel functionality; the error only occurs if PTX is actually used. (60% fail)
- **** — Setting a higher architecture like sm_86 on an older GPU (e.g., sm_50) causes a different error: 'no kernel image is available for execution on the device'. (95% fail)
