CUDA Toolkit 설치 (Ubuntu, WSL)

WSL, Linux 기반 환경에서 CUDA Toolkit 설치

CUDA 설치 - Linux

  1. WSL 환경
  2. CUDA Toolkit 설치
  3. CUDA cuDNN 설치

1. WSL

Install WSL 2

1
wsl.exe --install

Ensure you have the latest WSL kernel:

1
wsl.exe --update

CUDA support for WSL2

WSL 의 Linux에 NVIDIA Driver 를 설치하면 안된다.


2. CUDA Toolkit 설치

cuda toolkit 과 cudnn 을 설치한다. 설치한 버전의 환경변수를 설정한다.

1. CUDA Toolkit 설치

https://developer.nvidia.com/cuda-downloads

2. cuDNN 설치

https://developer.nvidia.com/cudnn

3. 환경변수

설치한 cuda 버전에 맞춰 CUDA_PATH, PATH, LD_LIBRARY 를 설정해 준다.

1
2
3
4
5
# CUDA PATH
export CUDA_PATH=/usr/local/cuda-13.2
export CUDA_HOME=/usr/local/cuda-13.2
export PATH=$CUDA_PATH/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-13.2/lib64:$LD_LIBRARY_PATH

nvcc 명령이 실행되는지 확인한다.

1
2
3
4
5
6
~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on Thu_Mar_19_11:12:51_PM_PDT_2026
Cuda compilation tools, release 13.2, V13.2.78
Build cuda_13.2.r13.2/compiler.37668154_0

OLD 문서

WSL 에서 CUDA 사용을 위한 User Guide

Miniforge로 Conda 환경 설정하기

https://github.com/conda-forge/miniforge

1
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"

설치를 시작한다.

1
2
3
4
5
6
7
8
9
10
11
12
$ sh Miniforge3-Linux-x86_64.sh

Welcome to Miniforge3 26.3.2-2

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>


Do you accept the license terms? [yes|no]
>>> yes

설치 위치를 정한다.

1
2
3
4
5
6
7
8
Miniforge3 will now be installed into this location:
/home/qkboo/miniforge3

- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below

[/home/qkboo/miniforge3] >>>

기본 base 환경 자동 처리

1
2
3
4
5
6
7
8
9
10
11
12
13
installation finished.
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
run the following command when conda is activated:

conda config --set auto_activate_base false

Note: You can undo this later by running `conda init --reverse $SHELL`

Proceed with initialization? [yes|no]
[no] >>> yes

초기화를 진행하면 아래 같이 .bashrc 에 추가된다.

conda init 명령을 사용할 수 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
The following has been added in your "/home/qkboo/.bashrc" file

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba shell init' !!
export MAMBA_EXE='/home/qkboo/.local/miniforge3/bin/mamba';
export MAMBA_ROOT_PREFIX='/home/qkboo/.local/miniforge3';
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
alias mamba="$MAMBA_EXE" # Fallback on help from mamba activate
fi
unset __mamba_setup
# <<< mamba initialize <<<

이후 (base) 환경을 자동화 하지 않으려면

1
conda config --set auto_activate_base false

Conda Channel 관리

a. conda-forge만 있는지 확인:

conda config –show channels
b. 다른 채널 제거:

conda config –remove channels {채널명}
c. conda-forge 추가:

conda config –add channels conda-forge