Documenta cómo configurar PyTorch con soporte ROCm para RX 6800 XT. Incluye instalación, tests de verificación y troubleshooting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4.4 KiB
4.4 KiB
Configuración GPU AMD RX 6800 XT para PyTorch
Resumen
Esta guía documenta cómo configurar PyTorch con soporte ROCm para usar la GPU AMD RX 6800 XT (16GB VRAM) en lugar de NVIDIA CUDA.
Hardware
- GPU: AMD Radeon RX 6800 XT
- VRAM: 16 GB
- ROCm: 7.1 (instalado a nivel sistema)
- Sistema: Arch Linux
Problema Inicial
PyTorch instalado con pip install torch no detecta la GPU AMD:
PyTorch version: 2.10.0+cu128
torch.cuda.is_available(): False
torch.version.hip: None
Solución
1. Verificar ROCm del sistema
rocm-smi --version
# ROCM-SMI version: 4.0.0+unknown
# ROCM-SMI-LIB version: 7.8.0
2. Instalar PyTorch con soporte ROCm
La URL correcta para PyTorch con ROCm es rocm7.1 (no rocm5.7 ni rocm6.x):
# Activar entorno virtual
source venv/bin/activate
# Desinstalar PyTorch anterior (si existe)
pip uninstall -y torch torchvision torchaudio
# Instalar con ROCm 7.1
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm7.1
Nota: Las versiones disponibles en PyTorch ROCm:
rocm5.7- No disponiblerocm6.0- No disponiblerocm6.1- No disponiblerocm7.1- ✅ Funciona (versión 2.10.0+rocm7.1)
3. Verificar instalación
import torch
print(f"PyTorch: {torch.__version__}")
print(f"ROCm version: {torch.version.hip}")
print(f"GPU available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"GPU Name: {torch.cuda.get_device_name(0)}")
print(f"VRAM: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB")
Salida esperada:
PyTorch: 2.10.0+rocm7.1
ROCm version: 7.1.25424
GPU available: True
GPU Name: AMD Radeon Graphics
VRAM: 16.0 GB
Tests de Verificación
Test 1: Tensor básico
import torch
x = torch.randn(1000, 1000).cuda()
y = x @ x.T
print("✅ Matrix multiplication works")
Test 2: Memoria
x = torch.randn(10000, 10000).cuda() # ~400MB
print(f"Allocated: {torch.cuda.memory_allocated(0) / 1024**3:.2f} GB")
Test 3: CNN (Conv2d)
import torch.nn as nn
conv = nn.Conv2d(3, 64, 3, padding=1).cuda()
x = torch.randn(1, 3, 224, 224).cuda()
y = conv(x)
print(f"Output: {y.shape}")
Test 4: Transformer Attention
import torch.nn.functional as F
q = torch.randn(2, 8, 512, 64).cuda()
attn = F.scaled_dot_product_attention(q, q, q)
print(f"Attention: {attn.shape}")
Test 5: Whisper-like Encoder
import torch.nn as nn
import torch.nn.functional as F
x = torch.randn(1, 80, 1500).cuda()
conv1 = nn.Conv1d(80, 512, 3, padding=1).cuda()
x = F.gelu(conv1(x))
print(f"Whisper encoder: {x.shape}")
Dependencias Adicionales
Faster-Whisper (recomendado para transcription)
pip install faster-whisper
Funciona con GPU automáticamente:
from faster_whisper import WhisperModel
model = WhisperModel("small", device="auto", compute_type="float16")
segments, info = model.transcribe("video.mp4", language="es")
OpenCV
pip install opencv-python
Otras librerías
pip install transformers accelerate numpy scipy
Troubleshooting
"No such file or directory: /opt/amdgpu/share/libdrm/amdgpu.ids"
Warning ignorable, la GPU funciona igual.
"AttributeError: module 'torch' has no attribute 'gelu'"
Usar torch.nn.functional.gelu() en lugar de torch.gelu().
GPU no detectada
Verificar que ROCm esté instalado:
ls /opt/rocm
hipcc --version
Comparación CUDA vs ROCm
| Aspecto | CUDA (NVIDIA) | ROCm (AMD) |
|---|---|---|
| Instalación | pip install torch |
pip install torch --index-url https://download.pytorch.org/whl/rocm7.1 |
| Device | torch.device("cuda") |
torch.device("cuda") (相同) |
| Modelo | model.cuda() |
model.cuda() (相同) |
| VRAM 16GB | RTX 3070+ | RX 6800 XT |
Notas
- PyTorch usa la misma API para CUDA y ROCm
- El código no necesita cambios para ejecutar en GPU AMD
- El índice
rocm7.1es el correcto para ROCm 7.x - La versión nightly también está disponible:
--index-url https://download.pytorch.org/whl/nightly/rocm7.1
Historial de Pruebas
- ❌
rocm5.7- No disponible en PyTorch - ❌
rocm6.0- No disponible - ❌
rocm6.1- No disponible - ✅
rocm7.1- Funciona correctamente
Fecha: 19 de Febrero 2026 GPU: AMD RX 6800 XT (16GB VRAM) ROCm: 7.1.25424 PyTorch: 2.10.0+rocm7.1