【PyTorch】报错场景及解决方案汇总

Backto PyTorch Index

Error Case Solution Reason
RuntimeError: Error(s) in loading state_dict for ResNet: load_state_dict() model.load_state_dict( checkpoint[‘state_dict’], strict=False) version not match
AssertionError: Invalid device id using GPU in config.py, set GPU_ID correctly gpu devices misfound error
Volatile = now has no effect. Use with torch.no_grad(): instead image = Variable(image, volatile=True) with torch.no_grad(): image = Variable(image) removed
“non-inplace resize is deprecated” tensor.resize() change to tensor.reshape or torch.reshape deprecated
RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. runtime error 1. 去掉num_workers参数 ; 2. (推荐)在跑epoch之前,加上if __name__==__main__: import module导致重复执行
Torch: not enough memory: you tried to allocate 0GB. Buy new RAM! error occurs half-way add swap memory; Don NOT run other memory-cosuming apps, like Chrome/PyCharm, etc Memory is valuable & limited.
RuntimeError: Expected object of backend CPU but got backend CUDA for argument #2 ‘weight’ testing with torch.no\_grad():input = input.cuda();net.cuda();net(input) Mixed usage of CPU/GPU

你可能感兴趣的:(PyTorch)