mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
558 stars 148 forks source link

Deploy to Replicate #111

Closed ardha27 closed 8 months ago

ardha27 commented 8 months ago

i want to fork your code and deploy it to replicate, but i get this error image

[System ARGV] ['/root/.pyenv/versions/3.11.7/lib/python3.11/site-packages/cog/server/http.py', '--await-explicit-shutdown=true', '--upload-url=http://api.tenant-replicate-prdsvcs.svc.cluster.local/_internal/file-upload/']
[Pre Setup] Prepare environments
[Fooocus-API] Task queue size: 3, queue history size: 100
Traceback (most recent call last):
File "/root/.pyenv/versions/3.11.7/lib/python3.11/site-packages/cog/server/worker.py", line 185, in _setup
run_setup(self._predictor)
File "/root/.pyenv/versions/3.11.7/lib/python3.11/site-packages/cog/predictor.py", line 68, in run_setup
predictor.setup()
File "/src/predict.py", line 21, in setup
pre_setup(disable_image_log=True, skip_pip=True, preload_pipeline=True, preset=None)
File "/src/main.py", line 333, in pre_setup
prepare_environments(args)
File "/src/main.py", line 268, in prepare_environments
if args.gpu_device_id is not None:
^^^^^^^^^^^^^^^^^^
AttributeError: 'Args' object has no attribute 'gpu_device_id'
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.11.7/lib/python3.11/site-packages/cog/server/runner.py", line 296, in setup
    for event in worker.setup():
  File "/root/.pyenv/versions/3.11.7/lib/python3.11/site-packages/cog/server/worker.py", line 126, in _wait
    raise FatalWorkerException(raise_on_error + ": " + done.error_detail)
cog.server.exceptions.FatalWorkerException: Predictor errored during setup: 'Args' object has no attribute 'gpu_device_id'
konieshadow commented 8 months ago

@ardha27 Are you using the latest code? I just tested the main branch by cog predict, and it works fine.

ardha27 commented 8 months ago

Can you teach me a bit on how to test it on local before i push it to replicate?

ardha27 commented 8 months ago

is the first starting on replicate always takes long time? image i wait for more than 30m and still 'starting'

konieshadow commented 8 months ago

Can you teach me a bit on how to test it on local before i push it to replicate?

Follow cog's document.

  1. Ensure you have an machine installed docker and nvidia-container-toolkit: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
  2. Install cog: https://github.com/replicate/cog?tab=readme-ov-file#install
  3. In the project root direct, run cog predict, or cog predict -i prompt='1 girl'.
konieshadow commented 8 months ago

is the first starting on replicate always takes long time? image i wait for more than 30m and still 'starting'

No. It takes 3~7 minutes in normal.

ardha27 commented 8 months ago

Can you teach me a bit on how to test it on local before i push it to replicate?

Follow cog's document.

  1. Ensure you have an machine installed docker and nvidia-container-toolkit: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
  2. Install cog: https://github.com/replicate/cog?tab=readme-ov-file#install
  3. In the project root direct, run cog predict, or cog predict -i prompt='1 girl'.

thanks, it working now. What is the simplest way to make Fooocus auto download other checkpoint?

ardha27 commented 8 months ago

btw, can i add all checkpoint/pth file inside the cog/docker? so it not relying on downloading file from other repo

konieshadow commented 8 months ago

btw, can i add all checkpoint/pth file inside the cog/docker? so it not relying on downloading file from other repo

You can do it easily in Dockerfile for docker, but it will make the image much larger. For cog, I don't know how.

ardha27 commented 8 months ago

Could you give me one example line, if for example i want to include checkpoint inside dockerfile?

konieshadow commented 8 months ago

Could you give me one example line, if for example i want to include checkpoint inside dockerfile?

You can use COPY key word in docker file. But first you need to modify .dockerignore to not exclude checkout file from docker build stage. Just open an getting started toturial for dockerfile write.