From 956a4490d22657fdaed46bcf1fcfe1778e5832e6 Mon Sep 17 00:00:00 2001 From: HelloCard <45723415+HelloCard@users.noreply.github.com> Date: Fri, 10 Oct 2025 17:03:40 +0800 Subject: [PATCH 1/3] Fix "cannot find -lcuda & -lcudart" problom in WSL2 nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used (Worker_TP0 pid=5917) ERROR 10-10 12:22:46 [multiproc_executor.py:671] [4/4] /root/miniconda3/bin/x86_64-conda-linux-gnu-c++ sampling/sampling.cuda.o sampling/renorm.cuda.o sampling/flashinfer_sampling_binding.cuda.o -shared -L/root/miniconda3/lib -L/root/miniconda3/lib64 -L/root/miniconda3/lib64/stubs -lcudart -lcuda -o sampling/sampling.so (Worker_TP0 pid=5917) ERROR 10-10 12:22:46 [multiproc_executor.py:671] FAILED: [code=1] sampling/sampling.so (Worker_TP0 pid=5917) ERROR 10-10 12:22:46 [multiproc_executor.py:671] /root/miniconda3/bin/x86_64-conda-linux-gnu-c++ sampling/sampling.cuda.o sampling/renorm.cuda.o sampling/flashinfer_sampling_binding.cuda.o -shared -L/root/miniconda3/lib -L/root/miniconda3/lib64 -L/root/miniconda3/lib64/stubs -lcudart -lcuda -o sampling/sampling.so (Worker_TP0 pid=5917) ERROR 10-10 12:22:46 [multiproc_executor.py:671] /root/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/11.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: cannot find -lcuda: No such file or directory because in WSL2, cuda.so set at /usr/lib/wsl/lib. https://github.com/microsoft/WSL/issues/8587 And add $cuda_home/lib to find libcudart.so in \root\miniconda3\lib, install by command "conda install cuda -c nvidia" --- flashinfer/jit/cpp_ext.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flashinfer/jit/cpp_ext.py b/flashinfer/jit/cpp_ext.py index fb0c40c00e..b81da5b352 100644 --- a/flashinfer/jit/cpp_ext.py +++ b/flashinfer/jit/cpp_ext.py @@ -168,6 +168,8 @@ def generate_ninja_build_for_op( ldflags = [ "-shared", + "-L/usr/lib/wsl/lib", + "-L$cuda_home/lib", "-L$cuda_home/lib64", "-L$cuda_home/lib64/stubs", "-lcudart", From 3ef85a665fb1a67f8ec96b57cb37fe6ed55d9aed Mon Sep 17 00:00:00 2001 From: HelloCard <45723415+HelloCard@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:12:05 +0800 Subject: [PATCH 2/3] Update cpp_ext.py --- flashinfer/jit/cpp_ext.py | 1 + 1 file changed, 1 insertion(+) diff --git a/flashinfer/jit/cpp_ext.py b/flashinfer/jit/cpp_ext.py index b81da5b352..bbcb90be24 100644 --- a/flashinfer/jit/cpp_ext.py +++ b/flashinfer/jit/cpp_ext.py @@ -166,6 +166,7 @@ def generate_ninja_build_for_op( # No module flags, use global flags cuda_cflags += global_flags + #/usr/lib/wsl/lib is for WSL2 users, their cuda.so is there ldflags = [ "-shared", "-L/usr/lib/wsl/lib", From a56c801cd0829257516475de8e0fdfa092c639d2 Mon Sep 17 00:00:00 2001 From: HelloCard <45723415+HelloCard@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:14:30 +0800 Subject: [PATCH 3/3] Update cpp_ext.py --- flashinfer/jit/cpp_ext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flashinfer/jit/cpp_ext.py b/flashinfer/jit/cpp_ext.py index bbcb90be24..ef92a3c212 100644 --- a/flashinfer/jit/cpp_ext.py +++ b/flashinfer/jit/cpp_ext.py @@ -166,7 +166,7 @@ def generate_ninja_build_for_op( # No module flags, use global flags cuda_cflags += global_flags - #/usr/lib/wsl/lib is for WSL2 users, their cuda.so is there + # /usr/lib/wsl/lib is for WSL2 users, their cuda.so is there ldflags = [ "-shared", "-L/usr/lib/wsl/lib",