Slicer can be built and runs well on Windows Subsystem for Linux (WSL2)

Some information for Windows developers who want to develop/test Slicer on Linux. On current Windows 10 versions, it is very easy to install Linux and run Linux GUI applications such as Slicer, by using Windows Subsystem for Linux (WSL2).

Ubuntu 20.04 shows up as an app in Microsoft Store. If you install and run it you get a linux terminal. By copy-pasting 10-20 lines you can install kubuntu desktop and you can connect to it using Windows remote desktop as explained here.

Slicer build instructions for linux work flawlessly and Slicer runs well (both the locally built version and downloaded releases):

Build speed is good, Slicer performance is near native, there is no problem with networking, file system access, etc. (issues that kept coming up when using VirtualBox, HyperV, etc.). GPU volume rendering works, but it is a software renderer. There is some GPU virtualization support that works for CUDA; and Microsoft is working on improving GUI application support, so probably GPU-accelerated rendering will be available at some point.

2 Likes

@lassoan was able to install Slicer 4.11 on Kubuntu 20.04 on wsl2 on Windows 11, so in theory with GPU aceleration. Works except the 3D view that works (very slow) on internal GPU, crashes always using discrete GPU. In my case the dGPU it’s in fact an external GPU (eGPU) connected trough Thunderbolt to mine laptop (using it just for testing).
Some questions

  • Other Kubuntu packages appear as Windows app directly accessible trough Start menu. I was only able to launch Slicer from Dolphin, didn’t find a way to install it as native wsl2 GUI app (maybe a reason why crashes using eGPU). Using “sudo apt-get install slicer” return there is no repository to install it from. There is any way to have it installed as separate app.
  • Following this guide I downloaded ad installed the eGPU Windows driver. This is correct, or need I to download and install the Linux driver in wsl2 Ubuntu installation. I tried that but the installation did not completed correctly.
  • The eGPU is used since monitoring from Win Task Manager it’s the only one with some load. Trying to display volume rendering on eGPU result in a 100% usage spike and a crash. There is any Slicer log to look on to understand his problems.

I presume those instructions are correct, given that they are written by the group who develop wsl2.

You need to install the driver in windows side (not in wsl2 side). Also note that specific driver supports only turing and newer generations.

Using AMD GPU RX 550 4GB (the only spare I get this time for testing). Installed the linked driver that support this generation.

Tested the eGPU using a native Kubuntu installation and Slicer volume rendering works without problems, so the problem it’s not the setup nor the specific GPU, seems to be something related to wsl2.

I tried the instructions on the wsl2 for openGL, which basically requires you to install mesa 21 version inside the ubuntu. After that when I ran the

glxinfo -B

I can see the renderer as the NVIDIA gpu (instead of llvmpipes). Further basic tests with glxspheres shows that opengl does work (I can see the load on the Nvidia GPU on windows task manager), although it is quite slow. And while Slicer does initially render MRHead.nrrd as a still image, there can be no interaction on the 3D viewer. Curiously that’s true when I switch to CPU rendering. So something after Mesa 21 package upgrade broke 3D rendering in Slicer, as I was able to do software GPU rendering and CPU rendering on the wsl2 on this system.

Anyways, just reporting that H/W rendering inside WSL2 is still not functional.

Thanks for the information. I guess more time is needed for this GPU support to mature.