pytorch - CPU와 GPU 부하 때 상호의 pytorch은 ------ CPU가 GPU 부하 상호의 torch.load (map_location =) 학습

将 GPU 改为의 CPU 时, 遇到 一个 报错 : RuntimeError에하십시오 CUDA 장치 만) (torch.cuda.is_available 개체를 역 직렬화하려고하는 것은 거짓이다. 당신은 CPU 전용 시스템에서 실행중인 경우, CPU에 스토리지를 매핑 map_location = 'CPU'로 torch.load 사용하십시오 此时 改为. :

torch.load ( " 0.9472_0048.weights "map_location = ' CPU ')

라는 이름의 파일 modelparameters.pth에 우리가 모델의 매개 변수 만 저장 가정 (model.state_dict ()), 모델 = 순 ()

1. CPU -> CPU 또는 GPU -> GPU :

체크 포인트 = torch.load ( ' modelparameters.pth ' ) 
 model.load_state_dict (체크 포인트)

2. CPU -> GPU 1

torch.load ( ' modelparameters.pth 'map_location = 람다 저장 LOC : storage.cuda 1)

3. GPU 1 -> GPU 0

torch.load ( ' modelparameters.pth 'map_location = { ' 쿠다 1 ' ' 쿠다 0 '})

> CPU - 4 GPU

torch.load ( ' modelparameters.pth 'map_location = 람다 저장 LOC : 수납)

추천

출처www.cnblogs.com/llfctt/p/10986401.html