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

ModuleNotFoundError: No module named 'ldm_patched' when running main.py #351

Open
carlosvillu opened this issue Jun 7, 2024 · 4 comments

Comments

@carlosvillu
Copy link

Description:
When attempting to run main.py with the command ['main.py', '--host', '0.0.0.0', '--port', '8888'], I encountered a ModuleNotFoundError related to ldm_patched. Below are the details of the error:

Error Message:

['main.py', '--host', '0.0.0.0', '--port', '8888']

[Fooocus API] Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

[Fooocus API] Fooocus API version: 0.3.33

Traceback (most recent call last):
  File "/app/main.py", line 200, in <module>
    from fooocusapi.args import args
  File "/app/fooocusapi/args.py", line 2, in <module>
    import ldm_patched.modules.args_parser as args_parser
ModuleNotFoundError: No module named 'ldm_patched'

Steps to Reproduce:

  1. Run the command ['main.py', '--host', '0.0.0.0', '--port', '8888'] in the terminal.
  2. Observe the error message indicating that the ldm_patched module is not found.

Expected Behavior:
The script should run without errors, initializing the Fooocus API as expected.

Actual Behavior:
The script fails to run, raising a ModuleNotFoundError for the ldm_patched module.

Environment:

  • Python version: 3.10.12
  • GCC version: 11.4.0
  • Fooocus API version: 0.3.33

Additional Information:
It appears that the ldm_patched module is either missing or not installed in the environment. Could you provide guidance on how to resolve this issue? Is there a specific package or dependency that needs to be installed?

Thank you for your assistance!

@mrhan1993
Copy link
Owner

I would suggest you upgrade to the latest version.

@carlosvillu
Copy link
Author

carlosvillu commented Jun 25, 2024

I have tested the current code in the repository, and it works perfectly on the first attempt.

However, the problem arises when I run this command:

docker run -d --name fooocus-api --restart unless-stopped --gpus=all \
    -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \
    -e NVIDIA_VISIBLE_DEVICES=all \
    -v /home/carlosvillu/Development/Fooocus-API-docker/repositories:/app/repositories \
    -v ~/.cache/pip:/root/.cache/pip \
    -p 2025:8888 konieshadow/fooocus-api

I believe the issue is not with the repository itself but with the published Docker image.

Output:

[2024-06-25 14:24:24] INFO     [System ARGV] ['main.py', '--host', '0.0.0.0', '--port', '8888', '--skip-pip']
[2024-06-25 14:24:24] INFO     [Fooocus API] Python 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]
[2024-06-25 14:24:24] INFO     [Fooocus API] Fooocus API version: 0.4.0.6
Traceback (most recent call last):
  File "/app/main.py", line 195, in <module>
    from fooocusapi.args import args
  File "/app/fooocusapi/args.py", line 5, in <module>
    import ldm_patched.modules.args_parser as args_parser
ModuleNotFoundError: No module named 'ldm_patched'

@mrhan1993
Copy link
Owner

我发布了一个新的 Docker 镜像,将 /home/carlosvillu/Development/Fooocus-API-docker 与仓库同步,然后再次使用你提供的命令重试。如果仍然不工作,尝试 -v /home/carlosvillu/Development/Fooocus-API-docker/repositories/Fooocus/models:/app/repositories/Fooocus/models , if any error, let me know. thx

I have released a new Docker image, and synchronizes /home/carloscillu/Development/Fooocus-API-docker with the repository, and then retry using the command you provided. If it still doesn't work, try -v /home/carlosvillu/Development/Fooocus-API-docker/repositories/Fooocus/models:/app/repositories/Fooocus/models , if any error, let me know. thx

@dpkirchner
Copy link

@mrhan1993 's suggestion works, however there are a few more steps required to get Fooocus to generate images:

mkdir -p ~/.cache/pip ~/fooocus-models

# install some necessary model files (doesn't include the actual model)
git clone https://github.com/lllyasviel/Fooocus.git
cd Fooocus/models
rsync -a ./ ~/fooocus-models/

# now you can run this
docker run --gpus=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all -v ~/.cache/pip:/root/.cache/pip -v ~/fooocus-models:/app/repositories/Fooocus/models -p 8888:8888 konieshadow/fooocus-api

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

No branches or pull requests

3 participants