1、NVIDIA driver too old error
报错:The NVIDIA driver on your system is too old (found version 9000).
Please update your GPU driver by downloading and installing a new
version from the URL: http://www.nvidia.com/Download/index.aspx
Alternatively, go to: http://pytorch.org to install a PyTorch version
that has been compiled with your version of the CUDA driver.
解决:用nvcc --version 或nvidia-smi查看cuda版本
(如果nvcc查不到的话需要配置cuda环境变量
export PATH="/usr/local/cuda-10.1/bin:$PATH" export LD_LIBRARY_PATH="/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH"
)
安装与cuda版本对应的pytorch和torchvision
如本文torch对应cuda版本10.1
pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
2.使用多gpu训练验证时cuda:out of memory,除了常见的错误(如数据送入模型前忘记写with torch.no_grad():,验证保存的loss没有加loss.item()等),还有可能是有些代码中验证时要把所有卡上的结果合并到一张卡上导致内存溢出,代码如下:
gts.extend(list(itertools.chain.from_iterable(utils.all_gather(copy.deepcopy(targets)))))
这里的targets是一个字典,其中存着多个tensor且device是在cuda上,因此只需要把targets中存放的tensor转成cpu的形式即可:
tars = []
for img_gts in targets:
img_gts = {k: v.to('cpu') for k, v in img_gts.items()}
tars.append(img_gts)
gts.extend(list(itertools.chain.from_iterable(utils.all_gather(copy.deepcopy(tars)))))
3、程序卡在显存里 kill不掉
fuser -v /dev/nvidia* |awk ‘{for(i=1;i<=NF;i++)print "kill -9 " $i;}’ | sh
4、
ImportError: cannot import name ‘PILLOW_VERSION’ from ‘PIL’
该错误由于Pillow 7.0.0 移除了 PILLOW_VERSION, 将 代码中的PILLOW_VERSION
改为 __version__
即可
5、wget 断点续传
当文件特别大或者网络特别慢的时候,往往一个文件还没有下载完,连接就已经被切断,此时就需要断点续传。wget的断点续传是自动的,只需要使用-c参数,例如:
wget -c http://the.url.of/incomplete/file
使用断点续传要求服务器支持断点续传。-t参数表示重试次数,例如需要重试100次,那么就写-t 100,如果设成-t 0,那么表示无穷次重试,直到连接成功。-T参数表示超时等待时间,例如-T 120,表示等待120秒连接不上就算超时。