Compiling Relion on WSL2

September 14, 2021
Relion Cryo-EM WSL2 Windows Linux



I would like to start the scientific part of my blog with something I promised myself long time ago that I would write down somewhere, so I would not have to look for answers online ever again. During last 2 years it hasn’t happened though.

Even though I moved completely to Ubuntu for every-day research, I still sometimes use Relion on Windows Subsystem Linux (WSL). Recently we repurchased a new Windows workstation for tomography workflow in Warp (that is only available on Windows). Hence, I was again looking for dependencies that are not listed on the official Relion website. Let’s compile Relion for WSL2!


  1. Make sure that Windows build is recent enough (Windows 10 OS build 20262 or higher) Check this website for details and step by step procedure. Here I just include the most important commands. I would suggest joining the Windows Insider Program and update up to latest Windows 11 build.

  2. Install WSL2. Open Power Shell as admin and paste:

1dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
2dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  1. When done, download the kernel update .

  2. Change the default WSL to WSL2:

1wsl --set-default-version 2
  1. Install Ubuntu 20.04LTS from Windows Store. Then, in the Start Menu find Ubuntu icon and start it. You will be prompted to provide new username and password.

  2. Having WSL2 with Ubuntu 20.04LTS installed you can go forward and install Relion.

  3. Update Ubuntu apt library and download required dependencies:

1sudo apt-get update && sudo apt-get upgrade -y
2
3sudo apt-get install cmake git build-essential mpi-default-bin mpi-default-dev libfftw3-dev libtiff-dev -y
4
5# Missing X11 libs
6sudo apt-get install libx11-dev libxft-dev -y
  1. Ubuntu on WSL2 is missing X11 libraries, which have to be installed prior the compilation. Having all libraries ready, you can compile Relion. Here is how to compile the CPU accelerated version (the GPU version need way more tweaking).
1cd build
2
3rm -r *
4
5cmake -DALTCPU=ON ..
6
7make -j8
8
9#Depending on the number of available CPUs you can use more or less for the compilation step (-j N, where N is the number of CPUs)
  1. Compilation should finish without errors. Now the binaries can be moved to /usr/local/bin/ directory for global Relion installation, or can be used directly from the folder for local setup:
1sudo make install

or

1make install
  1. If Relion was installed locally, it can be added to $PATH:
1export PATH=$PATH:/home/*username*/relion/build/bin/
  1. And this is it! Relion should be working now. However, if the Windows build is quite old, the gWSL X-window server might not be present yet in the system. Thus, I’d suggest using VcXsrv Windows X Server . To make it work, start the X-windows server on Windows and export $DISPLAY using bash:
1export DISPLAY=:0

Now everything should be set to start work! Enjoy!