Fooocus icon indicating copy to clipboard operation
Fooocus copied to clipboard

python lzma exception

Open Peppe289 opened this issue 2 years ago • 2 comments

Read Troubleshoot

[x] I admit that I have read the Troubleshoot before making this issue.

Describe the problem I started fooocus on cloud computing linux with CPU. I used the ['--share', '--always-cpu', '--attention-split'] flags to use only the CPU, but the error regarding lzma appeared:

  File "/home/<User>/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/datasets/utils.py", line 6, in <module>
    import lzma
  File "/usr/local/lib/python3.10/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

I currently use Debian GNU/Linux 11 (bullseye).

Solution

The only solution I found is pip install backports.lzma && apt-get install -y liblzma-dev and was to modify the python libraries fooocus_env/lib/python3.10/site-packages/torchvision/datasets/utils.py:

try:
    import lzma
except ImportError:
    from backports import lzma

I setup using python-venev. I encountered other problems with python, but it was enough to follow https://github.com/lllyasviel/Fooocus/issues/1074#issuecomment-1872577606 issues.

Full Console Log

Exception in thread Thread-2 (worker):
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/home/gstechnology2017/Fooocus/modules/async_worker.py", line 25, in worker
    import modules.default_pipeline as pipeline
  File "/home/gstechnology2017/Fooocus/modules/default_pipeline.py", line 1, in <module>
    import modules.core as core
  File "/home/gstechnology2017/Fooocus/modules/core.py", line 1, in <module>
    from modules.patch import patch_all
  File "/home/gstechnology2017/Fooocus/modules/patch.py", line 12, in <module>
    import modules.inpaint_worker as inpaint_worker
  File "/home/gstechnology2017/Fooocus/modules/inpaint_worker.py", line 6, in <module>
    from modules.upscaler import perform_upscale
  File "/home/gstechnology2017/Fooocus/modules/upscaler.py", line 6, in <module>
    from ldm_patched.contrib.external_upscale_model import ImageUpscaleWithModel
  File "/home/gstechnology2017/Fooocus/ldm_patched/contrib/external_upscale_model.py", line 4, in <module>
    from ldm_patched.pfn import model_loading
  File "/home/gstechnology2017/Fooocus/ldm_patched/pfn/model_loading.py", line 8, in <module>
    from .architecture.LaMa import LaMa
  File "/home/gstechnology2017/Fooocus/ldm_patched/pfn/architecture/LaMa.py", line 15, in <module>
    from torchvision.transforms.functional import InterpolationMode, rotate
  File "/home/gstechnology2017/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/__init__.py", line 6, in <module>
    from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
  File "/home/gstechnology2017/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/datasets/__init__.py", line 1, in <module>
    from ._optical_flow import FlyingChairs, FlyingThings3D, HD1K, KittiFlow, Sintel
  File "/home/gstechnology2017/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/datasets/_optical_flow.py", line 13, in <module>
    from .utils import _read_pfm, verify_str_arg
  File "/home/gstechnology2017/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/datasets/utils.py", line 6, in <module>
    import lzma
  File "/usr/local/lib/python3.10/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

Peppe289 avatar Dec 31 '23 11:12 Peppe289

Can you please provide the FULL terminal output from starting command to error? Thanks!

mashb1t avatar Dec 31 '23 14:12 mashb1t

Can you please provide the FULL terminal output from starting command to error? Thanks!

ofc! this is the FULL log with the described problem regarding _lzma. The only thing you notice from the web page is that it stays stuck at Waiting for task to start....

<user>@instance-2:~/Fooocus$ source fooocus_env/bin/activate
(fooocus_env) <user>@instance-2:~/Fooocus$ python entry_with_update.py --share --always-cpu --attention-split 
Already up-to-date
Update succeeded.
[System ARGV] ['entry_with_update.py', '--share', '--always-cpu', '--attention-split']
Python 3.10.0 (default, Dec 31 2023, 10:35:16) [GCC 10.2.1 20210110]
Fooocus version: 2.1.859
Running on local URL:  http://127.0.0.1:7865
Total VRAM 64319 MB, total RAM 64319 MB
Set vram state to: DISABLED
Always offload VRAM
Device: cpu
VAE dtype: torch.float32
Using split optimization for cross attention
Exception in thread Thread-2 (worker):
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/home/<user>/Fooocus/modules/async_worker.py", line 25, in worker
    import modules.default_pipeline as pipeline
  File "/home/<user>/Fooocus/modules/default_pipeline.py", line 1, in <module>
    import modules.core as core
  File "/home/<user>/Fooocus/modules/core.py", line 1, in <module>
    from modules.patch import patch_all
  File "/home/<user>/Fooocus/modules/patch.py", line 12, in <module>
    import modules.inpaint_worker as inpaint_worker
  File "/home/<user>/Fooocus/modules/inpaint_worker.py", line 6, in <module>
    from modules.upscaler import perform_upscale
  File "/home/<user>/Fooocus/modules/upscaler.py", line 6, in <module>
    from ldm_patched.contrib.external_upscale_model import ImageUpscaleWithModel
  File "/home/<user>/Fooocus/ldm_patched/contrib/external_upscale_model.py", line 4, in <module>
    from ldm_patched.pfn import model_loading
  File "/home/<user>/Fooocus/ldm_patched/pfn/model_loading.py", line 8, in <module>
    from .architecture.LaMa import LaMa
  File "/home/<user>/Fooocus/ldm_patched/pfn/architecture/LaMa.py", line 15, in <module>
    from torchvision.transforms.functional import InterpolationMode, rotate
  File "/home/<user>/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/__init__.py", line 6, in <module>
    from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
  File "/home/<user>/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/datasets/__init__.py", line 1, in <module>
    from ._optical_flow import FlyingChairs, FlyingThings3D, HD1K, KittiFlow, Sintel
  File "/home/<user>/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/datasets/_optical_flow.py", line 13, in <module>
    from .utils import _read_pfm, verify_str_arg
  File "/home/<user>/Fooocus/fooocus_env/lib/python3.10/site-packages/torchvision/datasets/utils.py", line 6, in <module>
    import lzma
  File "/usr/local/lib/python3.10/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'
Running on public URL: https://5868031ee84d311e01.gradio.live

This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)

Peppe289 avatar Dec 31 '23 16:12 Peppe289

I don't know what ´_lzma iss used for, but you can also try and just install it.

See

  • https://stackoverflow.com/questions/59690698/modulenotfounderror-no-module-named-lzma-when-building-python-using-pyenv-on
  • https://github.com/pandas-dev/pandas/issues/27532

mashb1t avatar Jan 02 '24 22:01 mashb1t

As this is already the solution you've mentioned this issue can be closed and will be referenced to on further issues of the same kind. Thank you!

mashb1t avatar Jan 04 '24 00:01 mashb1t