I am using WSL Ubuntu to use the Stable Diffusion AI art generator but I’m coming into problems since my C: drive is relatively small.
Funny - I was just thinking the same thing. And my C: drive isn't small by any stretch, but I might have an addiction to new Stable Diffusion models. Papercut! BalloonArt! Wheeee! ;-)
I wanted to know if there was a way to have Ubuntu download its information to other drives like the D: drive or other drives? And if so how would I go about doing that?
While you could use your D: drive directly from within Ubuntu/WSL, it's not really a good idea. /mnt/d will provide access to it, but the network file system that WSL2 uses to access Windows drives is quite slow. It wouldn't change your image generation time that much for Stable Diffusion, but it would almost certainly increase the startup time for SD dramatically, since the model would have to be loaded off /mnt/d into the GPU each time.
Accessing many small files on a Windows drive from WSL2 can be around 100x slower than the ext4 virtual disk. But even a single large file like a Stable Diffusion model is around twice as slow based on a quick test I did yesterday.
Better to create a separate WSL2 distribution/instance somewhere on the D: drive, assuming that it is an SSD, at least. If you are going from an SSD on C: to an HDD on D:, then you have some speed vs. size tradeoff decisions to make.
You can use the instructions that @Joseph provided, but:
- Please exercise caution as noted in my comment there
- You'll also need to set your default user in the new instance.
- You'll need to issue a
wsl --set-default <new_version> to make the new copy the default.
If you are using a recent WSL release (installed from the Microsoft Store) under Windows 11, there's a slightly easier way.
Exit the existing Ubuntu
In PowerShell (as a regular, non-Admin user):
wsl --shutdown
create a directory for the new distribution
mkdir D:\WSL\instances\stable-diffusion
Find the location of the existing Ubuntu:
Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss\ |
ForEach-Object {
(Get-ItemProperty $_.PSPATH) | Select-Object DistributionName,BasePath
}
wsl --import --vhd Stable-Diffusion D:\WSL\instances\stable-diffusion C:\Users<yourUsername>\path\you\found\above\ext4.vhdx
Then you should be able to launch wsl ~ -d Stable-Diffusion.
Set your default user via this answer (Method #1 recommended).
Then wsl ~ -d Stable-Diffusion should launch properly with your default user.
After confirming that everything is working, then you can optionally issue:
wsl --set-default Stable-Diffusion
wsl --unregister <old_distribution_name>
But remember that this is a destructive, irreversible operation. Please make sure that all files you need are available in the new distribution first!
You could also leave the old distribution in place as a "general purpose" Ubuntu WSL installation, using the D: version of Stable Diffusion specifically for that purpose.
If so, and you want to reduce the size of the image (after deleting the models/etc.), then also see this answer.