系统环境准备 🐧
- 推荐系统:Ubuntu 20.04 或更高版本
- Python 版本:3.7 - 3.10(建议使用 Python 官方文档 查看兼容性)
安装方法 🛠️
方式一:使用 pip 安装
- 确保已安装 Python 和 pip
- 运行命令:
pip install tensorflow
- 验证安装:
import tensorflow as tf print(tf.__version__)
方式二:从源码编译(高级用户)
- 克隆官方仓库:
git clone https://github.com/tensorflow/tensorflow.git
- 进入目录并配置环境:
cd tensorflow ./configure
- 编译并安装:
bazel build --config=opt --config=cuda //tensorflow:tensorflow