Fix RuntimeError: CUDA out of memory (PyTorch)
Fix PyTorch CUDA out-of-memory errors with profiling, batch and sequence controls, AMP, checkpointing, allocator tuning, distributed fixes, and GPU diagnostics.
Root-cause fixes for specific error messages and stack traces.
50 articles
Fix PyTorch CUDA out-of-memory errors with profiling, batch and sequence controls, AMP, checkpointing, allocator tuning, distributed fixes, and GPU diagnostics.
Fix Next.js hydration mismatch errors by matching server and first client output, debugging dates, storage, invalid HTML, CSS, CDN, and production-only changes.
Fix Node.js EADDRINUSE on port 3000: find the listener safely, resolve duplicate servers, and prevent Docker, WSL, CI, and production port clashes reliably.
Fix npm ERR! ERESOLVE dependency tree errors by reading peer conflicts, aligning package versions, using overrides safely, and keeping CI installs reproducible.
Fix Python datetime JSON serialization errors with ISO 8601, timezone-safe encoders, Flask, Django, FastAPI, pandas, debugging, tests, and prevention.
Pandas 2.0 removed DataFrame.append(). Replace it with pd.concat — and if you were appending in a loop, collect rows in a list and build the DataFrame once.
Python 3.10 removed the old collections.Mapping alias. Import from collections.abc instead — but it's usually an old dependency, so read the traceback and upgrade it.
You import cv2 but the pip package is opencv-python — and there are four variants. Pick the right one, and preempt the libGL.so.1 error on servers with headless.
The package is python-dotenv but the import is dotenv — and pip install dotenv is the wrong package. Install python-dotenv into the interpreter you actually run.
This means the left side has fewer targets than the right side has values. Count both sides, iterate dicts with .items(), and use star-unpacking for extras.
OpenAI RateLimitError has two causes that need opposite fixes: insufficient_quota (billing) and rate_limit_exceeded (throughput). Diagnose which, then fix it.
This Hugging Face message is a warning, not the real error — the crash comes later. Fix it with explicit truncation, and watch for the model_max_length sentinel trap.
If bitsandbytes loads libbitsandbytes_cpu.so, no CUDA binary matched. Upgrade bitsandbytes first, confirm a CUDA PyTorch, then fix the library path.
Two causes account for almost every ChromaDB 'collection does not exist' — using get_collection instead of get_or_create, and an ephemeral client that never persisted.
The traceback lies because CUDA runs async. Get the real line with CUDA_LAUNCH_BLOCKING=1 or the CPU, then fix the out-of-range index behind it.
A Hugging Face 401 means the token is missing, invalid, or lacks access. Learn to tell 401 from 403 and 404, and fix gated and private repo access.
A LangChain ValidationError is a Pydantic error — and it names the exact field. Read loc/type/input, and fix the Pydantic v1 vs v2 mismatch behind most of them.
This Hugging Face error means one of two things: a Hub id that can't be found, or a local folder missing tokenizer files. Learn which, then fix it fast.
"Download failed" isn't one error. Triage it by symptom — wrong name, gated auth, network/SSL/proxy, timeout, or a corrupted cache — and apply the right fix.
The fastest test is torch.version.cuda — if it's None you have a CPU-only wheel. PyTorch bundles its own CUDA runtime, so you only need the NVIDIA driver.
How Angular unit testing fits together — TestBed, Jasmine, and Karma — plus code coverage, testing pipes, and testing attribute directives, with examples.
Every TensorFlow CUDA library error — libcublas, libcudart, libnvinfer, cuDNN — traced to one of four root causes, with the order to diagnose them.
The pandas errors that waste the most time — SettingWithCopyWarning, Int64Index errors, silent assignment failures, and merge row explosions — and their causes.
model.fit failing under tf.distribute.MirroredStrategy is almost always: the model/optimizer built outside strategy.scope(), a global batch size that isn't scaled, or a non-replica-aware custom step. The correct pattern, explained.
This TensorFlow error doesn't mean bfloat16 is invalid — it means the specific op has no bfloat16 kernel. Cast to float32 for that op with tf.cast, or use mixed_bfloat16 precision so Keras places dtypes for you.
This internal TensorFlow crash means a GPU kernel was launched with zero or a negative number of elements — almost always an empty batch, a layer whose shape math collapsed to 0, or an int32 overflow on a huge tensor. Here's how to find which.
'InvalidArgumentError: Graph execution error' is a generic wrapper — the real cause is in the nested traceback. The three most common ones (shape mismatch, label out of range, dtype mismatch) and how to fix each.
These TensorFlow errors fire after the libraries load, so they're not path problems — usually GPU memory exhaustion (enable memory growth), a cuDNN/CUDA version mismatch, or the GPU being held by another process. How to diagnose and fix each.
This TensorFlow message about libnvinfer_plugin.so is almost always a harmless TensorRT warning, not an error — TF still runs on GPU. When it actually matters, and how to fix it if you need TensorRT.
The 'Found untraced functions' warning when saving a Keras model is informational, not an error — your model still saves and reloads correctly. Here's why.
Autocomplete fails for tf.keras because it's a lazily-loaded alias that static analyzers can't follow. Your code still runs — import from keras directly to give the IDE a real module to introspect.
This ImportError comes from a shadowed or half-installed package (classically TensorFlow) or a circular import — not from the abs builtin. Here's how to find which one and fix it.
This means the dynamic loader can't find the exact CUDA library your framework was built against. The '.9.0' suffix must match exactly — here's how to check whether it's a path problem or a missing CUDA toolkit, and fix each.
This TensorFlow message means it needs the CUDA 11.x runtime and can't find it. The '11.0' is a major-version SONAME — any CUDA 11.x provides it, CUDA 12 does not. Here's the triage and fix.
TensorFlow returns an empty GPU list even though CUDA is installed via conda — almost always a CUDA/cuDNN version mismatch or a conda-vs-system conflict. Diagnose it and fix it with tensorflow[and-cuda] or a matched conda environment.
EagerTensors from tf.constant are immutable, so slice assignment raises AttributeError. Use tf.Variable, or tf.tensor_scatter_nd_update for a modified copy.
Svelte error handling: the await catch branch, <svelte:boundary> in Svelte 5, and +error.svelte in SvelteKit. There is no <svelte:error> element.
The JDBC error 'Unable to retrieve result set' is a generic wrapper. The real cause is almost always an unresolvable table name, a reserved word, a missing SELECT grant, or a closed statement — here's how to tell them apart and fix each.
Fix Python's str and NoneType concatenation error by finding the None value, repairing missing returns, choosing safe defaults, and avoiding common bad fixes.
This pandas error means you called a datetime accessor like .month on an integer index. Convert the index to datetimes first — and know that Int64Index itself was removed in pandas 2.0.
HTTP 524 is a Cloudflare timeout, not a Jupyter error — the origin took longer than 100 seconds to respond. Fix it by not blocking on long cells, or by bypassing the proxy with an SSH tunnel.
StratifiedKFold makes k non-overlapping folds (every sample tested once); StratifiedShuffleSplit draws independent random splits. When to use each.
Firebase 400 CONFIGURATION_NOT_FOUND means the sign-in method isn't enabled. Enable the provider in Authentication and check your apiKey/projectId.
macOS does not ship with wget. Install it with Homebrew using brew install wget, or build from source with MacPorts as an alternative.
Python: ImportError: lxml not found, please install it
AttributeError: module 'pexpect' has no attribute 'TIMEOUT' means a stale module is loaded or a local file shadows the package. How to tell which, and fix it.
SettingWithCopyWarning means pandas can't tell if you're modifying a view or a copy, so your assignment may silently do nothing. The view-vs-copy .loc fix.
Fix Python Requests Max retries exceeded errors by identifying DNS, refused connection, timeout, TLS, proxy, or HTTP-status causes before adding retries.
Origin is a forbidden header — browsers set it and silently refuse setRequestHeader overrides. Why the restriction exists and the server-side CORS fix.
Generate Angular code coverage with ng test --code-coverage, read the HTML report, enforce thresholds in karma.conf.js, and exclude files that shouldn't count.