当前位置: 首页 > news >正文

tensorflow-cpu

python3.8~3.12安装tensorflow-cpu

准备

创建并进入目录

mkdir tf-cpu
cd tf-cpu

编写测试代码

test_tensorflow.py

import tensorflow as tf# 检查TensorFlow版本
print("\nTensorFlow version:", tf.__version__,end='\n\n')# 创建一个简单的计算图并运行它
tensor = tf.constant([[1, 2], [3, 4]])
result = tf.multiply(tensor, 2)# 启动默认的TensorFlow会话(自TensorFlow 2.x起,推荐使用tf.function和eager execution)
if hasattr(tf, 'Session'):  # TensorFlow 1.x风格with tf.Session() as sess:output = sess.run(result)print("Output of multiplication:", output)
else:  # TensorFlow 2.x风格,默认启用eager executionoutput = result.numpy()  # 将Tensor转换为NumPy数组以查看结果print("Output of multiplication:\n", output)

python3.12 tensorflow

创建虚拟环境

python312 -m venv tf219-312

windows

cd tf219-312/Scripts
activate
cd ../../

linux

source tf219-312/bin/activate

升级pip版本

python -m pip install --upgrade pip

搜索可用版本

pip index versions tensorflow-cpu
pip index versions tensorflow-intel

安装指定版本

pip install tensorflow-cpu==2.19.0

intel优化版本可以执行以下命令

pip install tensorflow-intel==2.18.0

测试

python test_tensorflow.py

取消激活环境

windows

cd tf219-312/Scripts
deactivate
cd ../../

linux

source tf219-312/bin/deactivate

python3.11 tensorflow

创建虚拟环境

python311 -m venv tf219-311

windows

cd tf219-311/Scripts
activate
cd ../../

linux

source tf219-311/bin/activate

升级pip版本

python -m pip install --upgrade pip

搜索可用版本

pip index versions tensorflow-cpu
pip index versions tensorflow-intel

安装指定版本

pip install tensorflow-cpu==2.19.0

intel优化版本可以执行以下命令

pip install tensorflow-intel==2.18.0

测试

python test_tensorflow.py

取消激活环境

windows

cd tf219-311/Scripts
deactivate
cd ../../

linux

source tf219-311/bin/deactivate

python3.10 tensorflow

创建虚拟环境

python310 -m venv tf219-310

windows

cd tf219-310/Scripts
activate
cd ../../

linux

source tf219-310/bin/activate

升级pip版本

python -m pip install --upgrade pip

搜索可用版本

pip index versions tensorflow-cpu
pip index versions tensorflow-intel

安装指定版本

pip install tensorflow-cpu==2.19.0

intel优化版本可以执行以下命令

pip install tensorflow-intel==2.18.0

测试

python test_tensorflow.py

取消激活环境

windows

cd tf219-310/Scripts
deactivate
cd ../../

linux

source tf219-310/bin/deactivate

python3.9 tensorflow

创建虚拟环境

python39 -m venv tf219-39

windows

cd tf219-39/Scripts
activate
cd ../../

linux

source tf219-39/bin/activate

升级pip版本

python -m pip install --upgrade pip

搜索可用版本

pip index versions tensorflow-cpu
pip index versions tensorflow-intel

安装指定版本

pip install tensorflow-cpu==2.19.0

intel优化版本可以执行以下命令

pip install tensorflow-intel==2.18.0

测试

python test_tensorflow.py

取消激活环境

windows

cd tf219-39/Scripts
deactivate
cd ../../

linux

source tf219-39/bin/deactivate

python3.8 tensorflow2.13

创建虚拟环境

D:\dev\python\Python38\python.exe -m venv tf213-38

windows

cd tf213-38/Scripts
activate
cd ../../

linux

source tf213-38/bin/activate

升级pip版本

python -m pip install --upgrade pip

搜索可用版本

pip index versions tensorflow-cpu
pip index versions tensorflow-intel

安装指定版本

pip install tensorflow-cpu==2.13.0

intel优化版本可以执行以下命令

pip install tensorflow-intel==2.13.0

测试

python test_tensorflow.py

取消激活环境

windows

cd tf213-38/Scripts
deactivate
cd ../../

linux

source tf213-38/bin/deactivate

相关文章:

  • tabs切换#
  • git|gitee仓库同步到github
  • PyCharm 快捷键指南
  • 基于Qt6 + MuPDF在 Arm IMX6ULL运行的PDF浏览器——MuPDF Tools
  • Spring Boot集成RabbitMQ高级篇:可靠性与性能提升
  • 面试题:请解释Java中的设计模式,并举例说明单例模式(Singleton Pattern)的实现方式
  • 解决WSL、Ubuntu的.ico图标不正确显示缩略图
  • 解决IDEA Maven编译时@spring.profiles.active@没有替换成具体环境变量的问题
  • 将本地文件上传到云服务器上
  • Redis+Caffeine构建高性能二级缓存
  • 数据出境的安全合规思考
  • 蓝桥杯13届国赛 2022
  • Java设计模式之代理模式:从入门到精通(保姆级教程)
  • 我开源了一个免费在线工具!UIED Tools
  • 【Jenkins简单自动化部署案例:基于Docker和Harbor的自动化部署流程记录】
  • 【现代深度学习技术】注意力机制05:多头注意力
  • AIGC时代的内容安全:AI检测技术如何应对新型风险挑战?
  • 国产密码新时代!华测国密 SSL 证书解锁安全新高度
  • 鸿蒙 UIAbility组件与UI的数据同步和窗口关闭
  • 【C++】”如虎添翼“:模板初阶
  • 广东韶关一镇干部冲进交通事故火海救人,获授“见义勇为”奖励万元
  • 中国人民抗日战争暨世界反法西斯战争胜利80周年纪念活动标识发布
  • 国羽用冠军开启奥运周期,林丹:希望洛杉矶奥运取得更好成绩
  • 重庆三峡学院回应“85万元中标设备,网购价不到300元”:已着手解决
  • 著名文物鉴赏家吴荣光逝世,享年78岁
  • “行人相撞案”现场视频公布,法院:表述不当造成误导