可以使用以下命令在 Anaconda 中安装 TensorFlow:
conda create -n env_name
condaactivate env_name
conda install tensorflow
其中 env_name
是你要创建的虚拟环境的名称。如果你希望在系统默认环境中安装 TensorFlow,可以省略 conda create -n env_name
和 conda activate env_name
两条命令。
如果你使用的是 GPU 版本的 TensorFlow,还需要安装 CUDA 和 cuDNN,然后在安装 TensorFlow 时使用 tensorflow-gpu
代替 tensorflow
如果你使用 Windows 系统,需要使用另外的命令来安装:
conda create -n env_name
condaactivate env_name
conda install -c conda-forge tensorflow
这是因为 Windows 版本的 TensorFlow 目前在 conda-forge 仓库中。