Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS - Safari session issue, high memory consumption (on local run), low docker performance #414

Open
divin31 opened this issue Mar 4, 2025 · 9 comments
Labels
Docker Related to docker

Comments

@divin31
Copy link

divin31 commented Mar 4, 2025

This is just a rudimentary guide, don't be too intimidated, You don't have to follow this to the tee
BEFORE TO OPEN AN ISSUE, MAKE SURE THAT IT HASN'T ALREADY BEEN SOLVED OR REPORTED. :)
Check it with the issue search field

Script Mode

  • Native & Docker

Process Mode

  • Gradio GUI

Command Line (headless mode only)

  • provide the exact command line

Operating System:

  • MacOS

Describe the bug
I have tried running it both in docker and locally.
Platform: M4 pro 24 GB RAM
Book: George Orwell - Animal Farm epub Language: ENG -> Hungarian
Processor Unit: MPS
Every other setting left on default.

In docker, it used about 8% CPU (total) | 1 core, and below 4 GB of memory.
Left it running for 30 minutes, but it only did a few percents, so I stopped the container.
Pressing x did not stop container CPU and memory utilization.

I'm currently testing it locally. Finished 5% in 750 seconds. The process: python3.12 is using ~150% CPU, above 32 GB of memory.
In Safari, the session seems bugged. Bottom progress bar disappeared and Error appeared. The loading animation appeared in the file box and it's counting the seconds there.
After refreshing the page, the "Select a file" box is back to normal, however bottom progress bar didn't resume

My other containers are using ~11 GB, so it's swapping heavily. Memory pressure almost always in the yellow. Swap used is ~20 GB.

Terminal log

Update:
Docker attempt nr2 with a shorter epub:

Image

/home/user/.local/lib/python3.12/site-packages/ebooklib/epub.py:1423: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version.  If you rely on the current behaviour, change it to './/xmlns:rootfile[@media-type]'
  for root_file in tree.findall('//xmlns:rootfile[@media-type]', namespaces={'xmlns': NAMESPACES['CONTAINERNS']}):
IPs available for connection:
['127.0.0.1', '::1', '192.168.216.2']
Note: 0.0.0.0 is not the IP to connect. Instead use an IP above to connect.
* Running on local URL:  http://0.0.0.0:7860/
To create a public link, set `share=True` in `launch()`.
Processing eBook file: Tablo_Publishing-Reviewing_E-Sports_in_2021-2021.epub
Available Processor Unit: cpu
Running command: /usr/bin/ebook-convert /home/user/app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/15f13fba1764e5acd41f69d755678fed/Tablo_Publishing-Reviewing_E-Sports_in_2021-2021.epub /home/user/app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/15f13fba1764e5acd41f69d755678fed/__Tablo_Publishing-Reviewing_E-Sports_in_2021-2021.epub --input-encoding=utf-8 --output-profile=generic_eink --verbose
Conversion options changed from defaults:
  output_profile: 'generic_eink'
  input_encoding: 'utf-8'
  verbose: 1
1% Converting input to HTML...
InputFormatPlugin: EPUB Input running
on /home/user/app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/15f13fba1764e5acd41f69d755678fed/Tablo_Publishing-Reviewing_E-Sports_in_2021-2021.epub
Parsing all content...
Parsing OEBPS/46ade8f8-29e3-475f-a0ee-0e2b6748222f.xhtml ...
Parsing OEBPS/nav.xhtml ...
Parsing OEBPS/styles.css ...
Reading TOC from NCX...
34% Running transforms on e-book...
Merging user specified metadata...
Detecting structure...
	Detected chapter: Chapter 1
Flattening CSS and remapping font sizes...
Source base font size is 12.00000pt
Removing fake margins...
Found 22 items of level: p_1
Ignoring level p_1
Cleaning up manifest...
Trimming unused files from manifest...
Trimming 'OEBPS/nav.xhtml' from manifest
Trimming 'OEBPS/toc.ncx' from manifest
Creating EPUB Output...
67% Running EPUB Output plugin
Splitting markup on page breaks and flow limits, if any...
	Looking for large trees in OEBPS/46ade8f8-29e3-475f-a0ee-0e2b6748222f.xhtml...
	No large trees found
Generating default cover
EPUB output written to /home/user/app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/15f13fba1764e5acd41f69d755678fed/__Tablo_Publishing-Reviewing_E-Sports_in_2021-2021.epub
Output saved to   /home/user/app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/15f13fba1764e5acd41f69d755678fed/__Tablo_Publishing-Reviewing_E-Sports_in_2021-2021.epub
******* NOTE: YOU CAN SAFELY IGNORE "Character xx not found in the vocabulary." *******
Loading TTS tts_models/multilingual/multi-dataset/xtts_v2 model, it takes a while, please be patient...

convertsion 0.00%: 0/34 [W304 16:31:08.486213999 NNPACK.cpp:62] Could not initialize NNPACK! Reason: Unsupported hardware.

After getting stuck, the hardware utilization persists

Image

Update2:

Using local run, I copied the session id to Firefox while converting is in progress.
In both instances the bottom progress bar doesn't show the status

Image
@ROBERT-MCDOWELL ROBERT-MCDOWELL added the Docker Related to docker label Mar 4, 2025
@DrewThomasson
Copy link
Owner

DrewThomasson commented Mar 4, 2025

Related:

Currently attempting a universal dockerfile that builds for ARM and x86

PR: #413

@DrewThomasson
Copy link
Owner

Update: Universal arm dockerfile created successfully,

Will be merged into main soon,

Details: #422

@divin31
Copy link
Author

divin31 commented Mar 9, 2025

I have done some testing.
Docker image is now working with good CPU utilization, using up to ~8 cores.
Memory utilization is still capped at ~4 GB.
Also unlike CPU usage, memory doesn't get freed up once the processing is finished.

Image

Session still seem bugged:

  • After processing is complete, file doesn't appear for download
  • Weird time counter in the bottom right corner after a new task is started
  • Progress bar doesn't show when page is refreshed or opened from another page/browser
  • Pressing 'x' on the ebook, does not cancel the process
Image

Update:
Tested adding two more ebooks.
First I repeated adding the same ebook as previous time that didn't appear for download, and this time it appeared.
Then I added a different ebook, which resulted in the following error in logs:

Converting 2.94%:   6% 2/34 [00:48<12:44, 23.90s/step]
Converting 5.88%:   6% 2/34 [01:14<12:44, 23.90s/step]
Sentence: It has earned a huge success and reached new heights over the past decade . The eSports provide an organized and competitive video gaming platform .

Converting 5.88%:   9% 3/34 [01:14<12:41, 24.58s/step]
Converting 5.88%:   9% 3/34 [01:33<16:02, 31.06s/step]
Failed to open dst: /app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/593980caa2d95de2e4cfa84613c5ad0b/chapters/sentences/3.flac (No such file or directory)
Traceback (most recent call last):
  File "/app/lib/classes/tts_manager.py", line 351, in convert_sentence_to_audio
    torchaudio.save(self.params['sentence_audio_file'], audio_tensor, sample_rate, format=default_audio_proc_format)
  File "/usr/local/lib/python3.12/site-packages/torchaudio/_backend/utils.py", line 313, in save
    return backend.save(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/torchaudio/_backend/ffmpeg.py", line 316, in save
    save_audio(
  File "/usr/local/lib/python3.12/site-packages/torchaudio/_backend/ffmpeg.py", line 256, in save_audio
    with s.open():
         ^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/torio/io/_streaming_media_encoder.py", line 436, in open
    self._s.open(option)
RuntimeError: Failed to open dst: /app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/593980caa2d95de2e4cfa84613c5ad0b/chapters/sentences/3.flac (No such file or directory)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/lib/functions.py", line 695, in convert_chapters_to_audio
    if tts_manager.convert_sentence_to_audio():
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/classes/tts_manager.py", line 363, in convert_sentence_to_audio
    raise ValueError(e)
ValueError: Failed to open dst: /app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/593980caa2d95de2e4cfa84613c5ad0b/chapters/sentences/3.flac (No such file or directory)
Caught DependencyError: Failed to open dst: /app/tmp/ebook-096b1a5c-652b-4f62-90fb-24023c85ba5d/593980caa2d95de2e4cfa84613c5ad0b/chapters/sentences/3.flac (No such file or directory)
convert_chapters_to_audio() failed!

@ROBERT-MCDOWELL
Copy link
Collaborator

Progress bar doesn't show when page is refreshed or opened from another page/browser

this is browser limitation, if you refresh you disconnect from the gradio socket and the only way to connect is to reload the ebook if not already and click on the convert button to resume.

Pressing 'x' on the ebook, does not cancel the process

does it show the modal "cancellation requested"? or did you click on "X" after the refresh?

@divin31
Copy link
Author

divin31 commented Mar 9, 2025

this is browser limitation, if you refresh you disconnect from the gradio socket and the only way to connect is to reload the ebook if not already and click on the convert button to resume.

If press the convert button on a different page, the progress bar still doesn't reappear. Only the queue.

does it show the modal "cancellation requested"? or did you click on "X" after the refresh?

I clicked before reloading. The file immediately disappears from the box, bottom progress bar keeps loading.

@ROBERT-MCDOWELL
Copy link
Collaborator

If press the convert button on a different page, the progress bar still doesn't reappear. Only the queue.

did you wait until the progress bar appears as to resume is like to restart a full process?

I clicked before reloading. The file immediately disappears from the box, bottom progress bar keeps loading.

ok but is the modal (an alert telling you to wait) appears or not?

@divin31
Copy link
Author

divin31 commented Mar 9, 2025

ok but is the modal (an alert telling you to wait) appears or not?

No alert appeared. Progress bar (%) remains active.

Image

I did a few more attempts, and realized it happens only if I connect through a different tab or refresh the page.
So I start converting in tab 1, access the site in tab 2 (without doing anything else), go back to tab 1, and x no longer works.

did you wait until the progress bar appears as to resume is like to restart a full process?

After refreshing the page or opening new tab, sometimes I see a loading bar that doesn't do anything once it's finished, the initial process bar (showing the % of completion) never reappears.

Image

@ROBERT-MCDOWELL
Copy link
Collaborator

ROBERT-MCDOWELL commented Mar 9, 2025

as I said, it's not a eb2ab issue/ the browsers stop the tab activities when not focused to save cpu/power etc...
so when back, of course it's disconnected from gradio socket.
but if you select the same ebook/text file it will automatically resume the conversion, but you must wait the reinitialization like loading the model etc...
also you need to provide the full terminal logs to get some coding informations. without it, no help is possible

@DrewThomasson
Copy link
Owner

DrewThomasson commented Mar 9, 2025

oh yeah forgot to mention the latest docker image has a ARM version now so anyone running this on ARM should delete the x86 docker image so then docker will pull the ARM version instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docker Related to docker
Projects
None yet
Development

No branches or pull requests

3 participants