Advertisement
underlines

dreambooth001

Dec 28th, 2022
1,178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.35 KB | None | 0 0
  1. # uninstall other cuda versions inside WSL - https://stackoverflow.com/questions/56431461/how-to-remove-cuda-completely-from-ubuntu
  2. sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*"  #uninstall cuda toolkit
  3.  
  4. # install cuda 11.6 - https://developer.nvidia.com/cuda-11-6-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local
  5. wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
  6. sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
  7. wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda-repo-wsl-ubuntu-11-6-local_11.6.0-1_amd64.deb
  8. sudo dpkg -i cuda-repo-wsl-ubuntu-11-6-local_11.6.0-1_amd64.deb
  9. sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-6-local/7fa2af80.pub
  10. sudo apt-get update
  11. sudo apt-get -y install cuda
  12.  
  13. # check CUDA
  14. nvidia-smi
  15. # still shows CUDA 12.0, we ignore it
  16.  
  17. # create cuda env
  18. conda create --name diffusers python=3.10.0
  19. conda activate diffusers
  20.  
  21. # install pytorch for cuda 11.6
  22. conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge
  23.  
  24. # install triton
  25. pip install -U --pre triton
  26.  
  27. # install xformers
  28. conda install xformers -c xformers/label/dev
  29.  
  30. #install functorch + ninja
  31. pip install functorch==0.2.1 ninja
  32.  
  33. # install correct bitsandbytes with GPU support for selected cuda variant
  34. conda list| grep cudatoolkit
  35. # get toolkit version above cudaXXX
  36. pip install bitsandbytes-cuda116
  37.  
  38. # clone and install Shivam's diffusers implementation
  39. git clone https://github.com/ShivamShrirao/diffusers.git
  40. cd diffusers
  41. pip install .
  42. cd examples/dreambooth
  43.  
  44. # install HF login + token
  45. huggingface-cli login
  46.  
  47. # install deepspeed, configurate accelerate
  48. pip install deepspeed
  49. accelerate config
  50.     0 this machine
  51.     0 no distributed training
  52.     NO CPU only
  53.     YES use DeepSpeed
  54.     NO use deepseed config
  55.     2 ZeRO optimisation stage
  56.     CPU offload optimizer states
  57.     CPU offload parameters
  58.     1 gradient accumulation steps
  59.     NO gradient clipping
  60.     NO zero.init
  61.     1 GPU
  62.     fp16
  63.  
  64. # fix weird xformers dependency error for pyre-extensions and einops
  65. pip install pyre-extensions==0.0.23
  66. pip install einops
  67.  
  68. # add library path for wsl into launch.sh
  69.     export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
  70.     export MODEL_NAME="runwayml/stable-diffusion-v1-5"
  71.     export OUTPUT_DIR="output"
  72.     accelerate launch train_dreambooth.py \
  73.       --pretrained_model_name_or_path=$MODEL_NAME \
  74.       --output_dir=$OUTPUT_DIR \
  75.       --revision="fp16" \
  76.       --with_prior_preservation --prior_loss_weight=1.0 \
  77.       --seed=5825825 \
  78.       --resolution=512 \
  79.       --train_batch_size=1 \
  80.       --mixed_precision="fp16" \
  81.       --gradient_checkpointing \
  82.       --use_8bit_adam \
  83.       --gradient_accumulation_steps=1 \
  84.       --learning_rate=5e-6 \
  85.       --lr_scheduler="constant" \
  86.       --lr_warmup_steps=0 \
  87.       --num_class_images=47\
  88.       --sample_batch_size=1 \
  89.       --max_train_steps=500 \
  90.       --save_interval=250\
  91.       --save_sample_prompt="photo of young amiarp woman" \
  92.       --concepts_list="concepts_list.json" \
  93.  
  94. # edit concepts_list.json:
  95.         "instance_prompt":      "photo of young amiarp woman",
  96.         "class_prompt":         "photo of a young woman",
  97.         "instance_data_dir":    "instance",
  98.         "class_data_dir":       "class"
  99.  
  100. # train
  101. chmod +x launch.sh
  102. ./launch.sh
  103.  
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement