我从crnn-pytorch中保存了一些变量,该变量在gpu上运行并使用warp-ctc。
warp-ctc:https://github.com/SeanNaren/warp-ctc
然后我在代码中使用这些变量,可以在cpu上运行它,结果是正确的。但是,当我在gpu上运行它时,会出现Segmentation fault
错误。
这是我在gpu上运行的代码:
import torch
from warpctc_pytorch import CTCLoss
import numpy as np
from torch.autograd import Variable
i = 1
criterion = CTCLoss()
criterion = criterion.cuda()
a = np.load('preds_%d.npy' % i)
b = np.load('text_%d.npy' % i)
c = np.load('preds_size_%d.npy' % i)
d = np.load('length_%d.npy' % i)
#a = Variable(torch.from_numpy(a)).cuda()
#b = Variable(torch.from_numpy(b)).cuda()
#c = Variable(torch.from_numpy(c)).cuda()
#d = Variable(torch.from_numpy(d)).cuda()
a = torch.from_numpy(a).cuda()
b = torch.from_numpy(b).cuda()
c = torch.from_numpy(c).cuda()
d = torch.from_numpy(d).cuda()
print(a.dtype)
print(b.dtype)
print(c.dtype)
print(d.dtype)
cost = criterion(a, b, c, d) / 64
print('cost:', cost)
我遇到细分错误。当删除所有.cuda()时,我得到正确的答案。 所有cpu和gpu测试均已通过。 我真的希望有人能提供帮助。