1. pytorch版本问题导致的错误
1.1 AttributeError
AttributeError: 'CIFAR100Instance' object has no attribute 'train_labels'
AttributeError: 'CIFAR100Instance' object has no attribute 'train_data'
解决办法:参考官方源码,Pytorch0.4.0采用的'train_labels'
和'train_data'
现在被更新为targets
和data
1.2 IndexError
IndexError: invalid index of a 0-dim tensor . Use 'tensor.item()' in python or 'tensor.item<T>() in Ct to covert a 0-dim tensor to a number
解决办法:将tensor.data[0]
替换为tensor.item()
1.3 ImportError
ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead.
解决办法:将以下代码
from torch.utils.ffi import create_extension
ffi = create_extension(...)
替换为
from torch.utils.cpp_extension import BuildExtension
ffi = BuildExtension(...)
2. 类型错误
ValueError: Type mismatch (<class 'float'> vs. <class 'int'>) with values (1.0 vs. 1) for config key: DISTILL.TRIAL
错误原因:配置文件config.yaml
中的数据类型与defaults.py
中定义的不符
解决办法:统一使用float
类型,例如将数字从1改为1.0
3. 资源错误
1.1 RuntimeError
RuntimeError: NCCL error in: /pytorch/torch/lib/c10d/ProcessGroupNCCL.cpp:784, invalid usage, NCCL version 2.7.8
错误原因:统一代码中要求用8张GPU运行,而机器只有2张卡。
解决办法:把代码设置为2张卡运行。
1.2 AssertionError
AssertionError: Default process group is not initialized
错误原因:非分布式训练使用了分布式训练的设置
解决办法:统一是/否分布式训练
1.3 RuntimeError
RuntimeError: CUDA out of memory.
错误原因:显存不够了
解决办法:清理其他任务或等待其他任务执行完毕