支持的安装方式 📦
TensorFlow 可通过以下方式安装,具体选择取决于您的使用场景和环境需求:
Python 环境
使用pip
安装最新版本:pip install tensorflow
Conda 环境
通过conda
安装:conda install -c conda-forge tensorflow
从源码编译
需要 Linux/macOS 系统:git clone https://github.com/tensorflow/tensorflow.git cd tensorflow bazel build //tensorflow:tensorflow
⚙️ 了解更多编译要求
系统兼容性 🌐
平台 | 支持版本 | 安装建议 |
---|---|---|
Linux | Ubuntu 18.04+ | 使用 pip 或 conda 安装 |
macOS | 10.15+ | 安装 Homebrew 包 |
Windows | 10/11 | 优先使用 Anaconda 分发版 |
常见问题解决 🛠️
GPU 支持
确保已安装 CUDA/cuDNN 并选择tensorflow-gpu
版本:pip install tensorflow-gpu
版本冲突
使用pip install --upgrade tensorflow
更新到最新版本
🔄 查看版本兼容性列表虚拟环境
推荐使用venv
或conda env
创建独立环境:python -m venv tf_env source tf_env/bin/activate
🌱 了解虚拟环境管理