問題:
c = F.relu(policy_model.Q.c1(exp_list[i][k].unsqueeze(0)))
error:
*** RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cuda:2! (when checking argument for argument weight in
method wrapper__cudnn_convolution)
原因:
訓練好的Model和待使用的數據分別在兩個cuda上,因此出現錯誤。
解決方法:
在加載模型時,設置加載到數據所在的cuda上。確保模型和數據在同一個cuda上。
即把:
policy_model = torch.load(PATH)
改為:
policy_model = torch.load(PATH, map_location=torch.device('cuda:1'))