## TL;DR
An InvalidArgumentError from the event writer means a summary value violates the writer's expectations, most often a non-finite step, a wrong-shaped tensor for the summary type, or a second writer writing the same event file. Log scalars as scalars, check step values are increasing integers, and ensure one writer owns each log directory per process.

```text
TensorBoard error: 'Data written by event writer failed with InvalidArgumentError'
```

## Use this when
- The run or call fails with this symptom: Data written by event writer failed with InvalidArgumentError in TensorBoard.
- You are working on a TensorFlow training job writing TensorBoard summaries and the failure repeats on the same run or configuration.
- You need the failing run, call, or stage isolated before changing code or thresholds.

## Not for this skill when
- An image or histogram summary receiving a mismatched tensor shape, where the fix is reshaping that summary's input.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Find which summary call precedes the error by enabling summaries one family at a time. Verify: the offending summary type is isolated
2. Print the value's shape and dtype at that call and compare with what the summary op expects. Verify: the mismatch is identified concretely
3. Check step values for duplicates or decreases across resumed training, a frequent invalid argument. Verify: steps are monotonic in the failing run
4. Confirm a single process owns the log directory; shared dirs across workers corrupt the writer's assumptions. Verify: one writer per log directory is verified
5. Rerun and open the run in TensorBoard to confirm events accumulate without the error. Verify: scalers render for the new run

## Variant phrasings
### tensorboard event writer invalidargumenterror data written
The verbatim phrasing.
### tensorflow summary write failed invalid argument
The summary phrasing.
### tensorboard event writer error step shape fix
The step phrasing.

Compatibility: TensorBoard event writing with TensorFlow summary APIs

## Why it happens
The event writer validates each record as it serialises it, so malformed values fail at write time with a generic argument error. Because summaries run inside the training loop, the failing call is surrounded by working ones, and the type or step mismatch has to be isolated by family.

## Edge cases / pitfalls
- Two jobs pointed at one logdir is the most damaging variant; it corrupts files as well as raising this error.
- NaN metric values are legal in event files; do not chase them for this error, look at shapes and steps.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst__sqvLL6bIwojFwtNyUzJcQ
