CUDA error:invalid argument

在使用torch.view()时遇到RuntimeError,提示输入不连续。通过调用tensor.contiguous()可以尝试解决,但在某些情况下仍无法解决问题。参考StackOverflow上的讨论,该错误可能与CUDA的内存分配有关,cudaLimitMallocHeapSize控制着设备上malloc和free系统调用使用的堆大小。设置此限制必须在使用这些系统调用的内核启动之前完成,否则会返回cudaErrorInvalidValue。此限制仅适用于计算能力2.0及更高的设备。
摘要由CSDN通过智能技术生成

当使用torch.view()时


出现 RuntimeError: invalid argument 1: input is not contiguous at /pytorch/torch/lib/TH/generic/THTensor.c:231

可以使用 tensor.contiguous() 解决

比如:

mask[idx, :].view(bat_size, 1) 变成 mask[idx, :].contiguous().view(bat_size, 1)

不能解决问题

https://stackoverflow.com/questions/13994799/cuda-invalid-argument-error-on-second-kernel

cudaLimitMallocHeapSize controls the size in bytes of the heap used by the malloc() and free() device system calls. Setting cudaLimitMallocHeapSize must be performed before launching any kernel that uses the mallo

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值