C.W.K.
Stream
Lesson 04 of 05 · published

WSL이나 Linux에서 CUDA 깔기

~14 min · cuda, wsl, linux, ubuntu, setup

Level 0Beginner
0 XP0/38 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

Linux path: 같은 NVCC, 다른 패키지 layer

Linux setup은 두 flavor:

  • Native Linux (Ubuntu 22.04 / 24.04) — cloud VM이나 dedicated AI rig가 돌리는 거. 성능 최고, Nsight 풀 access.
  • WSL 2 on Windows — Windows 안의 진짜 Linux 커널, NVIDIA WSL driver 통해 실제 GPU 호출 가능. 같은 Linux toolkit, profiling 약간 손해, 근데 Windows 개발자가 Unix shell + 개발 도구 쓸 수 있음.

둘 다 같은 Linux CUDA toolkit 패키지를 써. WSL 특별점은 GPU driver가 Windows랑 공유라는 것 — WSL 안에선 Linux driver 안 깔고, 바깥 Windows에 driver 깔고, CUDA Linux userland가 passthrough로 호출.

막 깐 WSL에 nvcc가 왜 없냐

Windows쪽 CUDA installer는 Windows path에만 파일 떨궈. WSL 안엔 분리된 filesystem이 있어서 Linux쪽 toolkit 패키지 따로 깔아야 해. NVIDIA apt repo에 있어.

Code

Ubuntu 22.04에 CUDA 13.2 toolkit 설치 (native + WSL 둘 다)·bash
# Ubuntu 안 (native 또는 WSL)
sudo apt update
sudo apt install build-essential gnupg curl -y

# NVIDIA 패키지 키 + repo 추가
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub \
  | sudo tee /etc/apt/keyrings/nvidia.asc > /dev/null

echo 'deb [signed-by=/etc/apt/keyrings/nvidia.asc] \
https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /' \
| sudo tee /etc/apt/sources.list.d/cuda.list

sudo apt update
sudo apt install cuda-toolkit-13-2 -y

# PATH + library path 시스템 전체에 박기
echo 'export PATH=/usr/local/cuda-13.2/bin:$PATH' | sudo tee /etc/profile.d/cuda.sh
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-13.2/lib64:$LD_LIBRARY_PATH' \
  | sudo tee -a /etc/profile.d/cuda.sh
source /etc/profile.d/cuda.sh

nvcc --version  # release 13.2
흔한 WSL 함정 + 해결·bash
# WSL 안에서 'nvidia-smi: command not found'
#   → Windows쪽 NVIDIA driver 충분히 최신인지 확인 (CUDA on WSL은 driver 470+ 필요).

# 설치 후에도 'nvcc: command not found'
#   → source /etc/profile.d/cuda.sh, 또는 새 shell 열기.

# 서드파티 코드 컴파일 시 'cuda.h: No such file or directory'
#   → -I/usr/local/cuda/include 컴파일 플래그에 추가.

# 첫 커널 launch 느림 (~1-2초)
#   → JIT warm-up 중. 자기 sm_XX로 pre-compile 하면 스킵.

External links

Exercise

쓸 수 있는 Linux flavor 아무거나 (native, WSL, Colab) 잡고 nvcc --version 초록불 만들기. Colab이면 노트북 열어서 runtime을 GPU로 바꾸고 cell에 !nvcc --version 돌리는 거. 기준 동일: version string 나오면 OK. 여기서 멈춰 — 다음 레슨이 방금 깐 거 써.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.