运行预设模型时keras-nlp和tensorflow之间的依赖问题

问题描述 投票:0回答:1

我正在尝试遵循 keras-nlp 的一些示例代码来使用预训练的内置 BERT 模型。

bert_classifier = keras_nlp.models.BertClassifier.from_preset("bert_tiny_en_uncased")

但是,我对所需软件包(keras-npl、keras、tensorflow、tensorflow-text 和 tensorflow-intel)的依赖项和版本有一些困难。

启动新的虚拟环境并运行

pip install --upgrade keras-nlp
pip install --upgrade keras>=3
PIP 返回错误消息:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.10.1 requires keras<2.11,>=2.10.0, but you have keras 3.0.4 which is incompatible.

使用

pip install --upgrade tensorflow
将tensorflow升级到版本2.15会安装keras 2(并删除keras 3),并给出新的PIP依赖性错误消息:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-text 2.10.0 requires tensorflow<2.11,>=2.10.0; platform_machine != "arm64" or platform_system != "Darwin", but you have tensorflow 2.15.0 which is incompatible.

我尝试安装特定版本的 keras-npl、keras、tensorflow、tensorflow-text 和 tensorflow-intel。无论我做什么,在运行示例 python 脚本时,我都会遇到 PIP 中的依赖性问题和错误消息。网站 https://pypi.org/project/keras-nlp/https://keras.io/getting_started/ 无法为我澄清这个问题。

我需要所有这些软件包的哪些版本,或者我应该按什么顺序安装它们?

tensorflow keras pip dependencies
1个回答
0
投票

但是,我对依赖项和版本有一些困难 所需的软件包(keras-npl、keras、tensorflow、 张量流文本和张量流英特尔)。

在处理多个软件包及其版本时,可能是一项具有挑战性的任务。但是,关于如何解决这些依赖冲突的一些指导。

注意:-不同版本的软件包可能有特定的兼容性要求。

所以,您遇到了 TensorFlow、Keras、tensorflow-text 和 keras-nlp 之间的冲突

首先,您需要找到

TensorFlow, Keras, TensorFlow Text
的兼容版本,以及任何其他可以很好地协同工作的所需软件包。

兼容版本文档

安装与 keras-nlp 和 tensorflow-text 兼容的特定版本的 TensorFlow。

使用此示例命令:-

pip安装tensorflow==2.10.0

安装 keras-nlp 和 keras:

pip 安装 keras-nlp keras

安装tensorflow-text:

pip 安装tensorflow-text==2.10.0

安装所有依赖项且没有冲突后,请尝试再次执行示例 Python 脚本以验证它是否按预期运行。

© www.soinside.com 2019 - 2024. All rights reserved.