当前位置:网站首页>【踩坑合辑】Attempting to deserialize object on CUDA device+buff/cache占用过高+pad_sequence

【踩坑合辑】Attempting to deserialize object on CUDA device+buff/cache占用过高+pad_sequence

2022-07-06 14:50:00 反科研pua所所长

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()
原网站

版权声明
本文为[反科研pua所所长]所创,转载请带上原文链接,感谢
https://blog.csdn.net/YasmineC/article/details/125628700