[pytorch] - 오류 해결 요약

1513 단어 Pytorch

1. 매개 변수는load가 들어가지 못하고module가 많습니다.그 이유는: 전에 훈련할 때'nn'을 사용했기 때문이다.DataParallel(model_structure,device_ids=gpu_ids) ’
RuntimeError: Error(s) in loading state_dict for ftnet_EncoderDecoder:
	
Missing key(s) in state_dict: 
"BackBone.model.conv1.weight", "BackBone.model.bn1.weight", "BackBone.model.bn1.bias", "BackBone.model.bn1.running_mean", "BackBone.model.bn1.running_var", .....

Unexpected key(s) in state_dict: 
"module.BackBone.model.conv1.weight", "module.BackBone.model.bn1.weight", "module.BackBone.model.bn1.bias", "module.BackBone.model.bn1.running_mean", "module.BackBone.model.bn1.running_var", "module.BackBone.model.l  "  ........

해결:
model_structure = net()
model_structure = nn.DataParallel(model_structure,device_ids=gpu_ids)
model = load_network(model_structure)

 
2、There is an imbalance between your GPUs. You may want to exclude GPU 0 which has less than 75% of the memory or cores of GPU 1. You can do so by setting the device_ids argument to DataParallel, or by setting the CUDA_VISIBLE_DEVICES environment variable.
해결:
As mentioned in this link, you have to do model.cuda() before passing it to nn.DataParallel.
net = nn.DataParallel(model.cuda(), device_ids=[0,1])

URL that solved this problem:https://stackoverflow.com/questions/55343893/how-to-do-parallel-processing-in-pytorch

좋은 웹페이지 즐겨찾기