Hi,大家好,我是源于花海。要让一个基于 CPU 的 tensorflow 和 keras 开发的深度学习模型正确运行起来,配置环境是个重要的问题,本文介绍了 tensorflow keras 和对应的 python 版本以及安装环境的部分流程。


目录

一、tensorflow + keras + python 版本对照

二、tensorflow 和 keras 安装流程


一、tensorflow + keras + python 版本对照

详情看 tensorflow 官网链接如下:

​​​​​​Build from source on Windows  |  TensorFlow (google.cn)

FrameworkPython versionDescription
TensorFlow 2.93.7.-3.10.TensorFlow 2.9.0 + Keras
TensorFlow 2.83.7.-3.10.TensorFlow 2.8.0 + Keras
TensorFlow 2.73.7.-3.9.TensorFlow 2.7.0 + Keras
TensorFlow 2.63.6.-3.9.TensorFlow 2.6.0 + Keras 2.6.0
TensorFlow 2.53.6.-3.9.TensorFlow 2.5.0 + Keras 2.5
TensorFlow 2.43.6.-3.8.TensorFlow 2.4.0 + Keras 2.4.3
TensorFlow 2.33.5.-3.8.TensorFlow 2.3.0 + Keras 2.4.3
TensorFlow 2.23.7.TensorFlow 2.2.0 + Keras 2.3.1
TensorFlow 2.13.6.TensorFlow 2.1.0 + Keras 2.3.1
TensorFlow 2.03.6.TensorFlow 2.0.0 + Keras 2.3.1
TensorFlow 1.153.6.TensorFlow 1.15.0 + Keras 2.3.1
TensorFlow 1.143.6.TensorFlow 1.14.0 + Keras 2.2.5
TensorFlow 1.133.6.TensorFlow 1.13.0 + Keras 2.2.4
TensorFlow 1.123.6.TensorFlow 1.12.0 + Keras 2.2.4
2.TensorFlow 1.12.0 + Keras 2.2.4
TensorFlow 1.113.6.TensorFlow 1.11.0 + Keras 2.2.4
2.TensorFlow 1.11.0 + Keras 2.2.4
TensorFlow 1.103.6.TensorFlow 1.10.0 + Keras 2.2.0
2.TensorFlow 1.10.0 + Keras 2.2.0
TensorFlow 1.93.6.TensorFlow 1.9.0 + Keras 2.2.0
2.TensorFlow 1.9.0 + Keras 2.2.0
TensorFlow 1.83.6.TensorFlow 1.8.0 + Keras 2.1.6
2.TensorFlow 1.8.0 + Keras 2.1.6
TensorFlow 1.73.6.TensorFlow 1.7.0 + Keras 2.1.6
2.TensorFlow 1.7.0 + Keras 2.1.6
TensorFlow 1.53.6.TensorFlow 1.5.0 + Keras 2.1.6
2.TensorFlow 1.5.0 + Keras 2.0.8
TensorFlow 1.43.6.TensorFlow 1.4.0 + Keras 2.0.8
2.TensorFlow 1.4.0 + Keras 2.0.8
TensorFlow 1.33.6.TensorFlow 1.3.0 + Keras 2.0.6
2.TensorFlow 1.3.0 + Keras 2.0.6

二、tensorflow 和 keras 安装流程

这里安装 python=3.8,tensorflow=2.4.0,keras=2.4.3(segnet 是我做的语义分割项目的虚拟环境)若需要将创建的虚拟环境添加到 jupyter lab/notebook 中使用,则需要第 3 - 6 步,否则不用

# 1. Anaconda 创建虚拟环境
conda create -n segnet python=3.8
# 2. 激活并进入虚拟环境
activate segnet
# 3. 安装 ipykernel 
pip install ipykernel -i https://pypi.tuna.tsinghua.edu.cn/simple/
# 4. 安装ipykernel,将虚拟环境加入 jupyter 内核中
python -m ipykernel install --name segnet --display-name segnet
# 5. 检查新虚拟环境是否成功加入内核
jupyter kernelspec list
# 6. 从指定文件夹里进入 jupyter
jupyter lab
# 7. 安装 tensorflow、keras 等软件包
pip install tensorflow=2.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install keras=2.4.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
------------------------------------------------------------------------
pip install matplotlib=3.4.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install numpy=1.19.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pillow=10.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install scipy=1.7.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐