tensorflow安装
时间: 2023-06-21 21:16:57 浏览: 59
以下是在 Windows 系统上安装 TensorFlow 的步骤:
1. 安装 Anaconda
Anaconda 是一个 Python 发行版,包含了许多科学计算所需的库和工具,可以简化 TensorFlow 的安装过程。在 Anaconda 官网上下载适合自己系统的安装包,安装时选择添加 Anaconda 到系统 PATH 环境变量。
2. 创建虚拟环境
在命令行中输入以下命令创建一个 Python 3.7 版本的虚拟环境:
```
conda create -n tensorflow python=3.7
```
3. 激活虚拟环境
在命令行中输入以下命令激活刚才创建的虚拟环境:
```
conda activate tensorflow
```
4. 安装 TensorFlow
在命令行中输入以下命令安装 TensorFlow:
```
pip install tensorflow
```
5. 测试 TensorFlow
在 Python 解释器中输入以下代码测试 TensorFlow 是否安装成功:
```
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant('Hello, TensorFlow!')
sess = tf.compat.v1.Session()
print(sess.run(hello))
```
如果输出结果为 `b'Hello, TensorFlow!'`,则说明 TensorFlow 安装成功。
注意:以上步骤仅适用于 Windows 系统,其他操作系统安装 TensorFlow 的步骤可能会有所不同。
相关推荐
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)