{"id":4276,"library":"tensorflow-cpu","title":"TensorFlow CPU","description":"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.","status":"active","version":"2.21.0","language":"python","source_language":"en","source_url":"https://github.com/tensorflow/tensorflow","tags":["machine learning","deep learning","cpu","tensor","google"],"install":[{"cmd":"pip install tensorflow-cpu","lang":"bash","label":"Install CPU-only TensorFlow"}],"dependencies":[{"reason":"Required Python interpreter version","package":"python","optional":false}],"imports":[{"symbol":"tensorflow","correct":"import tensorflow as tf"}],"quickstart":{"code":"import tensorflow as tf\n\n# Verify TensorFlow version\nprint(f\"TensorFlow Version: {tf.__version__}\")\n\n# Verify CPU device is recognized\ncpu_devices = tf.config.list_physical_devices('CPU')\nprint(f\"CPU Devices: {cpu_devices}\")\n\nif cpu_devices:\n    print(f\"TensorFlow is configured to use CPU: {cpu_devices[0].name}\")\n    # Perform a simple operation to confirm functionality\n    a = tf.constant([[1.0, 2.0], [3.0, 4.0]])\n    b = tf.constant([[1.0, 1.0], [1.0, 1.0]])\n    print(f\"Result of a + b:\\n{a + b}\")\nelse:\n    print(\"No CPU devices found by TensorFlow. Check installation.\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to Python 3.10 or newer. The `tensorflow-cpu` package generally requires Python >=3.10.","message":"Support for Python 3.9 has been removed starting with TensorFlow 2.21.","severity":"breaking","affected_versions":">=2.21.0"},{"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.","message":"Keras 3 became the default Keras version starting with TensorFlow 2.16. This may introduce breaking changes if your code relies on Keras 2 APIs.","severity":"breaking","affected_versions":">=2.16.0"},{"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.","message":"The `tf.estimator` API has been removed.","severity":"breaking","affected_versions":">=2.16.0"},{"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.","message":"If 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.","severity":"gotcha","affected_versions":"All versions"},{"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).","message":"Optimizing TensorFlow performance on CPU often requires tuning specific runtime options and environment variables.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'2.21.0':48 'acceler':43 'align':57 'cadenc':55 'comput':32 'cpu':2,5,9,75 'cpu-optim':8 'current':45 'deep':73 'deploy':37 'design':26 'develop':21 'everi':68 'follow':51 'framework':20 'frequent':53 'googl':23,77 'gpu':42 'high':29 'high-perform':28 'learn':19,39,72,74 'machin':18,38,71 'main':60 'minor':64 'model':40 'month':70 'numer':31 'open':16 'open-sourc':15 'optim':10 'patch':66 'perform':30 'project':62 'releas':54 'sourc':17 'suitabl':33 'tensor':76 'tensorflow':1,4,13,61 'tensorflow-cpu':3 'train':35 'typic':56 'updat':67 'variant':11 'version':46 'without':41","created_at":"2026-04-12T03:48:27.458326+00:00","updated_at":"2026-04-16T22:46:56.881198+00:00","problems":[{"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.","cause":"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.","error":"Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA"},{"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.","cause":"The `tensorflow-cpu` package is not installed in your current Python environment, or the environment where it was installed is not active.","error":"ModuleNotFoundError: No module named 'tensorflow'"},{"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.","cause":"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.","error":"Could not load dynamic library 'libcudart.so.X.Y'; dlerror: libcudart.so.X.Y: cannot open shared object file: No such file or directory"},{"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.","cause":"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.","error":"ERROR: Could not find a version that satisfies the requirement tensorflow-cpu"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.21.0","cli_name":"tensorflow","cli_version":"sh: 1: tensorflow: not found","type":"library","homepage":"https://www.tensorflow.org/","github":"https://github.com/tensorflow/tensorflow","docs":null,"changelog":null,"pypi":"https://pypi.org/project/tensorflow-cpu/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}