← 回首頁
Ollama / PyTorch
CUDA out of memory
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate X MiB
🔍 為什麼會發生
显存不够。可能是模型太大、batch size 太大、或者上一次推理没释放显存。
🛠️ 怎麼修
- 降 batch size:
--batch-size 1
- 开启 gradient checkpointing(训练时省 60-80% 显存)
- 用 fp16 或 int8 量化模型
- 关闭其他占显存的进程:
nvidia-smi 看谁在占用
- 设置
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True 减少碎片
看更多加密貨幣工具
本站為技術速查,內容僅供參考。錯誤訊息以官方文件為準。