← Back to list

Supercharge Your Machine Learning with GPU: A Complete RAPIDS (cuML/cuDF) Setup Guide for Python

Dall-E

Zackary in Tech Journal by Zackary · 2025-01-14 08:47 · 0 claps · 4.5 min read
#gpu #installation-guide #cuml #rapid #wsl
Open on Medium ↗
Wiki topics: MM · Multimodal & Generative Media OPS · LLMOps & Inference ML · Machine Learning EDU · Education & Learning

Use GPUs for Machine Learning: RAPIDS (cuML, cuDF) Setup Guide

Dall-E

Dall-E

Table of contents

· Introduction · Prerequisite · Step-by-Step InstallationStep 1: Install Windows WSL2Step 2: Install Nvidia driverStep 3: Log in to WSL2Step 4: Install conda in the wsl2Step 5: Install RAPIDS via condaStep 6: Check installation · Setting Up RAPIDS in VSCodeInstall VSCode for WSL2 · Example: Using cuDF and cuMLcuDF Example: DataFrame ManipulationcuML Example: Linear Regression · Conclusion

Introduction

Imagine speeding up data processing and machine learning model training from hours to just minutes. This is the power of GPU acceleration.

In this guide, you’ll learn how to set up a GPU-accelerated Python environment using RAPIDS on Windows with WSL2. RAPIDS, which includes cuDF for data manipulation and cuML for machine learning, will enable you to fully leverage your GPU’s computational power and significantly boost performance.

We’ll walk you through every step, including how to directly use this environment in VSCode, allowing you to seamlessly work with your GPU-accelerated setup for machine learning and data analysis. By the end of this tutorial, you’ll be equipped to accelerate your workflows and harness the full power of your GPU with ease.

Prerequisite

  • GPU compute capability > 7.0 (Check your GPU here)
  • OS: Linux or Windows 10/11 using WSL2 (We’ll cover the full installation for Windows 10 with WSL2. Although the official guide recommends Windows 11, it also works on Windows 10 based on our testing.)
  • CUDA: CUDA installation details can be found in Part 4.1 of my previous Medium article. For this example, we use CUDA 11.2.

For more details, refer to the official RAPIDS Installation Guide.

Step-by-Step Installation

Step 1: Install Windows WSL2

WSL2 enables running a Linux environment on Windows. Of course, you can Follow the official Microsoft guide, or you can directly follow the steps below:

  1. Open the Command Prompt and run:
wsl --install
  1. After installation, reboot your computer when prompted.

  2. If WSL2 isn’t set as the default version, set it with:

wsl --set-default-version 

Note: If you leave the WSL2 environment for any reason and later return, you can simply open the command prompt again and type wsl to access it. After you access WSL, you may also encounter a path like /mnt/c/Users/zackary; to switch to your Linux home directory, run:

cd ~

Step 2: Install Nvidia driver

  1. Visit the NVIDIA Driver Download Page, then select your GPU model and operating system. Download and install the latest drivers. For example, in our setup, we use the NVIDIA T400 with Windows 10, and the system suggests installing driver version 553.50 (check the pictures below).

  1. After downloading, follow the installation instructions provided on the page.

Step 3: Log in to WSL2

  1. First time you need to create account by entering username and password

  1. You should see the Linux terminal after logging in successfully.

Step 4: Install conda in the wsl2

  1. Install Miniconda3 (a minimal installer for Conda):
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
  1. Initialize Conda:
source ~/miniconda3/bin/activate
conda init --all
  1. Set Conda’s channel priority to flexible:
conda config --show channel_priority  # must be "flexible"
conda config --set channel_priority flexible   # if not "flexible", set to "flexiable"

Step 5: Install RAPIDS via conda

  1. Create a Conda environment with RAPIDS:
conda create -n rapids-24.12 -c rapidsai -c conda-forge -c nvidia  \
    rapids=24.12 python=3.12 'cuda-version>=12.0,<=12.5'
  1. After installing, you can find your Conda environment in your WSL2 directory.
\\wsl.localhost\Ubuntu\home\zackary\miniconda3\envs\rapids-24.12

Step 6: Check installation

  1. Start Python in WSL2:
python
  1. Test cuDF (data manipulation):
import cudf
print(cudf.Series([1, 2, 3]))

You should see the following output:

0    1
1    2
2    3
dtype: int64

Setting Up RAPIDS in VSCode

Install VSCode for WSL2

  1. Install the Remote — WSL extension in VSCode:
  • Open VSCode and press Ctrl+Shift+P.
  • Type Remote-WSL and install the extension.

  1. Configure Conda in VSCode’s terminal:
  • Open the terminal in VSCode (Ctrl+ `) and run:
conda init bash
source ~/.bashrc
conda activate rapids-24.12
  1. Test GPU availability with CuPy:
import cupy as cp
print("Is GPU available in CuPy:", cp.cuda.is_available())

Your expected result should look like this:

Example: Using cuDF and cuML

Once you’ve set up the environment, you can start using RAPIDS libraries like cuDF for data manipulation and cuML for machine learning.

cuDF Example: DataFrame Manipulation

import cudf

# Create a cuDF DataFrame
data = cudf.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
print("cuDF DataFrame:")
print(data)

# Perform operations
data['c'] = data['a'] + data['b']
print("After adding columns:")
print(data)

cuML Example: Linear Regression

import numpy as np
import cudf
from cuml.linear_model import LinearRegression

# Generate sample data
X = np.random.rand(100, 3).astype('float32')
y = np.dot(X, np.array([1.5, -2.0, 1.0])) + 0.5

# Convert data to GPU arrays
X_gpu = cudf.DataFrame.from_records(X)
y_gpu = cudf.Series(y)

# Train a linear regression model
model = LinearRegression()
model.fit(X_gpu, y_gpu)

# Display model coefficients
print("Model coefficients:")
print(model.coef_)
print("Intercept:", model.intercept_)

Conclusion

Congratulations! You’ve successfully set up a GPU-accelerated Python environment using RAPIDS on WSL2. Now, you can use cuDF for fast data manipulation and cuML for GPU-accelerated machine learning, significantly speeding up your workflows.

Keep exploring RAPIDS to unlock the full power of your GPU and elevate your data science and machine learning projects.


메타데이터
post_id
68dc6c077477
slug
supercharge-your-machine-learning-with-gpu-a-complete-rapids-cuml-cudf-setup-guide-for-python-68dc6c077477
url
https://medium.com/zackary-yen/supercharge-your-machine-learning-with-gpu-a-complete-rapids-cuml-cudf-setup-guide-for-python-68dc6c077477
canonical_url
https://medium.com/zackary-yen/supercharge-your-machine-learning-with-gpu-a-complete-rapids-cuml-cudf-setup-guide-for-python-68dc6c077477
author_url
https://medium.com/@zackary_yen
status
ok
fetched_at
2026-07-21 08:10:39