GXYM / TextBPN-Plus-Plus

Arbitrary Shape Text Detection via Boundary Transformer;The paper at: https://arxiv.org/abs/2205.05320, which has been accepted by IEEE Transactions on Multimedia (T-MM 2023).
175 stars 38 forks source link

Ctw1500训练遇到Expected a 'cuda' device type for generator but found 'cpu'解决办法 #24

Closed jihuan1203 closed 1 year ago

jihuan1203 commented 1 year ago

报错信息:File "/home/wit/anaconda3/envs/lj_py3.8pt1.10/lib/python3.8/site-packages/torch/utils/data/sampler.py", line 126, in iter yield from torch.randperm(n, generator=generator).tolist() RuntimeError: Expected a 'cuda' device type for generator but found 'cpu' 原因;pytorch版本高导致,我pytorch版本为1.10 解决方案,修改文件126行代码: yield from torch.randperm(n, generator=generator).tolist() 修改为: yield from torch.randperm(n, generator=torch.Generator(device='cuda')).tolist()