GPU 설정
이 문서는 처음에 Ubuntu 26.04 LTS 2026년 4월 릴리스 노트와 비교하여 확인되었습니다. AI/GPU 드라이버 및 CUDA/ROCm 버전은 여전히 공급업체 지원 매트릭스에 대한 지속적인 검증이 필요합니다.
GPU는 대부분의 AI 워크로드를 실행하는 핵심 하드웨어입니다. 이 문서에서는 드라이버 설치, CUDA 툴킷, cuDNN 및 확인 단계를 포함하여 Ubuntu 26.04에서 NVIDIA GPU 환경을 구성하기 위한 자세한 가이드를 제공합니다. 또한 AMD GPU ROCm 구성에 대해서도 간략하게 다룹니다.
26.04 저장소 상태
Ubuntu 26.04 리포지토리는 이제 NVIDIA CUDA 툴킷(sudo apt install cuda-toolkit) 및 AMD ROCm을 제공합니다. 7.1.0 (sudo apt install rocm). 기본적으로 사전 설치되어 있지 않습니다. 프로덕션 교육의 경우 특정 PyTorch/TensorFlow 버전 또는 다중 GPU 서버는 NVIDIA/AMD 공급업체 지원 매트릭스 및 프레임워크 릴리스 노트를 최종 정보 소스로 계속 취급합니다.
NVIDIA 드라이버 설치
Ubuntu 26.04은 NVIDIA 드라이버 설치를 위한 편리한 ubuntu-drivers 도구를 제공합니다.
하드웨어 확인
# View NVIDIA GPUs in the system
lspci | grep -i nvidia
# Check recommended driver versions
sudo ubuntu-drivers devices예제 출력:
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00002684sv...
vendor : NVIDIA Corporation
model : AD102 [GeForce RTX 4090]
driver : nvidia-driver-560 - third-party non-free recommended
driver : nvidia-driver-550 - third-party non-free
driver : nvidia-driver-555 - third-party non-free자동 설치(권장)
# Automatically install the recommended driver version
sudo ubuntu-drivers autoinstall
# Reboot to activate the driver
sudo reboot특정 버전의 수동 설치
# View available driver versions
apt list nvidia-driver-* 2>/dev/null | grep -v "Listing"
# Install a specific version
sudo apt install -y nvidia-driver-560
# Reboot
sudo rebootNVIDIA 공식 저장소(최신 버전)에서 설치
# Add the NVIDIA official repository (Ubuntu 26.04 uses ubuntu2604)
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
# Install the latest driver
sudo apt install -y nvidia-open
# Reboot
sudo reboot드라이버 설치 확인
# Check driver version and GPU status
nvidia-smi일반 출력 예:
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.03 Driver Version: 560.35.03 CUDA Version: 12.6 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 4090 Off | 00000000:01:00.0 On | Off |
| 0% 35C P8 18W / 450W | 512MiB / 24564MiB | 0% Default |
+-----------------------------------------+------------------------+----------------------+nvidia-smi 출력에 표시된 “CUDA 버전”은 실제로 설치된 CUDA 툴킷 버전이 아니라 드라이버에서 지원하는 가장 높은 CUDA 버전을 나타냅니다. CUDA 툴킷을 별도로 설치해야 합니다.
CUDA 툴킷 설치
CUDA 툴킷은 대부분의 AI 프레임워크(PyTorch, TensorFlow 등)에 필요한 NVIDIA의 GPU 컴퓨팅 플랫폼 및 프로그래밍 모델입니다.
드라이버와 CUDA 버전의 관계
각 CUDA 툴킷에는 최소 NVIDIA 드라이버 버전이 필요하며 최신 CUDA에는 최신 드라이버가 필요합니다. 설치하기 전에 NVIDIA CUDA 툴킷 릴리스 노트 및 PyTorch /TensorFlow의 버전 지원 매트릭스를 참조하여 조합을 선택하세요. 세 가지 모두와 호환됩니다. 일반적인 접근 방식: nvidia-smi을 실행하여 드라이버가 지원하는 최고 CUDA 버전을 확인한 다음 그에 따라 CUDA 툴킷과 프레임워크 휠을 선택합니다.
방법 1(권장): Ubuntu 26.04 리포지토리에서 설치
Ubuntu 26.04은 저장소에 CUDA 툴킷을 제공합니다. 대부분의 로컬 개발에서는 이것이 가장 간단한 옵션입니다.
# Install the CUDA Toolkit from the Ubuntu repository
sudo apt install -y cuda-toolkit
# Verify
nvcc --version방법 2: NVIDIA 리포지토리에서 특정 버전 설치
특정 CUDA 툴킷 버전이 필요한 경우(예: 특정 PyTorch 휠과 일치시키기 위해):
# Add the NVIDIA official repository (Ubuntu 26.04 uses ubuntu2604)
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
# List available CUDA Toolkit versions in the repository
apt-cache search cuda-toolkit
# Install a specific version (replace XX-Y with an actual available version, e.g. cuda-toolkit-13-0)
sudo apt install -y cuda-toolkit-XX-YUbuntu 26.04는 이제 공식 저장소에 NVIDIA CUDA 툴킷을 제공하므로 sudo apt install cuda-toolkit이 직접 작동합니다. NVIDIA의 ubuntu2604 저장소는 특정 CUDA 버전이 필요할 때(예: 특정 PyTorch 휠과 일치시키기 위해) 여전히 유용합니다.
환경 변수 구성
# Add CUDA to PATH
cat >> ~/.bashrc << 'EOF'
# CUDA Toolkit
export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
EOF
source ~/.bashrcCUDA 설치 확인
# Check CUDA compiler version
nvcc --version
# Example output:
# nvcc: NVIDIA (R) Cuda compiler driver
# Cuda compilation tools, release X.Y, VX.Y.xxx
# Run CUDA samples (optional)
# Newer CUDA versions no longer ship samples with the Toolkit; clone them from GitHub
sudo apt install -y cmake build-essential git
git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples
cmake -B build && cmake --build build -j$(nproc)
# Run device query (path may vary by version)
./build/Samples/1_Utilities/deviceQuery/deviceQuery
# If output shows "Result = PASS", installation is successful여러 CUDA 버전 설치
# With the NVIDIA repository you can install multiple versions (replace XX-Y with actual versions)
sudo apt install -y cuda-toolkit-XX-Y
sudo apt install -y cuda-toolkit-ZZ-W
# View installed versions
ls /usr/local/ | grep cuda
# Switch default version (by updating the symlink; replace X.Y with the target version)
sudo rm /usr/local/cuda
sudo ln -s /usr/local/cuda-X.Y /usr/local/cuda
# Verify current version
nvcc --versioncuDNN 설치
cuDNN(CUDA Deep Neural Network 라이브러리)은 NVIDIA의 딥러닝 가속 라이브러리입니다. PyTorch와 TensorFlow 모두 이에 의존합니다.
apt를 통해 설치(권장)
# Ensure the NVIDIA repository has been added
# Install cuDNN for CUDA 12
sudo apt install -y cudnn9-cuda-12
# Or install specific packages
sudo apt install -y libcudnn9-cuda-12 libcudnn9-dev-cuda-12
# Verify installation
dpkg -l | grep cudnntar 패키지를 통해 설치
# Download cuDNN from the NVIDIA developer website
# https://developer.nvidia.com/cudnn-downloads
# Requires a free NVIDIA developer account
# Extract to the CUDA directory
sudo tar -xzf cudnn-linux-x86_64-9.x.x.x_cuda12-archive.tar.xz
sudo cp cudnn-linux-x86_64-9.x.x.x_cuda12-archive/include/* /usr/local/cuda/include/
sudo cp cudnn-linux-x86_64-9.x.x.x_cuda12-archive/lib/* /usr/local/cuda/lib64/
sudo ldconfigcuDNN 확인
# Check if cuDNN can be found
ldconfig -p | grep cudnn
# Verify via Python (requires PyTorch to be installed first)
python3 -c "import torch; print('cuDNN version:', torch.backends.cudnn.version()); print('cuDNN enabled:', torch.backends.cudnn.enabled)"GPU 가용성 확인
모든 구성 요소를 설치한 후 포괄적인 확인을 수행합니다.
시스템 수준 검증
# 1. Check driver
nvidia-smi
# 2. Check CUDA
nvcc --version
# 3. Check cuDNN
ldconfig -p | grep cudnn
# 4. View detailed GPU information
nvidia-smi -q | head -50
# 5. Monitor real-time GPU status
watch -n 1 nvidia-smiPyTorch GPU 검증
# Install PyTorch (inside an activated virtual environment)
# pip install torch installs the wheel for the current CUDA by default;
# older drivers can pin a lower CUDA, e.g. cu126
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
# Verify GPU availability
python3 << 'EOF'
import torch
print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"CUDA version: {torch.version.cuda}")
print(f"cuDNN version: {torch.backends.cudnn.version()}")
print(f"GPU count: {torch.cuda.device_count()}")
if torch.cuda.is_available():
print(f"Current GPU: {torch.cuda.get_device_name(0)}")
print(f"GPU VRAM: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB")
# Simple GPU compute test
x = torch.randn(1000, 1000, device='cuda')
y = torch.randn(1000, 1000, device='cuda')
z = torch.mm(x, y)
print(f"GPU compute test passed! Matrix multiplication result shape: {z.shape}")
else:
print("Warning: CUDA not available. Please check driver and CUDA installation")
EOFTensorFlow GPU 검증
# Install TensorFlow
pip install tensorflow
# Verify
python3 << 'EOF'
import tensorflow as tf
print(f"TensorFlow version: {tf.__version__}")
gpus = tf.config.list_physical_devices('GPU')
print(f"Available GPU count: {len(gpus)}")
for gpu in gpus:
print(f" GPU: {gpu.name}")
if gpus:
# Simple test
with tf.device('/GPU:0'):
a = tf.random.normal([1000, 1000])
b = tf.random.normal([1000, 1000])
c = tf.matmul(a, b)
print(f"GPU compute test passed! Matrix multiplication result shape: {c.shape}")
EOFROCm(AMD GPU) 개요
ROCm(Radeon Open Compute)은 NVIDIA의 CUDA과 유사한 AMD의 오픈 소스 GPU 컴퓨팅 플랫폼입니다.
지원되는 AMD GPU
ROCm은 주로 다음 AMD GPU 시리즈를 지원합니다.
- 라데온 RX 7900 XTX / 7900 XT(RDNA 3)
- 라데온 RX 7800 XT / 7700 XT(RDNA 3)
- 라데온 PRO W7900 / W7800
- 본능 MI300X / MI250X / MI210 (데이터 센터)
ROCm 설치
Ubuntu 26.04은 단일 apt 명령으로 ROCm를 설치할 수 있는 첫 번째 릴리스입니다. 26.04 저장소에 제공된 패키지를 선호합니다.
# Method 1 (recommended): use the ROCm packaged in the Ubuntu 26.04 repository
# Full runtime stack
sudo apt install -y rocm
# Or just the libraries and headers for development
# sudo apt install -y rocm-dev
# Add user to render and video groups
sudo usermod -aG render,video $USER
# Reboot
sudo rebootUbuntu 26.04 저장소는 ROCm 7.1.0을 배송합니다. 최신 버전이 필요한 경우 아래 AMD의 공식 저장소를 사용하고 AMD 공식 문서의 현재 버전 번호를 따르세요.
# Method 2: install a newer version from AMD's official repository
# Check the current version at https://repo.radeon.com/rocm/apt/ and replace <version> below
# Until AMD ships an Ubuntu 26.04 (resolute) repo, the 24.04 (noble) repo can be used as a fallback
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/<version> noble main" | \
sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt update
sudo apt install -y rocm
sudo usermod -aG render,video $USER
sudo rebootROCm 확인
# View AMD GPU information
rocm-smi
# Check ROCm version
rocminfo | head -20
# Install PyTorch ROCm version
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.2
# Verify
python3 -c "import torch; print('ROCm available:', torch.cuda.is_available()); print('Device:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A')"AMD ROCm의 소프트웨어 생태계는 NVIDIA CUDA만큼 성숙하지 않습니다. 일부 AI 도구는 지원되지 않거나 지원이 제한될 수 있습니다. 주요 용도가 AI 개발이라면 NVIDIA GPU가 더 안전한 선택입니다. 그러나 ROCm는 지속적으로 개선되고 있으며 PyTorch 및 여러 주요 프레임워크는 이제 좋은 지원을 받고 있습니다.
일반적인 문제 해결
문제 1: nvidia-smi에 출력이나 오류가 표시되지 않음
# Check if the driver is loaded
lsmod | grep nvidia
# If no output, try reloading the driver
sudo modprobe nvidia
# Check for Secure Boot issues
mokutil --sb-state
# If Secure Boot is enabled, you may need to sign the driver or disable Secure Boot
# Check kernel logs
dmesg | grep -i nvidia
sudo journalctl -b | grep -i nvidia문제 2: 드라이버 버전 충돌
# Remove all NVIDIA drivers
sudo apt purge -y 'nvidia-*'
sudo apt purge -y 'libnvidia-*'
sudo apt autoremove -y
# Reboot
sudo reboot
# Reinstall
sudo ubuntu-drivers autoinstall
sudo reboot문제 3: CUDA 버전과 PyTorch 불일치
# Check current CUDA version
nvcc --version
# Check PyTorch expected CUDA version
python3 -c "import torch; print(torch.version.cuda)"
# If mismatched, install the PyTorch wheel for the corresponding CUDA version
# Default (current CUDA)
pip install torch
# CUDA 12.6
pip install torch --index-url https://download.pytorch.org/whl/cu126
# CUDA 12.8
pip install torch --index-url https://download.pytorch.org/whl/cu128
# Available cuXXX indexes are listed at https://pytorch.org/get-started/locally/문제 4: GPU 메모리 부족(OOM)
# Check current GPU memory usage
nvidia-smi
# Find processes using the GPU
nvidia-smi --query-compute-apps=pid,name,used_memory --format=csv
# Free GPU memory (kill the occupying process)
# First confirm the process PID
kill -9 <PID>
# Clear PyTorch cache
python3 -c "import torch; torch.cuda.empty_cache()"문제 5: 누보 드라이버 충돌
# Nouveau is the open-source NVIDIA driver, which may conflict with the official driver
# Check if nouveau is loaded
lsmod | grep nouveau
# If there is output, disable nouveau
sudo bash -c 'cat > /etc/modprobe.d/blacklist-nouveau.conf << EOF
blacklist nouveau
options nouveau modeset=0
EOF'
# Regenerate initramfs
sudo update-initramfs -u
# Reboot
sudo reboot문제 6: Docker 컨테이너에서 GPU 사용
# Install NVIDIA Container Toolkit
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
# Configure Docker
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Test Docker GPU access
docker run --rm --gpus all nvidia/cuda:12.6.0-base-ubuntu24.04 nvidia-smi
# Tip: nvidia/cuda image tags are organized by CUDA version and base OS;
# pick an existing tag at https://hub.docker.com/r/nvidia/cuda/tagsNVIDIA 드라이버를 설치한 후 즉시 NVIDIA 컨테이너 툴킷을 설치하는 것이 좋습니다. 이를 통해 컨테이너 내부에 별도로 드라이버를 구성하지 않고도 Docker 컨테이너(예: Open WebUI, ComfyUI 등)에서 AI 도구를 실행할 때 GPU 가속을 사용할 수 있습니다.
전체 설치 스크립트
다음 스크립트는 전체 GPU 환경 설정 프로세스를 통합합니다.
#!/bin/bash
# gpu-setup.sh -- Ubuntu 26.04 NVIDIA GPU Environment One-Click Setup
set -e
echo "=== 1. Install NVIDIA Driver ==="
sudo apt update
sudo ubuntu-drivers autoinstall
echo "=== 2. Install CUDA Toolkit (Ubuntu 26.04 repository) ==="
sudo apt install -y cuda-toolkit
echo "=== 3. (Optional) For a newer version from the NVIDIA repository, use the following instead ==="
# wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-keyring_1.1-1_all.deb
# sudo dpkg -i cuda-keyring_1.1-1_all.deb
# sudo apt update
# sudo apt install -y cuda-toolkit-XX-Y # replace with an actual available version
echo "=== 4. Install cuDNN ==="
sudo apt install -y cudnn9-cuda-12
echo "=== 5. Configure Environment Variables ==="
if ! grep -q "CUDA_HOME" ~/.bashrc; then
cat >> ~/.bashrc << 'ENVEOF'
# CUDA Environment
export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
ENVEOF
fi
echo "=== 6. Install NVIDIA Container Toolkit ==="
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
echo ""
echo "=== Installation Complete! ==="
echo "Please reboot and then run nvidia-smi and nvcc --version to verify."
echo "Reboot command: sudo reboot"# Save and run the script
chmod +x gpu-setup.sh
./gpu-setup.sh