Linux服务器使用GPU技巧

进行深度学习实验的时候用pytorch-gpu,经常要与GPU打交道;
所以经常遇到奇奇怪怪的问题;

查看GPU占用情况

watch -n 10 nvidia-smi

使用技巧

torch.nn.DataParallel()

CLASStorch.nn.DataParallel(module, device_ids=None, output_device=None, dim=0)

Linux服务器使用GPU技巧_第1张图片
可以看得到第一张卡用的多一些,这是因为虽然是并行,但是在做output_loss的时候默认是在第一张卡上跑的;参考[1]

Debug

1. RuntimeError: CUDA out of memory.

RuntimeError: CUDA out of memory. Tried to allocate 392.00 MiB (GPU 0; 7.80 GiB total capacity; 6.48 GiB already allocated; 131.88 MiB free; 6.71 GiB reserved in total by PyTorch)

之所以会爆是因为·torch.nn.DataParallel()`上述原因;

参考

[1]Pytorch的nn.DataParallel

你可能感兴趣的:(Debug,linux,运维,服务器)