Registry / ai-ml / tensorflow-cpu

tensorflow-cpu

JSON →
library2.21.0pypypi✓ verified 25d ago

TensorFlow-cpu is the CPU-optimized variant of TensorFlow, an open-source machine learning framework developed by Google. It is designed for high-performance numerical computation, suitable for training and deploying machine learning models without GPU acceleration. The current version is 2.21.0, and it follows a frequent release cadence, typically aligning with the main TensorFlow project's minor and patch updates every few months.

pip install tensorflow-cpu
INSTALL
IMPORT
SIG · TENSORFLOW-CPU
T
tensorflow-cpu
ai-mlpythonv2.21.0
Install
25.1s avg
Import
9790ms
Disk
1556MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.21.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 25.1s · import 9.790s · 1536MB
1556MB installed
● package 1556MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tensorflow
import tensorflow as tf

This quickstart code verifies the installed TensorFlow version, checks if CPU devices are recognized, and performs a basic tensor operation to confirm that TensorFlow is functioning correctly on the CPU.

import tensorflow as tf # Verify TensorFlow version print(f"TensorFlow Version: {tf.__version__}") # Verify CPU device is recognized cpu_devices = tf.config.list_physical_devices('CPU') print(f"CPU Devices: {cpu_devices}") if cpu_devices: print(f"TensorFlow is configured to use CPU: {cpu_devices[0].name}") # Perform a simple operation to confirm functionality a = tf.constant([[1.0, 2.0], [3.0, 4.0]]) b = tf.constant([[1.0, 1.0], [1.0, 1.0]]) print(f"Result of a + b:\n{a + b}") else: print("No CPU devices found by TensorFlow. Check installation.")
tensorflow --version
Debug
Known issues
breakingSupport for Python 3.9 has been removed starting with TensorFlow 2.21.
fix
Upgrade to Python 3.10 or newer. The `tensorflow-cpu` package generally requires Python >=3.10.
affects: >=2.21.0
breakingKeras 3 became the default Keras version starting with TensorFlow 2.16. This may introduce breaking changes if your code relies on Keras 2 APIs.
fix
Update your code to be compatible with Keras 3. To continue using Keras 2 (tf-keras), install `tf-keras` via `pip install tf-keras~=2.16` and set the environment variable `TF_USE_LEGACY_KERAS=1` before importing TensorFlow.
affects: >=2.16.0
breakingThe `tf.estimator` API has been removed.
fix
Migrate your code away from `tf.estimator`. If you must use this API, you will need to use TensorFlow 2.15 or an earlier version.
affects: >=2.16.0
gotchaIf a GPU is present on your system, TensorFlow might prioritize it even if you've installed `tensorflow-cpu`. This can lead to unexpected GPU utilization.
fix
To explicitly restrict TensorFlow to CPU, add `tf.config.set_visible_devices([], 'GPU')` at the beginning of your script, before any other TensorFlow operations.
affects: All versions
gotchaOptimizing TensorFlow performance on CPU often requires tuning specific runtime options and environment variables.
fix
Consider adjusting `tf.config.threading.set_intra_op_parallelism_threads()` and `tf.config.threading.set_inter_op_parallelism_threads()`. For Intel CPUs, setting the environment variable `TF_ENABLE_ONEDNN_OPTS=1` can enable oneDNN optimizations (default on Windows x64 & x86 since TF 2.15).
affects: All versions
Errors
Common errors & fixes
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
The pre-built TensorFlow CPU binaries are compiled for broad compatibility using a baseline instruction set, while your CPU supports more advanced instruction sets (like AVX2, FMA) that could offer performance improvements if utilized.
fix
This is a warning, not an error, and TensorFlow will function correctly. To fully leverage your CPU's advanced instructions for potentially better performance, you would need to build TensorFlow from source with specific compiler flags (e.g., -march=native); otherwise, you can safely ignore this warning.
ModuleNotFoundError: No module named 'tensorflow'
The `tensorflow-cpu` package is not installed in your current Python environment, or the environment where it was installed is not active.
fix
Install the package using pip: `pip install tensorflow-cpu` or ensure you have activated the correct virtual environment where `tensorflow-cpu` is already installed.
Could not load dynamic library 'libcudart.so.X.Y'; dlerror: libcudart.so.X.Y: cannot open shared object file: No such file or directory
Despite installing `tensorflow-cpu`, this error indicates that a GPU-enabled TensorFlow installation or a previous attempt to install one is present, causing TensorFlow to search for CUDA libraries that are missing.
fix
Ensure that only `tensorflow-cpu` is installed by explicitly uninstalling any conflicting GPU versions (`pip uninstall tensorflow tensorflow-gpu && pip install tensorflow-cpu`). Also, verify that no lingering environment variables are pointing to non-existent CUDA library paths.
ERROR: Could not find a version that satisfies the requirement tensorflow-cpu
This usually means there isn't a pre-built wheel package for `tensorflow-cpu` compatible with your specific Python version, operating system, and architecture combination, or your pip is outdated.
fix
Upgrade pip (`python -m pip install --upgrade pip`), ensure your Python version is officially supported by the specific `tensorflow-cpu` version you're trying to install (e.g., Python 3.9-3.11 for recent TF 2.x versions), and check your internet connection or proxy settings.
Upgrade
Version history
2.21.0latest on PyPI · released Mar 6, 2026
Audit
Dependencies
pythonrequiredRequired Python interpreter version
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
tensorflow-cpu — pip install tensorflow-cpu · libregistry