# RuntimeError: CUDA error: an illegal memory access was encountered in an asynchronous operation

- **ID:** `cuda/tensor-memory-not-contiguous`
- **Domain:** cuda
- **Category:** runtime_error
- **Error Code:** `cudaErrorIllegalAddress`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

A non-contiguous tensor was passed to a CUDA kernel that requires contiguous memory, causing out-of-bounds or misaligned access.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CUDA 11.8 | active | — | — |
| PyTorch 2.1.0 | active | — | — |
| cuDNN 8.9.2 | active | — | — |

## Workarounds

1. **Ensure tensors are contiguous before passing to CUDA kernels: `tensor = tensor.contiguous()`. For PyTorch, add `.contiguous()` after operations like `.transpose()` or `.view()`.** (90% success)
   ```
   Ensure tensors are contiguous before passing to CUDA kernels: `tensor = tensor.contiguous()`. For PyTorch, add `.contiguous()` after operations like `.transpose()` or `.view()`.
   ```

## Dead Ends

- **** — The error is about memory access pattern, not capacity. (85% fail)
- **** — The error is unrelated to device assignment. (90% fail)
