This guide gets the CUDA build of SAM3DBody-cpp running under WSL2 on Windows. WSL has two quirks that trip people up:
- You need a CUDA 12.x toolkit + cuDNN 9.x that match the ONNX Runtime 1.20.1 GPU build (see DEPENDENCIES.md).
- WSL prepends every Windows
PATHentry to your Linux environment, so the loader can pick up the Windows GPU driver instead of the WSL one unless you fixPATH/LD_LIBRARY_PATH(Step 6).
Do not install the full Linux NVIDIA driver inside WSL. The GPU driver lives on the Windows side. Inside WSL you install only the CUDA toolkit and cuDNN.
-
Windows 10/11 with WSL2 and an Ubuntu distro installed.
-
A recent NVIDIA driver installed on Windows (the WSL GPU passthrough comes from it).
-
Verify the GPU is visible from inside WSL before continuing:
nvidia-smi
This must list your GPU. If it doesn't, fix the Windows driver / WSL setup first — nothing below will work otherwise.
The build needs gcc-12, which isn't in the default repos on newer Ubuntu
releases. Add the archived lunar (23.04) universe repo to pull it in.
Open the sources file:
sudo nano /etc/apt/sources.list.d/ubuntu.sourcesPaste this at the end:
Types: deb
URIs: http://old-releases.ubuntu.com/ubuntu/
Suites: lunar
Components: universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Save, then refresh:
sudo apt updateIf your Ubuntu already provides
gcc-12(apt-cache policy gcc-12shows a candidate), you can skip this step.
sudo apt install gcc-12Install the WSL-Ubuntu CUDA toolkit (this guide uses 12.2):
Pick Linux → x86_64 → WSL-Ubuntu so you get the WSL package (not the full desktop driver).
Verify:
nvcc --versionExpected (version line is what matters):
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Cuda compilation tools, release 12.2, V12.2.91
Build cuda_12.2.r12.2/compiler.32965470_0
ONNX Runtime 1.20.1 requires cuDNN 9 — cuDNN 8 will not work and is the #1
cause of Failed to load library libonnxruntime_providers_cuda.so.
Get the install command for your distro here (choose Linux → x86_64 → Ubuntu, cuDNN for CUDA 12):
After installing, refresh the loader cache and confirm cuDNN 9 is present:
sudo ldconfig
ldconfig -p | grep -i cudnnYou should see libcudnn.so.9 listed.
Set -DCMAKE_CUDA_ARCHITECTURES for your card
(89 = Ada: RTX 40-series incl. RTX 4060; 86 = Ampere RTX 30-series;
75 = Turing RTX 20-series):
#!/bin/bash
THISDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$THISDIR"
cd ..
mkdir -p build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CUDA_ARCHITECTURES=89
make -j$(nproc)
exit 0Then build:
bash scripts/build.shWSL appends all Windows PATH entries to your Linux environment, so the loader
can resolve the Windows GPU driver path instead of the WSL one. Export clean
paths so Linux sees the WSL GPU libs (/usr/lib/wsl/lib) and your CUDA install:
export PATH=/usr/local/cuda-12.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export LD_LIBRARY_PATH=/usr/lib/wsl/lib:/usr/local/cuda-12.2/lib64Adjust
cuda-12.2to your installed version. To make this permanent, append the twoexportlines to~/.bashrc(thensource ~/.bashrc).
Before running the pipeline, confirm the ONNX Runtime CUDA provider has all its dependencies (no output = success):
ldd build/onnxruntime_dl/lib/libonnxruntime_providers_cuda.so | grep -i "not found"If anything shows up here, revisit Step 4 (cuDNN) and Step 6 (paths). See
DEPENDENCIES.md for the full troubleshooting flow, including
why a CPU fallback fails with Could not find an implementation for Expand(13).
Now run, e.g.:
scripts/webcam.shIf you installed Blender manually and the MakeHuman (MPFB) extension through
Blender's extension system, edit blender/blender_bvh_plugin.py.
Find:
if __name__ == "__main__":and inside the loop over add-ons add this elif:
elif "mpfb" in addon.lower(): # MPFB installed as a Blender extension
haveMPFB = TrueThanks to Vivek Chouhan ( https://www.linkedin.com/in/vivek-chouhan/ ) for providing this information!