CUDA kernel errors might be asynchronously reported at some other API call,
so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
/pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93:
operator(): block: [0,0,0], thread: [70,0,0]
Assertion index >= -sizes[i] && index < sizes[i] && "index out of bounds" failed.
/pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [0,0,0], thread: [28,0,0] Assertion index >= -sizes[i] && index < sizes[i] && "index out of bounds"
failed.
标签索引不正确,即标签编号大于定义标签,定义crf层的时候标签的类别数和yaml中的类别数不同,要么修改标签文件,要么修改层的类别数量定义
原因:
a = str(trues_cls.detach().numpy()[0]) #这样是错误的
解决方法:
a= str(trues_cls.detach().cpu().numpy()[0]) # 这样是正确的
# detach(): 返回一个新的Tensor,但返回的结果是没有梯度的。
# cpu():把gpu上的数据转到cpu上。
# numpy():将tensor格式转为numpy
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
输入的显卡卡号错了,可以切换显卡号的数字尝试
原因:dropout层的随机性,当输入dropout层的数据维度大于57346时,从第57347位开始不同显卡的结果会不一样,原因是不同显卡的数据采样方法在第57346位后存在差别。
解决方法:手动构造一个由randn实现的dropout层,可以实现跨机结果一致
伯努利分布,使用torch.tensor,与cuda有关,randn和数字有关
原因:环境使用了export,导致只有一个 GPU可见 (GPU:0),而程序中使用 GPUs:1。
输入export CUDA_VISIBLE_DEVICES = '0,1',让设备变为两个,方便在环境中随意切换
因篇幅问题不能全部显示,请点此查看更多更全内容