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

Tensorflow 兼容性测试-opencloudos

介绍

Tensorflow 兼容性测试: 测试 Tensorflow 各个版本在 OpenCloudOS Stream 的安装支持

操作系统

[root@lab101 ~]# cat /etc/os-release
NAME="OpenCloudOS Stream"
VERSION="23"
ID="opencloudos"
ID_LIKE="opencloudos"
VERSION_ID="23"
PLATFORM_ID="platform:ocs23"
PRETTY_NAME="OpenCloudOS Stream 23"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:opencloudos:opencloudos:23"
HOME_URL="https://www.opencloudos.org/"
BUG_REPORT_URL="https://bugs.opencloudos.tech/"
[root@lab101 ~]# uname -a
Linux lab101 6.6.6-2401.0.1.1.ocs23.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 18 09:42:48 CST 2024 x86_64 GNU/Linux

版本要求

当前的主要版本是TensorFlow 2

旧版 TensorFlow 1.x,CPU 和 GPU 软件包是分开的:

tensorflow==1.15:仅支持 CPU 的版本
tensorflow-gpu==1.15:支持 GPU 的版本(适用于 Ubuntu 和 Windows)

1.15是TensorFlow 1.x 的最终版本

安装测试

安装旧版本1.x

源里面已经没提供1.15版本

[root@lab101 ~]# pip3 install --user tensorflow==1.15
ERROR: Could not find a version that satisfies the requirement tensorflow==1.15 (from versions: 2.12.0rc0, 2.12.0rc1, 2.12.0, 2.12.1, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0, 2.15.0.post1, 2.15.1, 2.16.0rc0, 2.16.1, 2.16.2, 2.17.0rc0, 2.17.0rc1, 2.17.0)
ERROR: No matching distribution found for tensorflow==1.15

Tensorflow 1.15 需要运行

python <=3.7 to install Tensorflow 1.15

opencloudos上面的python版本为3.11,所以不支持这个版本

安装当前主线版本

安装最新版本的方法

pip3 install --user tensorflow -i https://mirrors.aliyun.com/pypi/simple/

当前的2.x版本有下面的版本,最新的版本为2.17.0

2.12.0 2.12.1 2.13.0 2.13.1 2.14.0 2.14.1 2.15.0 2.15.1 2.16.1 2.16.2 2.17.0

为了测试全部版本的兼容性,我们使用脚本进行遍历

#! /bin/bashfor version in `echo 2.12.0 2.12.1 2.13.0 2.13.1 2.14.0 2.14.1 2.15.0 2.15.1 2.16.1 2.16.2 2.17.0`
do
echo "正在测试$version版本"
echo "安装tensorflow==$version"
pip3 install --user tensorflow==$version   -i https://mirrors.aliyun.com/pypi/simple/
echo "测试tensorflow==$version"
python3 -c "import tensorflow as tf;print(tf.__version__);print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
echo "卸载tensorflow==$version"
done

检查输出的结果

[root@lab101 ~]# cat test.log |grep 测试ten -A 2
测试tensorflow==2.12.0
2.12.0
tf.Tensor(724.3179, shape=(), dtype=float32)
--
测试tensorflow==2.12.1
2.12.1
tf.Tensor(344.487, shape=(), dtype=float32)
--
测试tensorflow==2.13.0
2.13.0
tf.Tensor(-43.525192, shape=(), dtype=float32)
--
测试tensorflow==2.13.1
2.13.1
tf.Tensor(840.32227, shape=(), dtype=float32)
--
测试tensorflow==2.14.0
2.14.0
tf.Tensor(-1793.5032, shape=(), dtype=float32)
--
测试tensorflow==2.14.1
2.14.1
tf.Tensor(-1610.8185, shape=(), dtype=float32)
--
测试tensorflow==2.15.0
2.15.0
tf.Tensor(-455.57336, shape=(), dtype=float32)
--
测试tensorflow==2.15.1
2.15.1
tf.Tensor(847.0481, shape=(), dtype=float32)
--
测试tensorflow==2.16.1
2.16.1
tf.Tensor(-1371.9381, shape=(), dtype=float32)
--
测试tensorflow==2.16.2
2.16.2
tf.Tensor(1536.6016, shape=(), dtype=float32)
--
测试tensorflow==2.17.0
2.17.0
tf.Tensor(-1663.6276, shape=(), dtype=float32)

可以看到,全部都可以运行输出,测试验证安装的方法为官网给出的方法

补充

如果自己编译安装python3.7,看是否能支持tensorflow的1.15版本

[root@lab101 python-3.7.7]# python3.7  /usr/local/bin/pip3.7  install --user tensorflow==1.15  -i https://mirrors.aliyun.com/pypi/simple/

运行报错

    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:1. Downgrade the protobuf package to 3.20.x or lower.2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

处理

python3.7  /usr/local/bin/pip3.7  install --user  protobuf==3.20.*  -i https://mirrors.aliyun.com/pypi/simple/

运行

export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
[root@lab101 python-3.7.7]# python3.7 -c "import tensorflow as tf;print(tf.__version__);print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
1.15.0
Tensor("Sum:0", shape=(), dtype=float32)

没报错了,但是结果感觉不对,应该还是版本兼容性问题,建议使用2.x版本

兼容性列表

tensorflow版本是否兼容备注
1.15不支持要求python3<=python3.7(os python 3.11)
2.12.0支持
2.12.1支持
2.13.0支持
2.13.1支持
2.14.0支持
2.14.1支持
2.15.0支持
2.15.1支持
2.16.1支持
2.16.2支持
2.17.0支持

http://www.mrgr.cn/news/25123.html

相关文章:

  • Mongoose OverwriteModelError: Cannot overwrite `note` model once compiled.
  • 使用API有效率地管理Dynadot域名,查看域名服务器(NS)信息
  • 量化交易backtrader实践(一)_数据获取篇(3)_爬取数据
  • wifiip地址可以随便改吗?wifi的ip地址怎么改变
  • 不会写招加盟商广告语的品牌看过来,实用的文案模版!
  • Rust的常量
  • QT QSystemTrayIcon创建系统托盘区图标失败
  • ActiViz中的vtkActor2D基本用法
  • 万字长文解析:计算机视觉领域的目标检测与图像分割(不断更新)
  • 50.【C语言】字符函数和字符串函数(上)
  • 基于vue框架的宠爱有佳宠物医疗管理系统4x10z(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。
  • 前端面试常见手写题
  • Unity Apple Vision Pro 开发(十):通过图像识别锚定空间
  • 怎么设置电脑禁止访问网页/网站?一分钟教你五个方法,实现网站访问黑名单,让员工专注力满满!
  • Linux创建虚拟磁盘并分区格式化
  • 无人机低空安全管控系统技术详解
  • JDBC API详解一
  • 宏任务和微任务+超全面试真题
  • 时尚穿搭想换就换,各种风格一键完美搭配!亲测在线虚拟试衣换装平台效果超赞!
  • 一些了解WEB API的相关知识点的学习