Advertisement
Guest User

StableDiffusion-WSL

a guest
Oct 2nd, 2022
11,156
3
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | Software | 3 0
  1. == https://github.com/ShivamShrirao/diffusers/tree/main/examples/dreambooth ==
  2.  
  3. * Make a place for downloads
  4. mkdir Downloads
  5. cd Downloads
  6.  
  7. * Download & Install Anaconda
  8. wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
  9. chmod +x ./Anaconda3-2022.05-Linux-x86_64.sh
  10. ./Anaconda3-2022.05-Linux-x86_64.sh
  11.  
  12. * Nvidia CUDA toolkit for Ubuntu WSL - https://developer.nvidia.com/cuda-downloads
  13. wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
  14. sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
  15. wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda-repo-wsl-ubuntu-11-7-local_11.7.1-1_amd64.deb
  16. sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.1-1_amd64.deb
  17. sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/
  18. sudo apt-get update
  19. sudo apt-get -y install cuda
  20.  
  21. * New shell with Anaconda & install g++
  22. bash
  23. sudo apt install build-essential
  24.  
  25. * New virtual Python environment
  26. conda update -n base -c defaults conda
  27. conda create --name diffusers python=3.9
  28. conda activate diffusers
  29.  
  30. * Make a directory for all your github downloads, then download diffusers
  31. mkdir ~/github
  32. cd ~/github
  33. git clone https://github.com/ShivamShrirao/diffusers.git
  34. cd diffusers
  35.  
  36. * Install required packages
  37. pip install .
  38. cd examples/dreambooth
  39. pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
  40. pip install -r requirements.txt
  41. pip install -U --pre triton
  42. pip install ninja bitsandbytes
  43. pip install git+https://github.com/facebookresearch/xformers@1d31a3a#egg=xformers
  44.  
  45. * Configure / login
  46. accelerate config
  47. huggingface-cli login
  48. mkdir -p training
  49. mkdir -p classes
  50. explorer.exe .
  51.  
  52. * Edit your training file and add this line to the top or reboot:
  53. export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
  54.  
  55. * Copy your training file from your Windows desktop (or wherever you saved it):
  56. cp /mnt/c/Users/YOUR_USERNAME/Desktop/my_training.sh ./
  57. chmod +x ./my_training.sh
  58. ./my_training.sh
  59.  
  60.  
  61. * NB: If you get an error like this -
  62. 403 Client Error: Forbidden for url: https://huggingface.co/CompVis/stable-diffusion-v1-4/resolve/main/model_index.json
  63.  
  64. Then:
  65. Make sure you've visited https://huggingface.co/CompVis/stable-diffusion-v1-4 and accepted the licence!
  66. NB. If this is the very first time you've used diffusers, it's about a 6GB download
  67.  
  68. To train again next time, simply:
  69.  
  70. * Start Ubuntu, then:
  71. conda activate diffusers
  72. cd ~/github/diffusers/examples/dreambooth
  73. ./my_training.sh
  74.  
Advertisement
Comments
  • ZeroCool22
    2 years (edited)
    # text 0.15 KB | 0 0
    1. If someone has problems with CUDA not being detected, just be sure to add "export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH" to the train file.
  • Arrowman6677
    2 years
    # text 1.42 KB | 0 0
    1. I had to make some changes to get this to work for me:
    2.  
    3. * Install required packages (updated for 11/02/2022)
    4. pip install .
    5. cd examples/dreambooth
    6. conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge
    7. pip install -r requirements.txt
    8. pip install -U --pre triton
    9. pip install ninja bitsandbytes
    10. conda install xformers -c xformers/label/dev
    11.  
    12. I changed the torch install to use 0.12 (the OG pastebin installs the latest 0.13, which did not work for me). I also changed xformers to grab the latest version.
    13.  
    14. * Training file (running with SD 1.5)
    15. 1. Get your training script from here (https://github.com/ShivamShrirao/diffusers/tree/main/examples/dreambooth). I used the 8gb one and followed the instructions for configuring DeepSpeed
    16. 2. make sure you save your training script with LF line separators and not CRLF
    17. 3. Follow the instructions from this step to dump your 1.5 model (https://github.com/ShivamShrirao/diffusers/issues/50#issuecomment-1294854643).
    18. 4. Update the training script for the new model. It should look something like:
    19.  
    20. export MODEL_DIR="/home/arrow/github/diffusers/models/dump"
    21. export VAE_DIR="/home/arrow/github/diffusers/models/dump/vae"
    22. export INSTANCE_DIR="training"
    23. export CLASS_DIR="classes"
    24. export OUTPUT_DIR="out"
    25.  
    26. accelerate launch train_dreambooth.py \
    27. --pretrained_model_name_or_path=$MODEL_DIR \
    28. --pretrained_vae_name_or_path=$VAE_DIR \
    29. ...
Add Comment
Please, Sign In to add comment
Advertisement