[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
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Pytorch는 cpu와 gpu의 사용을 어떻게 전환하는지 상세히 설명합니다.앞에서 말했듯이pytorch에서 서버에 있는 gpu가 점용될 때 우리는 먼저 cpu로 코드를 디버깅하고 싶을 때가 많다. 그러면 gpu와 cpu의 전환이 필요하다. 장치를 가변 매개 변수로 사용하려면argparse를...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.