finnlennartsson / kpum_noddi

repo for processing of DKI/NODDI data for preterm project at KPUM
0 stars 0 forks source link

Install MRtrix3 in WSL #19

Closed finnlennartsson closed 1 year ago

finnlennartsson commented 1 year ago

MRtrix3 is installed by building from source.

Installed MRTrix3 by building from source and following instructions for MRtrix3 installation

BELOW IS DEPRECIATED The preferred method for installing MRtrix3 on Windows has been using msys2. The reason being that it should work with GUI (like mrview).

However, now that we can use WSLg #20, we can install MRtrix3 within WSLg instead.

Following instructions for MRtrix3 installation with (anaconda/)miniconda

# conda create --name kpum_wsl python=3.10
conda activate kpum_wsl
conda install -c mrtrix3 mrtrix3 
conda update -c mrtrix3 mrtrix3
finnlennartsson commented 1 year ago

However, problems with launching mrview

This best key is this post https://community.mrtrix.org/t/windows-11-mrtrix3-works-natively-on-wslg/5165 stating that everything worked out of the box.

Alternatively https://community.mrtrix.org/t/installing-on-windows-subsystem-for-linux-wsl/3637/2

which got the solution from Donald https://github.com/MRtrix3/mrtrix3/issues/2048

finnlennartsson commented 1 year ago

Could not launch mrview

$ mrview
mrview: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory

which solved by running

sudo apt-get install libgl1-mesa-dev

Then

(base) finn@LaptopFinn:~$ mrview
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, webgl, xcb.

Aborted

This was solved by https://github.com/NVlabs/instant-ngp/discussions/300#discussioncomment-4169112

sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
finnlennartsson commented 1 year ago

Now, mrview launches but is not working

(base) finn@LaptopFinn:~$ mrview
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
QOpenGLWidget: Failed to create context

This was solved by locating the file `` and putting a symbolic link into the search path

sudo mkdir /usr/lib/dri
sudo ln -sf /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so /usr/lib/dri/swrast_dri.so

Still problems

(base) finn@LaptopFinn:~$ mrview
libGL error: MESA-LOADER: failed to open swrast: /home/finn/Software/miniconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /lib/x86_64-linux-gnu/libLLVM-15.so.1) (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
QOpenGLWidget: Failed to create context

Following this post https://askubuntu.com/a/1422639 it was fixed in the same way by putting a symbolic link into the local miniconda

ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /home/finn/Software/miniconda3/bin/../lib/libstdc++.so.6

Or in the case of conda env kpum_wsl and for user radio

ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /home/radio/miniconda3/envs/kpum_wsl/bin/../lib/libstdc++.so.6