Skip to content

Run OneDiff on Windows by WSL2

Li Junliang edited this page May 16, 2024 · 4 revisions

1. Install WSL2

If you have NVIDIA GPU driver installed locally, then you can use it directly in WSL. If not, please install the graphics card driver first.

1、Install WSL with the following command:

wsl --install

After successful execution, the result will look like this:
image

2、Enable the Linux subsystem with administrator privileges using the following command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

After successful execution, the result will look like this:
image

3、Enable the Virtual Machine feature with administrator privileges using the following command:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

After successful execution, the result will look like this:
image

4、Set the default version of WSL to 2 with administrator privileges using the following command:

wsl --set-default-version 2

After successful execution, the result will look like this:
image

5、After restarting the computer, you can download the Ubuntu system from the Microsoft Store as shown below: image

6、Next, you can open the Ubuntu system as shown in the following image: image image-7

**NOTE:**If you run into such a problem Prompt when WSL2 starts: The referenced object type does not support the attempted operationHere are some things you can try
https://github.com/microsoft/WSL/issues/4177#issuecomment-1429113508

2. Install OneDiff

After you have set up the Ubuntu system, the subsequent steps are exactly the same as installing and using OneDiff on Linux. For detailed steps, please refer to OneDiff-README.md.
image-1

3.Install Stable Diffusion web UI

Please refer to automatic-installation-on-linux to install Stable Diffusion WebUI on WSL.

After you successfully install Stable Diffusion web UI, you can install the OneDiff extension through the following steps.

git clone https://github.com/siliconflow/onediff.git

Use the following command to install OneDiff for Stable Diffusion web UI.

ln -s "$(pwd)/onediff/onediff_sd_webui_extensions" "$(pwd)/stable-diffusion-webui/extensions/onediff_sd_webui_extensions"

cd $(pwd)/stable-diffusion-webui
venv_dir=- bash webui.sh 

# Exit webui server and upgrade some of the components that conflict with onediff.
cd repositories/generative-models && git checkout 9d759324 && cd -

Then install the following packages in your environment.

pip install -U einops==0.7.0

Then go to the cloned Stable Diffusion web UI directory.

cd /path/to/your/stable-diffusion-webui

Then run the following commands in this folder:

python webui.py

You can access this address directly to visit Stable Diffusion web UI http://127.0.0.1:7860.

Then to activate OneDiff extension acceleration, follow these steps: Select onediff_diffusion_model from the Script menu, enter a prompt in the text box (e.g., "a black dog"), and then click the "Generate" button. webui_interface onediff_script

References

https://learn.microsoft.com/zh-cn/windows/wsl/install
https://github.com/siliconflow/onediff/blob/main/README.md