当前位置:网站首页>[step on pit collection] attempting to deserialize object on CUDA device+buff/cache occupy too much +pad_ sequence

[step on pit collection] attempting to deserialize object on CUDA device+buff/cache occupy too much +pad_ sequence

2022-07-06 22:41:00 Director of anti scientific research PUA Institute

Attempting to deserialize object on CUDA device

RuntimeError: Attempting to deserialize object on CUDA device 2 but torch.cuda.device_count() is 1

solve :

device = "cuda:0"
model.load_state_dict(torch.load('tut1-model.pt', map_location=device))
model.cuda(device=device)

buff/cache Occupy too much

linux On buff/cache Too much occupation leads to jamming 

solve ( With root execute ):

echo 3 > /proc/sys/vm/drop_caches

pad_sequence Use

solve :

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

版权声明
本文为[Director of anti scientific research PUA Institute]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061450286051.html