WSL: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
Environment
- WIN10 Insider Preview 20175.rs_prerelease.200717-1349
- WSL2 ->ubuntu18.04
- darknet-CUDA
Question
I can successfully use tensorflow-gpu under ubuntu18.04-wsl2 with install 455.41_gameready_win10-dch_64bit_international.exe, but when I start to compile darknet it prompts error :
sh /usr/bin/ld: cannot find -lcuda collect2: error: ld returned 1 exit status
So i execute sudo ldconfig -v:
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
libcuda.so.1 -> libcuda.so.1.1
Then execute sudo ln -sf /usr/lib/wsl/lib/libcuda.so.1.1 /usr/lib/wsl/lib/libcuda.so.1,
it prompts ln: failed to create symbolic link '/usr/lib/wsl/lib/libcuda.so.1': Read-only file system
How can I successfully compile darknet?Thanks
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 45
- Comments: 28
Links to this issue
Commits related to this issue
- ubuntu22/wsl2_build: add ubuntu22.04 build for WSL - Need to install dependencies for qwt using the install_qt_ubuntu.sh script - Fix libcuda simlink - NVidia driver problem on WSL2: - https://gi... — committed to analogdevicesinc/scopy by Adrian-Stanea 3 years ago
- ubuntu22/wsl2_build: add ubuntu22.04 build for WSL - Need to install dependencies for qwt using the install_qt_ubuntu.sh script - Fix libcuda simlink - NVidia driver problem on WSL2: - https://gi... — committed to analogdevicesinc/scopy by Adrian-Stanea 3 years ago
- ubuntu22/wsl2_build: add ubuntu22.04 build for WSL - Fix libcuda simlink - NVidia driver problem on WSL2: - https://github.com/microsoft/WSL/issues/5663#issuecomment-1068499676 - https://foru... — committed to analogdevicesinc/scopy by Adrian-Stanea 3 years ago
- ubuntu22/wsl2_build: add ubuntu22.04 build for WSL - Fix libcuda simlink - NVidia driver problem on WSL2: - https://github.com/microsoft/WSL/issues/5663#issuecomment-1068499676 - https://foru... — committed to analogdevicesinc/scopy by Adrian-Stanea 3 years ago
Please review response post by @Phyx-Meow re: https://github.com/yuk7/ArchWSL/issues/248.
As he points out, it really has nothing to do with your Linux install. It’s a simple fix in Windows. The solution he posts is for Arch, but the fix is exactly same for Ubuntu, etc. in a WSL2 install. The issue is that Windows delivers libcuda.so, libcuda.so.1, and libcuda.so.1.1 as fully separate copies of the same file. The fix is just to remove libcuda.so and libcuda.so.1, and just make sym links for each of them to libcuda.so.1.1
Run a command line shell as Administrator, type “cmd” to get a non-powershell command line.
Then type the following commands to create the problematic symbolic links:
C: cd \Windows\System32\lxss\lib del libcuda.so del libcuda.so.1 mklink libcuda.so libcuda.so.1.1 mklink libcuda.so.1 libcuda.so.1.1
when you’re done, it will look like this:
C:\Windows\System32\lxss\lib> DIR … <stuff deleted> … Directory of C:\Windows\System32\lxss\lib 03/15/2022 04:00 PM <DIR> . 03/15/2022 03:59 PM <SYMLINK> libcuda.so [libcuda.so.1.1] 03/15/2022 04:00 PM <SYMLINK> libcuda.so.1 [libcuda.so.1.1]
Then, just finish your command you were running, in my case, the solution was just run “apt reinstall libc-bin”. This is because libc-bin was getting the errors when I had run “apt upgrade -y” command. (see below)
The error I received in my “apt upgrade -y” command was two lines: #> apt upgrade -y … < stuff deleted > … Processing triggers for libc-bin (2.31-0ubuntu9.7) … /sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link … < stuff deleted > …
As per @Phyx-Meow
“Actually this is not relate to Arch, nor ArchWSL. It’s caused by libcuda.so in your C:\Windows\System32\lxss\lib\ folder not a symbolic link, which is installed by nvidia driver. One solution to [remove] the warning is delete libcuda.so and libcuda.so.1 and use make symbolic link to libcuda.so.1.1. Command line: mklink <target file> <source file>. Note the command not work in powershell, you shall use cmd.exe.”
😃
I was able to build darknet by making a symlink to the directory where the rest of my cuda library files were
/usr/local/cuda/lib64by doing:sudo ln -s /usr/lib/wsl/lib/libcuda.so.1 /usr/local/cuda/lib64/libcuda.soWith the help of: https://github.com/pjreddie/darknet/issues/1480
@ArrowRaider Try restart wsl2, or restart your pc.
I’m noticing that this error (or warning?) is showing when installing
python3-pip. At the end of the installation I see:When inspecting the
/usr/lib/wsl/lib/folder, I see that in fact there are three files, none of which are symlinks:So my fix was not so much to do anything on the Windows side, but rather directly in WSL Ubuntu 22.04:
Now when I run
sudo apt reinstall libc-binI no longer get the error (or warning).UPDATE: I did also change things on the Windows side as indicated by @John-Joubert :
And after uninstalling Ubuntu 22.04 and re-installing again, I’m seeing that there are now symlinks in the
/usr/lib/wsl/lib/folder. I’m not sure if this is due to changes in the filesystem persisting on the WSL side through awsl --unregister Ubuntu-22.04in Powershell and then a re-install (which I highly doubt because my filesystem seems to have a clean slate), or if in the install process it’s picking up the changes from the Windows side (most likely the case).@John-Joubert that worked for me… I’m wondering why this bug is closed if we still have to do this manual workaround. – Why can’t this just be fixed in WSL?
/dupe #5548
This is specifically for Nvidia CUDA in WSL 2 with the Windows Insider Preview on the Dev Channel. I followed this guide after I had Windows Insider Preview on Dev Channel set up: https://docs.microsoft.com/en-us/windows/win32/direct3d12/gpu-cuda-in-wsl
I don’t find the folder /usr/lib/wsl, How do you get it ? Or how do you install the cuda?
Hi! We’ve identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.
Thanks for your report!
Why was this issue closed? The problem still persists for me, and I find myself having to use the manual workaround. Could someone take another look, please?
@John-Joubert This did not help me. It still says
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic linkwhenever ldconfig is run.My directory listing in the one folder is this:
I made a slight tweak to your command for anyone struggling getting this to work. Adding && between the various commands ensures proper evaluation from left to right, otherwise users might run into
The system cannot find the path specified.cd C:\Windows\System32\lxss\lib && del libcuda.so && del libcuda.so.1 && mklink libcuda.so libcuda.so.1.1 && mklink libcuda.so.1 libcuda.so.1.1If the error persists after doing the command, shutdown and restart wsl.
When I do this things then have something like this:
And CPU not GPU doing all 😦
Same with me. Workaround only survives until next nvidia driver update, then it must be done again.
This approach worked to me, but on the next day my WSL 2 crashed. Then I just give an
wsl --updateon the PoweShell and it worked again.same issue… Does this need to be open?
A manual workaround that requires admin privileges isn’t feasible for most.