CUDA 错误:调用 `cublasCreate(handle)` 时出现 CUBLAS_STATUS_ALLOC_FAILED [英] CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`

查看:389
本文介绍了CUDA 错误:调用 `cublasCreate(handle)` 时出现 CUBLAS_STATUS_ALLOC_FAILED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 colab 中运行 pytorch 深度学习模型时出现以下错误

I got the following error when I ran my pytorch deep learning model in colab

/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in linear(input, weight, bias)
   1370         ret = torch.addmm(bias, input, weight.t())
   1371     else:
-> 1372         output = input.matmul(weight.t())
   1373         if bias is not None:
   1374             output += bias

RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`

我什至将批量大小从 128 减少到 64,即减少到一半,但仍然出现此错误.早些时候,我以 128 的批量大小运行了相同的代码,但没有出现任何类似的错误.

I even reduced batch size from 128 to 64 i.e., reduced to half, but still, I got this error. Earlier, I ran the same code with a batch size of 128 but didn't get any error like this.

推荐答案

这个错误实际上可能是由于不同的原因造成的.如果可能,建议通过在 CPU 上运行代码来调试 CUDA 错误.如果这不可能,请尝试通过以下方式执行脚本:

This error can actually be due to different reasons. It is recommended to debug CUDA errors by running the code on the CPU, if possible. If that’s not possible, try to execute the script via:

CUDA_LAUNCH_BLOCKING=1 python [YOUR_PROGRAM]

这将帮助您获得在堆栈跟踪中引发错误的正确代码行,以便您可以解决它.

This will help you get the right line of code which raised the error in the stack trace so that you can resolve it.

这篇关于CUDA 错误:调用 `cublasCreate(handle)` 时出现 CUBLAS_STATUS_ALLOC_FAILED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆