WSL2 Setup

1. Install CUDA Toolkit

WSL2 uses the NVIDIA driver which is installed in your Windows host. As such, you should ensure that you do not install a NVIDIA driver in your WSL2 distribution. More information about WSL2 and using CUDA can be found on this page CUDA Toolkit - WSL2.

For installation instructions, you can refer to the following links:

2. Setup Environment Variables

Once you have CUDA Toolkit installed, you need to setup the following environment variables in your WSL2 distribution.

export CUDA_PATH=/usr/local/cuda
export PATH=$CUDA_PATH/bin:$PATH
export LIBRARY_PATH=$CUDA_PATH/lib64/stubs:$CUDA_PATH/lib64:$LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_PATH/lib64:$LD_LIBRARY_PATH

You can use these commands to updates the environment variables from your ~/.bashrc file automatically.

echo 'export CUDA_PATH=/usr/local/cuda' >> ~/.bashrc
echo 'export PATH=$CUDA_PATH/bin:$PATH' >> ~/.bashrc
echo 'export LIBRARY_PATH=$CUDA_PATH/lib64/stubs:$CUDA_PATH/lib64:$LIBRARY_PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$CUDA_PATH/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc

3. Install CV-CUDA

Once you have completed the above steps, you can install CV-CUDA in your WSL2 distribution. Please refer to the Installation guide for detailed instructions on installing CV-CUDA. A summary of the installation methods is provided below.

Method 2: Install from Pre-built Packages

Download and install Debian packages or tar archives from the CV-CUDA GitHub Releases page.

Method 3: Build from Source

For building CV-CUDA from source in WSL2, follow the Building from Source instructions.