Help with textgenrnn module

Question:
I discovered a Python module called textgenrnn to help with machine learning. I followed the instructions on several websites but I’m getting errors and I don’t know what to do.
Repl link:
https://replit.com/@CoderElijah/CoderElijah-AI

from textgenrnn import textgenrnn
textgen = textgenrnn()
textgen.train_from_file('shakespeare.txt', num_epochs=10)
textgen.generate(5)

The error:

2023-04-11 15:49:19.225931: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /nix/store/mdck89nsfisflwjv6xv8ydj7dj0sj2pn-gcc-11.3.0-lib/lib:/nix/store/026hln0aq1hyshaxsdvhg0kmcm6yf45r-zlib-1.2.13/lib:/nix/store/2k366jrbsra97gjfxwvrhvixjfxdach5-glib-2.74.1/lib:/nix/store/w3zzhfl4a7xp0xfflz2gawv02y8ba9z8-libX11-1.8.1/lib:/nix/store/hisqvx32cd57apbpcsnkpx6k3549wql1-libglvnd-1.4.0/lib:/nix/store/p36pgcv991mq5srvg765b78yqpxvk3qs-mesa-21.3.3-drivers/lib:/nix/store/mav4251if1ahjq5vkpwycyyvnmy459c4-pulseaudio-14.2/lib
2023-04-11 15:49:19.225976: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    from textgenrnn import textgenrnn
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/textgenrnn/__init__.py", line 1, in <module>
    from .textgenrnn import textgenrnn
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/textgenrnn/textgenrnn.py", line 1, in <module>
    from tensorflow.keras.callbacks import LearningRateScheduler, Callback
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/python/__init__.py", line 37, in <module>
    from tensorflow.python.eager import context
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/python/eager/context.py", line 29, in <module>
    from tensorflow.core.framework import function_pb2
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/core/framework/function_pb2.py", line 16, in <module>
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
    from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 36, in <module>
    _descriptor.FieldDescriptor(
  File "/home/runner/CoderElijah-AI/venv/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 561, in __new__
    _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).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

poetry add protobuf==3.20.x gets this:

2023-04-11 15:54:25.443282: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /nix/store/mdck89nsfisflwjv6xv8ydj7dj0sj2pn-gcc-11.3.0-lib/lib:/nix/store/026hln0aq1hyshaxsdvhg0kmcm6yf45r-zlib-1.2.13/lib:/nix/store/2k366jrbsra97gjfxwvrhvixjfxdach5-glib-2.74.1/lib:/nix/store/w3zzhfl4a7xp0xfflz2gawv02y8ba9z8-libX11-1.8.1/lib:/nix/store/hisqvx32cd57apbpcsnkpx6k3549wql1-libglvnd-1.4.0/lib:/nix/store/p36pgcv991mq5srvg765b78yqpxvk3qs-mesa-21.3.3-drivers/lib:/nix/store/mav4251if1ahjq5vkpwycyyvnmy459c4-pulseaudio-14.2/lib
2023-04-11 15:54:25.443332: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    from textgenrnn import textgenrnn
  File "/home/runner/CoderElijah-AI2/venv/lib/python3.10/site-packages/textgenrnn/__init__.py", line 1, in <module>
    from .textgenrnn import textgenrnn
  File "/home/runner/CoderElijah-AI2/venv/lib/python3.10/site-packages/textgenrnn/textgenrnn.py", line 5, in <module>
    from tensorflow.keras.utils import multi_gpu_model
ImportError: cannot import name 'multi_gpu_model' from 'tensorflow.keras.utils' (/home/runner/CoderElijah-AI2/venv/lib/python3.10/site-packages/keras/api/_v2/keras/utils/__init__.py)

https://replit.com/@CoderElijah/CoderElijah-AI2

Do I need a GPU for my Repl? Is that free?

I don’t think a GPU is free (it used to be free as a beta features, but now it’s 350🌀/day I think), it likely requires one as most methods for training involve a GPU.
If you don’t want to pay, you could check out Google Colaboratory

2 Likes