This note describes a practical way to use GPU-accelerated deep learning tools from a WSL terminal by calling the Windows Conda and Python executables. At the time this was written, CUDA GPU access was not available to Linux binaries running directly inside WSL, so the reliable workaround was to install CUDA, cuDNN, Conda, and TensorFlow on Windows, then invoke the Windows executables from the WSL shell.
Table of Contents
0. Install WSL, Xfce, and VcXsrv
Install WSL and a lightweight Linux desktop environment such as Xfce if you want GUI support. Install and start VcXsrv on Windows, then start Xfce from WSL:
startxfce4
If you only need terminal-based Python scripts or notebooks, the desktop environment is optional.
1. Install Miniconda on Windows
Install Miniconda for Windows and select the installer options that make conda and python available from the Windows command line. The important point is that Conda must be installed on Windows, not only inside WSL, because the GPU-enabled TensorFlow package will use the Windows NVIDIA driver and CUDA libraries.
After installation, confirm from Windows PowerShell or Command Prompt that Conda works:
conda --version
python --version
2. Add aliases in WSL
Add aliases to the end of ~/.bashrc so commands typed in WSL call the Windows executables:
alias python="python.exe"
alias conda="conda.exe"
alias ipython="ipython.exe"
alias nosetests="nosetests.exe"
alias pip="pip.exe"
Reload the shell configuration:
source ~/.bashrc
Then check that WSL resolves the Windows tools:
which python
python --version
conda --version
3. Install TensorFlow GPU support
Create a Conda environment from WSL. Because of the aliases above, this still uses Windows Conda:
conda create -n tf-gpu python=3.6
conda activate tf-gpu
pip install tensorflow-gpu
For older TensorFlow releases, the required CUDA and cuDNN versions must match the TensorFlow build. If an install fails or TensorFlow cannot load the GPU libraries, check the TensorFlow version compatibility table and install the corresponding CUDA and cuDNN versions on Windows.
4. Install CUDA support on Windows
Install the NVIDIA GPU stack on Windows:
- NVIDIA GPU drivers — CUDA 9.0 requires driver version 384.x or higher.
- CUDA Toolkit — older TensorFlow GPU builds commonly used CUDA 9.0.
- CUPTI — shipped with the CUDA Toolkit.
- cuDNN SDK — use the cuDNN version required by the TensorFlow release, such as 7.2 or newer for compatible older builds.
After installing these packages, make sure the CUDA and cuDNN DLL directories are available on the Windows PATH.
5. Run Python scripts from WSL
Run scripts from the WSL terminal as usual:
python train.py
The command is executed by python.exe, so it runs as a Windows Python process while still being launched from the WSL shell.
You can verify TensorFlow GPU visibility with:
import tensorflow as tf
print(tf.test.is_gpu_available())
For newer TensorFlow 2.x environments, use:
import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))
P.S. Hyper Terminal can be used to improve the terminal experience.
