Attempting to deserialize object on CUDA device
RuntimeError: Attempting to deserialize object on CUDA device 2 but torch.cuda.device_count() is 1
解决:
device = "cuda:0"
model.load_state_dict(torch.load('tut1-model.pt', map_location=device))
model.cuda(device=device)
buff/cache占用过高
linux上buff/cache占用过高导致卡顿
解决(以root身份执行):
echo 3 > /proc/sys/vm/drop_caches
pad_sequence使用
解决:
from torch.nn.utils.rnn import pad_sequence
def my_collate(batch):
a = torch.ones(25, 300)
b = torch.ones(22, 300)
c = torch.ones(15, 300)
pad_sequence([a, b, c]).size()