tiny-cuda-nn icon indicating copy to clipboard operation
tiny-cuda-nn copied to clipboard

Pytorch extension fails to install on WSL Ubuntu 20.04, Cuda 11.3/11.6

Open sbudhram opened this issue 2 years ago • 8 comments

I'm trying to setup ngp_pl (https://github.com/kwea123/ngp_pl) on a Win11 system, using WSL and Ubuntu 20.04.
I'm using a RTX 4080. I install WSL, Ubuntu and the CUDA 11.3 WSL drivers following nvidia instructions here, and verify it works: https://docs.nvidia.com/cuda/wsl-user-guide/index.html

I install Anaconda for WSL and that works fine too, and setup a virtual environment.

I install PyTorch 1.12.1 with CUDA 11.3 using this command: pip3 install torch==1.12.1 torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113

Before trying to install tiny-cuda-nn, I run these two commands: export TCNN_CUDA_ARCHITECTURES=86 (otherwise it complains about 89 architecture) export PATH=/usr/local/cuda/bin:$PATH (or it may fail because of missing references in this folder.

I clone this tiny-cuda-nn repo, drop into the bindings/torch directory, and run 'python setup.py install'.

It fails with this error in the last line: g++ -pthread -B /home/shaun/anaconda3/envs/ngp_pl/compiler_compat -Wl,--sysroot=/ -pthread -shared -B /home/shaun/anaconda3/envs/ngp_pl/compiler_compat -L/home/shaun/anaconda3/envs/ngp_pl/lib -Wl,-rpath=/home/shaun/anaconda3/envs/ngp_pl/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-cpython-38/../../dependencies/fmt/src/format.o build/temp.linux-x86_64-cpython-38/../../dependencies/fmt/src/os.o build/temp.linux-x86_64-cpython-38/../../src/common.o build/temp.linux-x86_64-cpython-38/../../src/common_device.o build/temp.linux-x86_64-cpython-38/../../src/cpp_api.o build/temp.linux-x86_64-cpython-38/../../src/cutlass_mlp.o build/temp.linux-x86_64-cpython-38/../../src/encoding.o build/temp.linux-x86_64-cpython-38/../../src/fully_fused_mlp.o build/temp.linux-x86_64-cpython-38/../../src/network.o build/temp.linux-x86_64-cpython-38/tinycudann/bindings.o -L/home/shaun/anaconda3/envs/ngp_pl/lib/python3.8/site-packages/torch/lib -L/usr/local/cuda/lib64 -lcuda -lcudadevrt -lcudart_static -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda_cu -ltorch_cuda_cpp -o build/lib.linux-x86_64-cpython-38/tinycudann_bindings/_86_C.cpython-38-x86_64-linux-gnu.so /home/shaun/anaconda3/envs/ngp_pl/compiler_compat/ld: cannot find -lcuda: No such file or directory

I tried replacing -lcuda with -L/usr/local/cuda and that seemed to fix this single instance, but I don't know how to fix this globally to let the script complete. Any suggestions?

I also tried this process with Cuda 11.6 and ran into the same issue. I also tried using PIP instead of Anaconda, same issue.

sbudhram avatar Feb 24 '23 01:02 sbudhram

I was able to get this to work by cd'ing to the /usr/local/cuda/lib64 directory and symbolically linking this library to the expected location. Not sure why this script is unable to find it though. sudo ln -s stubs/libcuda.so libcuda.so

sbudhram avatar Feb 24 '23 21:02 sbudhram

Thank you! your guide saved me!

And I'll list up my specs: Win11+WSL2+ubuntu22.04.2 distro 13700kf + RTX 4090 cuda11.7 pytorch 11.3+cuda11.7 toolkit installed by anaconda

I was able to get this to work by cd'ing to the /usr/local/cuda/lib64 directory and symbolically linking this library to the expected location. Not sure why this script is unable to find it though. sudo ln -s stubs/libcuda.so libcuda.so

qgli avatar Mar 06 '23 00:03 qgli

Hi, does it also work for you if you only use

libraries=["cudart"],

?

Tom94 avatar Apr 18 '23 13:04 Tom94

I was able to get this to work by cd'ing to the /usr/local/cuda/lib64 directory and symbolically linking this library to the expected location. Not sure why this script is unable to find it though. sudo ln -s stubs/libcuda.so libcuda.so

sudo ln -s /usr/lib/wsl/lib/libcuda.so libcuda.so

works for me.

hlpan avatar Jun 09 '23 06:06 hlpan

I was able to get this to work by cd'ing to the /usr/local/cuda/lib64 directory and symbolically linking this library to the expected location. Not sure why this script is unable to find it though.

sudo ln -s stubs/libcuda.so libcuda.so

Thank god, this workaround save me too~

GaussianGuaicai avatar Jul 04 '23 02:07 GaussianGuaicai

you know what? I don't know exactly where my settings worked, anyway, after I made some settings, I used the author's recommended 'pip install git'+ https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch ”It was unexpectedly installed successfully. I recalled these actions: ① reinstalling cudatoolkit11.8, ② using the sudo ln - s/usr/lib/wsl/lib/libcuda.so libcuda.so command, seems to be the most important of these two changes? Then the installation was successful.

Pythonpa avatar Aug 21 '23 16:08 Pythonpa

this solution works for me https://github.com/NVlabs/tiny-cuda-nn/issues/183#issuecomment-1342828785

roycezjq avatar Sep 20 '23 07:09 roycezjq

Doing this somewhere along the line worked for me:

export LIBRARY_PATH=/usr/local/cuda/lib64/stubs:$LIBRARY_PATH

object404 avatar Sep 26 '23 09:09 object404