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

**URL:** https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022
**Category:** Development
**Created:** [February 17, 2021, 2:20am UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022 "2021-02-17T02:20:54Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 17, 2021, 2:20am UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/1 "2021-02-17T02:20:54Z")

</div>

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](https://www.nextofwindows.com/how-to-enable-wsl2-ubuntu-gui-and-use-rdp-to-remote).

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

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/f/dfb0e690d4113d1e607fab4e2b6e378d01acd5f8.jpeg)

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.

---

<div class="post-metadata">

### Author: ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)
#### Post date: [January 4, 2022, 9:55pm UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/4 "2022-01-04T21:55:45Z")

</div>

@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](https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps) 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.

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [January 4, 2022, 10:11pm UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/5 "2022-01-04T22:11:04Z")

</div>

> [@davide445](#):
>
> Following [this](https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps) 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.

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.

---

<div class="post-metadata">

### Author: ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)
#### Post date: [January 4, 2022, 10:12pm UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/6 "2022-01-04T22:12:41Z")

</div>

> [@muratmaga](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![davide445](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide445/32/13460_2.png) [@davide445](https://discourse.slicer.org/u/davide445)
#### Post date: [January 5, 2022, 8:28am UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/7 "2022-01-05T08:28:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [January 18, 2022, 8:19pm UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/8 "2022-01-18T20:19:09Z")

</div>

> [@lassoan](#):
>
> 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.

I tried the instructions on the [wsl2 for openGL](https://github.com/microsoft/wslg#opengl-accelerated-rendering-in-wslg), which basically requires you to install mesa 21 version inside the ubuntu. After that when I ran the

```auto
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.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [January 19, 2022, 2:42am UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/9 "2022-01-19T02:42:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [July 22, 2024, 10:17pm UTC](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022/10 "2024-07-22T22:17:19Z")

</div>

There are improvements in WSL2 installation and GPU support (much GPU-accelerated rendering and display of GUI application screens work out of the box), but there are still some issues. See details here:

> <https://github.com/Slicer/Slicer/issues/7864>
>
> Some users would like to run Slicer in WSL2, but there are a couple of issues th…at would be nice to fix.
> 
> \# How to run Slicer on WSL2
> 
> \## Setup
> 
> \- Start PowerShell as Administrator
> 
> Run command:
> 
> \`\`\`
> wsl --install
> \`\`\`
> 
> Start wsl:
> 
> \`\`\`
> wsl
> \`\`\`
> 
> \- Create user, password.
> \- Get information on what linux distribution is installed:
> 
> \`\`\`
> cat /etc/os-release
> \`\`\`
> 
> \- Get prerequisites from here: https://slicer.readthedocs.io/en/latest/user\_guide/getting\_started.html#linux
> 
> For example, for ubuntu 22.04:
> 
> \`\`\`
> sudo apt-get install libglu1-mesa libpulse-mainloop-glib0 libnss3 libasound2 qt5dxcb-plugin libsm6
> \`\`\`
> 
> \- Install Slicer: get the download link from https://download.slicer.org, then download and unpack:
> 
> \`\`\`
> cd /tmp
> wget https://download.slicer.org/bitstream/669c9155e53aec320c786090 -O Slicer.tar.gz
> tar -xvzf Slicer.tar.gz
> \`\`\`
> 
> \## Start Slicer
> 
> \- Start wsl:
> 
> \`\`\`
> wsl
> \`\`\`
> 
> \- Start Slicer:
> 
> \`\`\`
> /tmp/Slicer-5.7.0-2024-07-20-linux-amd64/Slicer
> \`\`\`
> 
> \# Experienced issues
> 
> \## Extensions manager crashes
> 
> Workaround: install extensions using the Python console
> 
> \`\`\`
> extensionNames = \["SlicerIGT", "SegmentEditorExtraEffects"\]
> em = slicer.app.extensionsManagerModel()
> em.interactive = False # prevent display of popups
> restart = False # we will restart manually after all extensions were installed
> update = True
> for extensionName in extensionNames:
> if not em.installExtensionFromServer(extensionName, restart):
> raise ValueError(f"Failed to install {extensionName} extension")
> print(f"Installed {extensionName}")
> slicer.util.restart()
> \`\`\`
> 
> \## Cannot use view controllers (that appear when push-pin button is clicked)
> 
> View contollers appear slightly shifted and buttons do not react.
> 
> Workaround: use \`View Controllers\` module to adjust view settings
> 
> \## Popup windows appear out of place
> 
> Confirmation popups etc. appear far away from the application window.
> 
> Workaround: none. The popup windows are still functional.
> 
> \## Rendering is slow
> 
> \## Switching to Volume Rendering module crashes the application
