TensorFlow 安装指南 🚀

TensorFlow 是 Google 开发的开源机器学习框架,适合初学者和高级开发者。以下是安装步骤:

1. 系统要求

  • 操作系统:支持 Linux、Windows、macOS
  • Python 版本:3.7+(推荐 3.8 或 3.9)
  • GPU 支持(可选):需 NVIDIA 显卡 + CUDA 驱动

2. 安装方法

方法一:通过 pip 安装

pip install tensorflow

📌 注意:此命令会安装最新版本,建议查看 TensorFlow 官方文档 确认版本兼容性

方法二:通过 Conda 安装

conda install -c conda-forge tensorflow

方法三:从源码编译(高级用户)

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
./configure
bazel build --config=opt --config=cuda //tensorflow:tensorflow

3. 验证安装

运行以下代码检查 TensorFlow 是否安装成功:

import tensorflow as tf
print(tf.__version__)

✅ 如果输出版本号,说明安装成功!

4. 常见问题

  • 安装失败:检查 Python 环境是否正确配置,或尝试 TensorFlow 官方安装教程 的详细步骤
  • GPU 不识别:确保已安装 CUDA 工具包并配置环境变量
TensorFlow_Logo

如需进一步学习 TensorFlow 的使用,请访问 TensorFlow 教程页面 获取更多示例代码和实战项目!