(Success) Notes on Installing Stable Diffusion - Electric Boogaloo

2022-09-01 2

I had installed Ubuntu under WSL1. I didn’t realize that. Explains so much now.

In powershell you can list out the linux distros you have and the versions they running under.

> wsl -l -v
NAME      STATE           VERSION
Ubuntu    Stopped         1
Debian    Running         2

Always turn on virtualization in the bios. I found it in bios under Advanced -> CPU configuration -> SVM mode. This should be enabled. This is for the Asus UEFI bios version 2.2.

Once I had virtualization set, then I enabled WSL2.

In powershell:

> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
> wsl --set-default-version 2
> wsl --install -d debian

Now I could start debian and install cuda and actually get it working.

These are the steps to install CUDA.


$ sudo apt-key del 7fa2af80
$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
$ sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
$ wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get -y install cuda

The testing to make sure it was installed properly.

$ git clone https://github.com/nvidia/cuda-samples
$ cd cuda-samples/Samples/1_Utilities/deviceQuery
$ make
$ ./deviceQuery
./deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA GeForce RTX 3060 Ti"
CUDA Driver Version / Runtime Version          11.7 / 11.7

Steps to get conda.

$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh 
$ wsl.exe --shutdown

Steps to get the code for stable diffusion, I had to get the optimized version due to not having enough vram.

$ git clone https://github.com/basujindal/stable-diffusion.git

Download the weights after creating an account and accepting the license. Then copy the weights over to the stable-diffusion folder. This will need to get placed in this place specifically.


$ cd stable-diffusion
$ mkdir stable-diffusion/models/ldm/stable-diffusion-v1
$ cd stable-diffusion/models/ldm/stable-diffusion-v1
$ explorer.exe .

Now create the conda environment. This can take some time.

$ conda env create -f environment.yaml
$ conda activate ldm

Now I can actually run the command:

$ python optimizedSD/optimized_txt2img.py --prompt "the future we were promised, computers, robots, magic, vaporware, neon, vivid colors, 4k, artstation" --H 512 --W 512 --seed 27 --n_iter 2 --ddim_steps 50 --ckpt sd-v1-4.ckpt

Images can be found under the outputs/txt2img-samples/.