DrewThomasson / ebook2audiobook

Generates an audiobook with chapters and ebook metadata using Calibre and Xtts from Coqui tts, and with optional voice cloning, and supports multiple languages
MIT License
795 stars 78 forks source link

numpy 2.0.0 breakage #5

Closed Rihcus closed 1 month ago

Rihcus commented 5 months ago

Recently numpy 2.0.0 was released and it seams to break a part of torch.

  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
/opt/conda/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: 
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

Downgrading to version 1.26.4 seems to fix issue for now

pip install numpy==1.26.4

DrewThomasson commented 5 months ago

Oh shoot thx for letting me know!

I'll get on modifying the install txt files to have that edit

👍⭐️

DrewThomasson commented 5 months ago

Which install method did you use also?

Edit: I managed to find that numpy wasn't included in the Mac or Ubuntu install txt files,

So I added "numpy==1.26.4" to them both

The others appeared to already have a older numpy so I left them unchanged lol

Rihcus commented 4 months ago

Which install method did you use also?

The ubuntu one?

I'm actually using this script on kaggle similar to colab

#!DEBIAN_FRONTEND=noninteractive
!sudo apt-get update # && sudo apt-get -y upgrade
!sudo apt-get -y install libegl1 
!sudo apt-get -y install libopengl0
!sudo apt-get -y install libxcb-cursor0
!sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin
!sudo apt-get install -y ffmpeg
!pip install tts pydub nltk beautifulsoup4 ebooklib tqdm
!pip install numpy==1.26.4

root@571ce3117db5


OS: Ubuntu 20.04.6 LTS x86_64 Host: Google Compute Engine Kernel: 5.15.133+ Uptime: 46 mins Packages: 725 (dpkg) Shell: bash 5.0.17 Terminal: jupyter-noteboo CPU: Intel Xeon (4) @ 2.000GHz GPU: NVIDIA Tesla T4 GPU: NVIDIA Tesla T4 Memory: 844MiB / 32110MiB

DrewThomasson commented 4 months ago

Sorry about the late response I'll see if your modification breaks the colab or not later,

If it does then I'll make a separate ipyb file for kaggel,

Or easier If you send the kaggel script your using to run it I'll just put that in the repo and readme on kaggel running info lol

Rihcus commented 4 months ago

Sorry about the late response I'll see if your modification breaks the colab or not later,

If it does then I'll make a separate ipyb file for kaggel,

Or easier If you send the kaggel script your using to run it I'll just put that in the repo and readme on kaggel running info lol

Here is the kaggle notebook (its not the most elegant thing).

https://github.com/Rihcus/ebook2audiobookXTTS/blob/main/kaggle-ebook2audiobook-demo.ipynb

I have made some changes to the code (In a attempt to enable multi gpu support) https://github.com/Rihcus/ebook2audiobookXTTS

Additionally the final step where ffmpeg combines the chapters is a bit buggy on kaggle. The sample book works but there have been times it crashes. I can replicate this bug locally on my mac.

Other notes p2a_worker_gpu1.py and p2a_worker_gpu2.py are basically the same only difference

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu")

https://github.com/Rihcus/ebook2audiobookXTTS/blob/e7c8e39e431d724c50f5dc0846e68268a2cc7b60/p2a_worker_gpu1.py#L322

https://github.com/Rihcus/ebook2audiobookXTTS/blob/e7c8e39e431d724c50f5dc0846e68268a2cc7b60/p2a_worker_gpu1.py#L322

p1.py, p2a_worker_gpu1.py and p2a_worker_gpu2.py, p3.py are basically a fragmented version of your code I commented out certain parts in each to selectivly run certain parts

https://github.com/Rihcus/ebook2audiobookXTTS/blob/e7c8e39e431d724c50f5dc0846e68268a2cc7b60/p1.py#L434

https://github.com/Rihcus/ebook2audiobookXTTS/blob/e7c8e39e431d724c50f5dc0846e68268a2cc7b60/p2a_worker_gpu1.py#L435

https://github.com/Rihcus/ebook2audiobookXTTS/blob/e7c8e39e431d724c50f5dc0846e68268a2cc7b60/p2a_worker_gpu2.py#L435

https://github.com/Rihcus/ebook2audiobookXTTS/blob/e7c8e39e431d724c50f5dc0846e68268a2cc7b60/p3.py#L434

DrewThomasson commented 1 month ago

AAAAA I remembered about this I'm SO SORRY 😭

Your kaggle requirements install still works amazingly with the current updated implementation of ebook2audiobookxtts +WEB GUI!!! 🎉

Please update, Then I will gladly merge your pull request! 🎉 😭

Also:

Dude I don't know how you fixed the issues with getting Coqio xtts working in Google Colab or kaggel but like, it freakin works lol.

I Might try using your fix thing to get my xtts fine tuning Google Colab updated and working later as well 🎉 😭

DrewThomasson commented 1 month ago

Re-opening this so I make sure not to forget before I get a response/update on this 😭

DrewThomasson commented 1 month ago

Link to Google Colab Notebook I Used to test your Kaggel script on

Google Colab Notebook

Rihcus commented 1 month ago

AAAAA I remembered about this I'm SO SORRY 😭

Your kaggle requirements install still works amazingly with the current updated implementation of ebook2audiobookxtts +WEB GUI!!! 🎉

* If you make your kaggel version GitHub repo up to date with mine so its mergable

* and make it so that it works with everything in the current state

* and put the new kaggle files if you can in a new folder in the repo named `/Notebooks`

Please update, Then I will gladly merge your pull request! 🎉 😭

* I'd love to get your name under the `Contributor list` on my repo 😭

Also:

Dude I don't know how you fixed the issues with getting Coqio xtts working in Google Colab or kaggel but like, it freakin works lol.

I Might try using your fix thing to get my xtts fine tuning Google Colab updated and working later as well 🎉 😭

Glad to here. Regarding updating kaggle repo recently it stopped working on kaggle (not sure its a dependency or a issue with my frankenstine modifications).

Given that your colab notebook works I might try using it as a base and adapting it to kaggle (it would make merging changes easier). Bit busy this week.

Also the current kaggle version I made isn't very user friendly I have a system where I upload the book to a kaggle private data repository and then run the notebook, download the output and run another script to merge book (ffmpeg gave me some issues).

DrewThomasson commented 1 month ago

Well my Google Colab just launches the gradio web interface with a public link

So all the stuff like giving it the ebook should work in the gradio interface

Rihcus commented 1 month ago

I synced the repo and added the Notebooks folder.

https://github.com/Rihcus/ebook2audiobookXTTS/tree/main/Notebooks

For colab made a small tweak:

  1. Added gradio dependency (colab was complaining it wasn't installed for me)

!pip install gradio

  1. Imported ntlk (not sure if its needed got an error without it) set xtts to auto accept (avoids having to type y to download xtts).
#ntlk error fix
#https://github.com/delip/PyTorchNLPBook/issues/14
import nltk
nltk.download('punkt')

#Auto agree to xtts
import os
os.environ["COQUI_TOS_AGREED"] = "1"

I have also added a kaggle version however kaggle is been acting very buggy.

When installing dependencies kaggles note book UI crashes for me in both chrome and firefox:

SCR-20241011-ilst

When I run the app.py cell kaggle starts up gratio then weirdly kills the program and shuts down the notebook (mentioning keyboard interrupt) currently not sure why :(

Running on local URL: http://172.19.2.2:7860
Running on local URL: http://localhost:7860
* Running on local URL:  http://0.0.0.0:7860
* Running on public URL: https://759c5f2bfe0dfd8e61.gradio.live

This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)
^C
Keyboard interruption in main thread... closing server.
Killing tunnel 0.0.0.0:7860 <> https://759c5f2bfe0dfd8e61.gradio.live
Kernel title updated to Kaggle BETA of ebook2audiobookxtts.ipynb
DrewThomasson commented 1 month ago

Seems it's Kaggel preventing tunneling is why for the public link:

"Many forms of tunneling are automatically banned to prevent misuse, including frp, I'll see if we can ease this for gradio."

People talking about the issue your seeing: https://www.kaggle.com/discussions/product-feedback/377918

DrewThomasson commented 1 month ago

I'll be closing this for now cause At least the Google Colab works lol,

At least headless mode seems to work on your Kaggle side 👍🎉