报错
-
报错信息为:
发生异常: RuntimeError CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)
。
-
尝试了但都无效的方法:
- 在main函数中添加
CUDA_LAUNCH_BLOCKING=1
; - 重启环境;
- 尝试更小的矩阵乘法(排除了显存不够或者内存不够的问题);
- 替换
@ 、 torch.mm、torch.matmul、torch.einsum
等不同的矩阵乘法函数。
- 在main函数中添加
有效解决方法
- 最后的解决方法是:将张量计算转移到cpu上,并进行调试。定位到真实的问题。
device = torch.device('cuda:1'