로딩
요청 처리 중입니다...

[pytorch]AttributeError: '_IncompatibleKeys' object has no attribute 'cuda'

 [pytorch]AttributeError: '_IncompatibleKeys' object has no attribute 'cuda'

발생 에러 AttributeError: '_IncompatibleKeys' object has no attribute 'cuda' AttributeError: '_IncompatibleKeys' object has no attribute 'to' 첫번째 에러를 보고 모델을 load하는 과정에서 cuda로 매핑이 안되나? 싶어서 to(device)로 변경했었다.

그랬더니 두번째 에러가 발생했다. 모델을 gpu로 못 보내는게 아니라 뭔가 문제가 있는 것 같아서 다시 코드를 살펴봤다.

해결방안 문제는 간단했다. model을 load하는 과정에서 아래와 같이 작성했기 때문이다. model=model.load_state_dict(torch.load('model.pt')) model.eval() 변경 model.load_state_dict(torch.load('model.pt')) model.eval() 에러없이 잘 돌아간다...

# load # model # torch # 파이토치