본문 바로가기

코딩 에러

RuntimeError: Attempting to deserialize object on CUDA device 2 but torch.cuda.device_count() is 1. Please use torch.load with map_location to map your storages to an existing device.

device = torch.device('cuda:0') 으로 하던지, 아니면 해당 번호로 부여할 것

 

나 같은 경우에는

 

cuda:0 으로 하든 cuda로 하든 이 에러가 떳는데

 

map location을 해줘도 에러가 났었음.

 

map location 예전 코드들을 보면, {'map_location' : device} 이런 코드로 처리하는 것들이 많은 데,

단순히 torch.load(PATH, map_location = device)로 바꿔줘도 해결이 됨