LoRA with Dagger
πΈ Fine-tuning Stable Diffusion usingThis example shows how to create brand assets for merchandise from some screenshots of a brand's website:
It's implemented as a Stable Diffusion LoRA pipeline using Dagger: pipelines as (python) code.
- Go to lambdalabs.com, or any other GPU provider of your choice (the instructions below were tested on Lambda)
- Get an instance (e.g. A100 or A10). Min GPU memory is 16GB, tested on 24GB
- Hit up Jupyter (or SSH in, but Jupyter makes viewing the outputs easier π)
π New terminal, add user to docker group
sudo adduser ubuntu docker
sudo su - ubuntu
π Install newer Python
sudo add-apt-repository ppa:deadsnakes/ppa
Press enter to install the PPA.
sudo apt install -y socat python3.10-venv
python3.10 -m virtualenv venv
. venv/bin/activate
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
π Install Dagger CLI
( cd /usr/local ; curl -L https://dl.dagger.io/dagger/install.sh | sudo sh )
βοΈ Check out repo and configure it
git clone https://github.com/lukemarsden/dagger-stable-diffusion-lora
cd dagger-stable-diffusion-lora
pip install -r requirements.txt
cp config.yml.sample config.yml
Now open dagger-stable-diffusion-lora/config.yml
in the Jupyter editor and change anything you like.
π Train some LoRAs!
Back in the first terminal, run:
export _EXPERIMENTAL_DAGGER_INTERACTIVE_TUI=1
dagger run python lora.py
Now go and have lunch while you pull docker images & train some LoRAs π
...
If you're curious to watch the progress, in another terminal tab, do sudo docker ps
and sudo docker logs -f <container_id>
for some of the running jobs.
Welcome back, check out output/inference
to see the results!
π Observe the dagger cache making things faster
Now uncomment some of the prompts and/or brands in the config.yml
and re-run, note how the Dagger cache saves you from having to redo any work that it's already done!
πΈ Remember to shut down your GPU
If you like keeping your money!