i4Ds / Karabo-Pipeline

The Karabo Pipeline can be used as Digital Twin for SKA
https://i4ds.github.io/Karabo-Pipeline/
MIT License
11 stars 4 forks source link

Improve WSL-doc #550

Closed Lukas113 closed 6 months ago

Lukas113 commented 6 months ago

Currently, just following the dev-install instructions on WSL will fail with a weird error at pip install -e ".[dev]", becauseusr/lib/wsl/lib` is not available in the path.

The conda env config vars set LD_LIBRARY_PATH=/usr/lib/wsl/lib on the venv solves this issue, which is already in our documentation for the user-installation at the end. This should be more visible in the user and dev-installation doc at the point which is relevant (maybe already at the start of the section?)

sfiruch commented 6 months ago

Perhaps export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/custom/path/

Lukas113 commented 6 months ago

I think additional information regarding this issue is helpful. @kenfus do you know from where you have this and why it works? I'm asking, because I actually don't know why setting LD_LIBRARY_PATH=/usr/lib/wsl/lib works, because /usr/lib/wsl/lib doesn't exist. According to my knowledge, LD_LIBRARY_PATH just links shared library-files. However, when I tried to link the shared libraries using ldconfig using sudo bash -c 'echo /usr/lib/wsl/lib > /etc/ld.so.confg.d/wsl.conf'; sudo ldconfig, it didn't work. In addition, because I didn't see any wsl dir in usr/lib, I also tried adding just usr/lib to LD_LIBRARY_PATH, and it didn't work either. So I actually have no idea why adding /usr/lib/wsl/lib is working.

In addition, I think we should do one of the following, depending on the user-preference:

I've tested both, and they worked in my wsl-environment.

Lukas113 commented 6 months ago

After performing some updates on Windows, I have the following in usr/lib/wsl/lib:

image

However, it remains that only adding /usr/lib/wsl/lib to LD_LIBRARY_PATH works. I'm not sure why this is necessary for WSL, the error message is not very intuitive:

image

For the time beeing, I'll just update the doc accordingly.

sfiruch commented 6 months ago

Perhaps the installation script is relying on the env var? I saw that ldconfig & LD_LIBRARY_PATH work on different levels.

kenfus commented 6 months ago

/usr/lib/wsl/lib exists for me and contains some CUDA libraries, which was also the reason for me to add this to LD_LIBRARY_PATH because without, OSKAR would not run on the GPU. However, I never had to add it to install karabo locally with pip.

if "WSL" in platform.release() and (
    os.environ.get("LD_LIBRARY_PATH") is None
    or "wsl" not in os.environ["LD_LIBRARY_PATH"]
):
    wsl_ld_path = "/usr/lib/wsl/lib"
    if os.environ.get("LD_LIBRARY_PATH") is None:
        os.environ["LD_LIBRARY_PATH"] = wsl_ld_path
    else:
        os.environ["LD_LIBRARY_PATH"] = (
            os.environ["LD_LIBRARY_PATH"] + ":" + wsl_ld_path
        )
    # Restart Python Interpreter
    # https://stackoverflow.com/questions/6543847/setting-ld-library-path-from-inside-python
    os.execv(sys.executable, ["python"] + sys.argv)

We also have this hacky thing to make CUDA available for OSKAR when running Karabo on WSL. Maybe this causes an error if you don't have /usr/lib/wsl/lib but are running WSL for whatever reason?

EDIT: @Lukas113 I found this: https://superuser.com/questions/1832674/folder-usr-lib-wsl-is-missing-in-wsl-2

Ah sorry, I saw now that you have the folder. I can now also reproduce this problem in exact the same way and no, I don't know why editing the LD_LIBRARY_PATH changes anything. The only thing I could think of is that hacky thing in the init-file, which for some reason now is broken?