CUDA error: an illegal memory access
RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. 这个问题困扰了我很久,而且仅仅通过提供的报错信息无法查找到错误的根源。我通过不断地尝试,定位到了问题可能出现的地方。 if attn_bias is not None: x = x + attn_bias
加上上述代码就会报错,去掉就正常。 改成这样就可以解决问题了。 if attn_bias is not None: x = x + attn_bias.detach()