Implements: https://towardsdatascience.com/how-to-fine-tune-stable-diffusion-using-dreambooth-dfa6694524ae
EC2 Instance
- AMI: Deep Learning with PyTorch 1.13
- Instance type: g5.{some number}xlarge
- IAM role: stable-diffusion
dreambooth.pem
file for your EC2 instance- HuggingFace key (and accept the Terms and Conditions for the model - see https://towardsdatascience.com/how-to-fine-tune-stable-diffusion-using-dreambooth-dfa6694524ae for details how)
- AWS Public/Private Key Pair
- IP address of the EC2 instance
I keep these together in a .env
file locally for easy reference.
TODO: load the local .env
file to make setup easier
ssh -i dreambooth.pem ec2-user@<IP-ADDRESS>
(Optional:)
- Get ssh to work nicely
- add
PermitTunnel yes
withsudo vim /etc/ssh/sshd_config
- reload ssh with
sudo service sshd reload
ssh-keygen -t rsa -C "[email protected]"
eval "$(ssh-agent -s)" && \ ssh-add ~/.ssh/id_rsa && \ ssh-add -l -E sha256 && \ cat ~/.ssh/id_rsa.pub
Copy that output and paste it into GitHub as an SSH key under Settings. https://github.com/settings/keys
mkdir rootvc && cd rootvc && git clone [email protected]:rootvc/dreambooth.git && cd dreambooth
./setup.sh
accelerate config
Answer the questions as follows: (TODO: This is dumb, see if we can answer the Qs automatically.)
In which compute environment are you running? ([0] This machine, [1] AWS (Amazon SageMaker)): 0 Which type of machine are you using? ([0] No distributed training, [1] multi-CPU, [2] multi-GPU, [3] TPU [4] MPS): 0 Do you want to run your training on CPU only (even if a GPU is available)? [yes/NO]:no Do you want to use DeepSpeed? [yes/NO]: no Do you wish to use FP16 or BF16 (mixed precision)? [NO/fp16/bf16]: fp16
huggingface-cli login
Enter huggingface credentials.
(TODO: See if we can answer this Q automatically.)
git config --global credential.helper store
./train.sh
./generate.sh