Sidetrip — WSL While You Work — Getting DreamBooth to Run on Windows with 8GB VRAM
Or not.
Well, for my next experiment it’s time to try to get Dreambooth to run locally on my Windows machine. Oh wait, is it Dreambooth or DreamBooth? DreamBooth? Oh. I’ve been writing it wrong. Okay, DreamBooth then. Got it. Carrying on.
This could be a total failure. One reason I want to do this is to be able to run DreamBooth at home without needing to rely on Google Colab notebooks (and, well, cough up $10 every so often). I also found myself in the position where I wanted to add more than one training to my model and — while I’m sure I could figure it out w/ the intermediate files created during Colab training — I thought it easier to try this at home.
(Ha ha ha ha ha, hoo-boy — Editor)
What could go wrong? Other than my ego being lay to waste.
First things first: got to install Windows Subsystem for Linux on my machine. Well, WSL is already installed and waiting, so I went to the Windows Store and installed generic Ubuntu, started that up, created an account, did a basic update, and then started reading about what was necessary to get accelerated nVidia data-science / CUDA working on this here WSL installation.
Side-note: I never become attached to any Linux installation. They all end in tears, at least for me. I learned not to get attached after years of bopping around with Raspberry Pis. Any installation is doomed to eventual failure for me. Especially when you’re doing cut and paste brain surgery like this to get DATA-SCIENCE working.
The journey starts with WSL | Ubuntu and scrolling down to CUDA to get me some GPUs working. Ah, Enabling GPU acceleration on Ubuntu on WSL2 with the NVIDIA CUDA Platform | Ubuntu. There we go. I don’t see a specific nVidia driver so I’m just updating my card’s driver to the latest. The final apt-get before trying to compile something off of GitHub is massive. Like, let me check my hard disk remaining free space. Okay, it’s good but I’ve certainly doubled my used space since starting all this AI art fun.
Done, doing a clone of the samples (even that’s huge, but I guess that’s a good thing). Okay, compile the sample and run to ensure CUDA is ready for me by running the deviceQuery I just built and… flame out. Fail. No CUDA for me. The error message:
CUDA driver version is insufficient for CUDA runtime version
Looks like what we have here is a case of Ready, Fire, Aim.
While I had confidence in my machine’s environment I didn’t remember I had refreshed Windows recently (highly recommended, except, you know) blowing away all my development environment settings from long ago. Okay, back to the drawing board: to switch to WSL2 I have to first turn on virtualization in the OS:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
(check that’s okay in BIOS: check) and then, after setting my default WSL to version 2, try converting my Ubuntu v1 installation to a v2 installation (though I think I’ll blow it away and restart at the slightest hinky bump in the road). Woof, this conversion is taking a long time. Due penance for me not double checking my WSL being at 2 before starting all of this. Okay, done. Start Ubuntu. Go into that sample I built and run ./deviceQuery …
Detected 1 CUDA Capable device(s)
:
Result = PASS
Well slap my ass and call me Judy, it worked. I got a nice successful report out of deviceQuery meaning that the first step, setting up access to accelerated nVidia CUDA, is a go.
Next go through: Guide for DreamBooth with 8GB vram under Windows : StableDiffusion (reddit.com) — this leads to a recipe for setting up your Linux environment for running DreamBooth. There are configurations to run and pips to do. Then (ensuring your shell file is in Unix format thanks to dos2unix) you run the script for DreamBooth.
No dice. Like others in the Reddit page, I run into:
RuntimeError: CUDA error: out of memory
This happens while trying to call pin_memory(). There is a discussion about pinned memory. Anything relevant? Well, when I look at a Python test program from Dreambooth doesn’t train on 8GB · Issue #807 · huggingface/diffusers (github.com) I fail there and then realize I need to boost the memory to my WSL instance. Run htop or free -m shows that it’s limited.
Via the WSL config file I up it as far as I can on my 32GB Windows box but alas not even the Python pinning test can pass, let alone getting DreamBooth to run. Looks like some folks are running this on a 64GB system. I don’t feel so fancy anymore with my 32GB of memory.
We have reached the end of the road on this attempt. As much as I wanted to avoid running a Google Colab and actually run this on my own iron I have to admit, as of today, my humble system is just not big enough. So… screw it. I see there is a major OS update available (22H2) which might work better, but it will have to wait until I have reconstructed a hard drive on another project.
Trying this again: fast-DreamBooth.ipynb — Colaboratory (google.com) and throwing money at Google for colab credits.