Image generating models can’t tape a banana to a wall and rarely follow your prompts, but if you’re patient enough and know the tool well enough, you can do something creative with them.
In this tutorial, we will learn how to install Fooocus, an image generating software that uses Stable Diffusion SDXL under the hood.
Note: I’m using AMD 5600G APU, but most of what you see here also applies to discrete GPUs. Whenever something is APU specific, I will mark it as such. I use containers with ROCm, but Nvidia CUDA users should also find this guide helpful.
First, for Fooocus we need a container with installed ROCm and PyTorch. It’s around 35 GB in size, so don’t be surprised. Tutorial for that is here.
Let’s log in to the container using the default ubuntu user:
incus exec <container_name> -- sudo --login --user ubuntu
We need to install git
before we clone the official Fooocus repository, then we can download other required packages:
We need to download latest Fooocus (at the time of writing, it was 2.3.1
) from github, extract the file, then we can download other required packages:
wget https://github.com/lllyasviel/Fooocus/archive/refs/tags/2.3.1.tar.gz
tar -xzf 2.3.1.tar.gz
pip3 install -r Fooocus/requirements_versions.txt
That’s it. If you have a discrete GPU, run Fooocus with this command:
python3 ~/Fooocus-2.3.1/entry_with_update.py --listen --port 8888
Generated images will be stored at Fooocus-2.3.1/outputs/<creation_date>/
folders.
But, if have an APU like me, we can use LD_PRELOAD
trick explained in ROCm tutorial linked before, which means we don’t have to assign fixed amount of VRAM to the GPU. My startup command looks like this:
LD_PRELOAD=~/force-host-alloction-APU/./libforcegttalloc.so python3 ~/Fooocus-2.3.1/entry_with_update.py --listen --port 8888 --always-high-vram
To access Fooocus from the host or other containers on the same host, we need to know container’s IP address. We can get it with a command (the ^
and $
symbols limit the list
to the exact instance name):
incus list ^container_name$ -c 4 -f csv
Now paste the received IP address into your browser:
http://X.X.X.X:8888
However, if you’d like to share Fooocus with other computers on our network, we can use a proxy network device. The listen address could be an IP of your machine, which you can get using hostname -I | awk '{print $1}'
command. Change Y.Y.Y.Y
accordingly:
incus config device add <container_name> localhost8888 proxy listen=tcp:Y.Y.Y.Y:8888 connect=tcp:0.0.0.0:8888
Now paste http://Y.Y.Y.Y:8888
into your browser. This option has one small drawback that probably won’t matter to you, which you can read about in the “Access to services in containers” section of llama tutorial.
To learn more about Fooocus and its many features, check out its homepage and YouTube.
That’s all. If you have any questions, feel free to ask. Feedback, corrections and tips are greatly appreciated.