Python + Tensorflow ImportError: cannot import name 'rewriter_config_pb2' from 'tensorflow.core.protobuf' (unknown location)

постоянно какие-то ошибки именно из-за Tensorflow. Сейчас вылезает эта ошибка.

(AITGbot) D:\AITGbot\telegram_bot>python main.py Traceback (most recent call last): File "D:\AITGbot\telegram_bot\main.py", line 5, in import gpt_2_simple as gpt2 File "D:\AITGbot\Anaconda\envs\AITGbot\lib\site-packages\gpt_2_simple_init_.py", line 1, in from .gpt_2 import * File "D:\AITGbot\Anaconda\envs\AITGbot\lib\site-packages\gpt_2_simple\gpt_2.py", line 11, in from tensorflow.core.protobuf import rewriter_config_pb2 ImportError: cannot import name 'rewriter_config_pb2' from 'tensorflow.core.protobuf' (unknown location)



import telebot
import tensorflow as tf 
import gpt_2_simple as gpt2

# Создаем экземпляр бота
bot = telebot.TeleBot('SECRET')

# Создаю модель GPT-2
gpt2.download_gpt2(model_name="124M")
sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess, model_name="124M", model_dir="models")

# Функция для генерации ответа через GPT-2
def generate_response(input_text):
   with sess.as_default():
      response = gpt2.generate(sess, model_name='124M', prefix=input_text)
      return response

# Функция, обрабатывающая команду /start
@bot.message_handler(commands=["start"])
def start(m, res=False):
    bot.send_message(m.chat.id, 'Я на связи. Напиши мне что-нибудь :)')

# Получение сообщений от юзера
@bot.message_handler(content_types=["text"])
def handle_text(message):
    user_input = message.text
    response = generate_response(user_input)
    bot.send_message(message.chat.id, response)

# Запуск TensorFlow и создание графа
tf.compat.v1.reset_default_graph()
graph = tf.compat.v1.get_default_graph()


# Запускаем бота
bot.polling(none_stop=True, interval=0)

Windows 10, виртуальная среда Anaconda, Процессор: AMD A6-3620 APU with Radeon(tm) HD Graphics 2.20 GHz

Зависимости:

Package                      Version
---------------------------- -------------------
absl-py                      2.0.0
astor                        0.8.1
astunparse                   1.6.3
bleach                       1.5.0
cachetools                   5.3.2
certifi                      2023.11.17
charset-normalizer           3.3.2
colorama                     0.4.6
filelock                     3.13.1
flatbuffers                  23.5.26
fsspec                       2023.10.0
gast                         0.5.4
google-auth                  2.23.4
google-auth-oauthlib         1.1.0
google-pasta                 0.2.0
gpt-2-simple                 0.8.1
grpcio                       1.59.3
h5py                         3.10.0
html5lib                     0.9999999
idna                         3.6
Jinja2                       3.1.2
keras                        2.15.0
Keras-Applications           1.0.8
Keras-Preprocessing          1.1.2
libclang                     16.0.6
Markdown                     3.5.1
MarkupSafe                   2.1.3
ml-dtypes                    0.2.0
mpmath                       1.3.0
networkx                     3.2.1
numpy                        1.26.2
oauthlib                     3.2.2
opt-einsum                   3.3.0
packaging                    23.2
pip                          23.3.1
protobuf                     4.23.4
pyasn1                       0.5.1
pyasn1-modules               0.3.0
pyTelegramBotAPI             4.14.0
regex                        2023.10.3
requests                     2.31.0
requests-oauthlib            1.3.1
rsa                          4.9
setuptools                   68.0.0
six                          1.16.0
sympy                        1.12
telebot                      0.0.5
tensorboard                  2.15.1
tensorboard-data-server      0.7.2
tensorboard-plugin-wit       1.8.1
tensorflow                   2.15.0
tensorflow-estimator         2.15.0
tensorflow-intel             2.15.0
tensorflow-io-gcs-filesystem 0.31.0
termcolor                    2.3.0
tf-estimator-nightly         2.8.0.dev2021122109
toposort                     1.10
torch                        2.1.1
tqdm                         4.66.1
typing_extensions            4.8.0
urllib3                      2.1.0
Werkzeug                     3.0.1
wheel                        0.41.2
wrapt                        1.14.1

Tensorflow:

Name: tensorflow
Version: 2.15.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: d:\aitgbot\anaconda\envs\aitgbot\lib\site-packages
Requires: tensorflow-intel
Required-by: gpt-2-simple

Я ставил разные версии tensorflow, включая 1.6.0 с гитхаба, однако получаю море ошибок, что gpt2 требует более высокую версию и что tensorboard требует большую версию tensorflow.


Ответы (0 шт):