Files
ren 07c8ebcf01 docs: add AMD GPU setup guide for PyTorch ROCm
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>
2026-02-19 22:07:55 -03:00

190 lines
4.4 KiB
Markdown

# 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
```bash
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):
```bash
# 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 disponible
- `rocm6.0` - No disponible
- `rocm6.1` - No disponible
- `rocm7.1` - ✅ Funciona (versión 2.10.0+rocm7.1)
### 3. Verificar instalación
```python
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
```python
import torch
x = torch.randn(1000, 1000).cuda()
y = x @ x.T
print("✅ Matrix multiplication works")
```
### Test 2: Memoria
```python
x = torch.randn(10000, 10000).cuda() # ~400MB
print(f"Allocated: {torch.cuda.memory_allocated(0) / 1024**3:.2f} GB")
```
### Test 3: CNN (Conv2d)
```python
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
```python
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
```python
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)
```bash
pip install faster-whisper
```
Funciona con GPU automáticamente:
```python
from faster_whisper import WhisperModel
model = WhisperModel("small", device="auto", compute_type="float16")
segments, info = model.transcribe("video.mp4", language="es")
```
### OpenCV
```bash
pip install opencv-python
```
### Otras librerías
```bash
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:
```bash
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.1` es 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