**RuntimeError: CUDA error: an illegal memory access was encountered
**
没有选择将数据放在cuda上,默认在cpu上进行运算,
import torch
a = torch.ones(4)
b = torch.ones(4)
c = torch.zeros(8).cuda()
print(c)
ab = torch.cat([a,b], out=c) # throws error below:
print(c)
比如a,b是在cpu上进行计算,c是在gpu上,所以会报错
修改成都放在gpu上即可
import torch
a = torch.ones(4).cuda()
b = torch.ones(4).cuda()
c = torch.zeros(8).cuda()
print(c)
ab = torch.cat([a,b], out=c) # throws error below:
print(c)