# InternalError: Could not find valid device for node. Node: 'dnn/conv2d/Conv2D' Op:Conv2D. This is probably because CUDA_VISIBLE_DEVICES is set incorrectly.

- **ID:** `tensorflow/gpu-visible-devices-ignored`
- **Domain:** tensorflow
- **Category:** config_error
- **Error Code:** `ECF`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

CUDA_VISIBLE_DEVICES environment variable is set to an invalid GPU index or empty, causing TensorFlow to fail to find a usable GPU for convolution operations.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| TensorFlow 2.8.0 | active | — | — |
| CUDA 11.2 | active | — | — |
| NVIDIA Driver 470.57.02 | active | — | — |

## Workarounds

1. **Check available GPUs with `nvidia-smi` and set CUDA_VISIBLE_DEVICES to a comma-separated list of valid indices. For example, if nvidia-smi shows GPU 0 and GPU 1, use `export CUDA_VISIBLE_DEVICES=0,1` before running the script.** (90% success)
   ```
   Check available GPUs with `nvidia-smi` and set CUDA_VISIBLE_DEVICES to a comma-separated list of valid indices. For example, if nvidia-smi shows GPU 0 and GPU 1, use `export CUDA_VISIBLE_DEVICES=0,1` before running the script.
   ```
2. **If no GPU is available, force TensorFlow to use CPU by setting `tf.config.set_visible_devices([], 'GPU')` after import.** (80% success)
   ```
   If no GPU is available, force TensorFlow to use CPU by setting `tf.config.set_visible_devices([], 'GPU')` after import.
   ```
3. **Verify that the physical GPU devices are recognized: `print(tf.config.list_physical_devices('GPU'))`. If empty, check driver installation and CUDA version compatibility.** (85% success)
   ```
   Verify that the physical GPU devices are recognized: `print(tf.config.list_physical_devices('GPU'))`. If empty, check driver installation and CUDA version compatibility.
   ```

## Dead Ends

- **** — If GPU 0 is not present or is reserved by another process, TensorFlow still cannot allocate the convolution op. (85% fail)
- **** — The error is not due to missing GPU support but due to environment variable misconfiguration; reinstalling does not fix the variable. (70% fail)
- **** — This explicitly disables all GPUs, which may not be the intended fix if the user wants GPU acceleration. (60% fail)
