以下是如何在您的系统上安装 TensorFlow 的步骤。

系统要求

  • 操作系统:Ubuntu 16.04/18.04、Windows 10 或 macOS 10.13 及以上版本。
  • Python:Python 3.5 或更高版本(推荐使用 Python 3.7 或 3.8)。

安装步骤

  1. 安装 Python:确保您的系统已安装 Python 3.5 或更高版本。您可以通过以下命令检查 Python 版本:
    python3 --version
    
  2. 安装 pip:pip 是 Python 的包管理器,用于安装 TensorFlow。您可以通过以下命令安装 pip:
    sudo apt-get install python3-pip  # 对于 Ubuntu
    pip install --upgrade pip  # 升级 pip
    
  3. 安装 TensorFlow:使用以下命令安装 TensorFlow:
    pip install tensorflow
    
    或者,如果您需要 GPU 支持的版本,可以使用:
    pip install tensorflow-gpu
    

验证安装

安装完成后,您可以通过以下命令验证 TensorFlow 是否已成功安装:

python3 -c "import tensorflow as tf; print(tf.__version__)"

扩展阅读

如果您想了解更多关于 TensorFlow 的信息,请访问我们的 TensorFlow 教程

TensorFlow Logo