:: krowemoh

Friday | 27 DEC 2024
Posts Links Other About Now

previous
next

(Failed) - Notes on Installing Stable Diffusion on WSL2 Ubuntu

2022-08-31

These steps go nowhere :)

This will be just the steps to install stable diffusion on my Windows Subsystem for Linux Ubuntu.

This link is what I'm working off of.

https://www.assemblyai.com/blog/how-to-run-stable-diffusion-locally-to-generate-images/

The first step is to install miniconda, you could do anaconda as well.

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

Conda seems to have been screwed up and I had to restart wsl to get it to properly run the create command.

https://github.com/conda/conda/issues/9948#issuecomment-906410470

$ wsl.exe --shutdown

Open WSL again.

The next step is to get the stable diffusion code.

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

Now that we have the code, we need to get the weights. This requires an account with hugging face and you need to accept their license.

https://huggingface.co/CompVis/stable-diffusion-v-1-4-original

This will then give you a link to download the weights. The filename will be sd-v1-4.ckpt.

Once this file is downloaded, place the file inside the stable-diffusion git folder.

$ cd stable-diffusion
$ explorer.exe .

Now we can create the environment needed using conda.

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

Finally we can try out the new AI.

$ python scripts/txt2img.py --prompt "YOUR-PROMPT-HERE" --plms --ckpt sd-v1-4.ckpt --skip_grid --n_samples 1

I did this raw and I'm curious what I'll see with just your-prompt-here.

I might need to install and set up CUDA to be able to use my GPU but I gave it a shot before.

After waiting for quite some time while it downloaded, I got an error.

RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

Going to guess its the CUDA stuff but shot in the dark.

https://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#3-install-nvidia-cuda-on-ubuntu

$ 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
$ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/3bf863cc.pub
$ sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /"
$ sudo apt-get update
$ sudo apt-get -y install cuda

To test if WSL2 is able to use it.

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

This ultimately didn't work. I got an error message that the Cuda version was out of sync. I have a 3060 Ti which seems to use cuda 8.6 while Ubuntu has the package at version 11.7.1. I'm not entire sure if those numbers are telling me what I think they are telling me.

Going to install the CUDA toolkit 11.7 and see if that helps.

https://developer.nvidia.com/cuda-downloads

Installed this and this looks good. I uninstalled cuda.

$ sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*" 

Then re-installing it.

$ sudo apt-get install cuda

I'm going to try re-doing the steps but this time using instructions from reddit. Didn't work.

Another set of instructions to try

https://developer.nvidia.com/cuda-downloads

Get the Linux run file and make sure to not install the driver, only the libraries.

$ wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run
$ sudo sh cuda_11.7.1_515.65.01_linux.run

Make sure to not install the driver. This will also update the /usr/local/cuda to be a symlink to the one we are installing.

Doesn't work.