# InvalidArgumentError: CPU affinity is not supported on this platform [Op:ModelDataset]

- **ID:** `tensorflow/tf-data-cpu-affinity-error`
- **Domain:** tensorflow
- **Category:** runtime_error
- **Error Code:** `CP`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

TF Data autotuning with CPU affinity is enabled on a platform that does not support sched_setaffinity (e.g., macOS or certain container environments).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow 2.10 | active | — | — |
| tensorflow 2.11 | active | — | — |
| tensorflow 2.12 | active | — | — |

## Workarounds

1. **Disable autotune CPU affinity by calling tf.data.experimental.AutotuneOptions with autotune_cpu_affinity=False before building the dataset pipeline.** (95% success)
   ```
   Disable autotune CPU affinity by calling tf.data.experimental.AutotuneOptions with autotune_cpu_affinity=False before building the dataset pipeline.
   ```
2. **Run the script inside a Linux container (Docker) with full sched_setaffinity support, e.g., docker run --rm -it tensorflow/tensorflow:latest python script.py** (85% success)
   ```
   Run the script inside a Linux container (Docker) with full sched_setaffinity support, e.g., docker run --rm -it tensorflow/tensorflow:latest python script.py
   ```

## Dead Ends

- **** — The error is a hard InvalidArgumentError, not a warning; logging suppression does not prevent the crash. (95% fail)
- **** — The issue is at the OS/kernel level, not a library bug; reinstallation does not change platform support. (90% fail)
