【torch报错】RuntimeError: Unable to find a valid cuDNN algorithm to run convolution & realnet

realnet torch代码训练过程报错及解决

背景

在使用realnet的官方代码进行训练时报错如下,使用的命令为,采用了分布式DDP,不过本地只用了1张显卡:

python -m torch.distributed.launch --nproc_per_node=1  train_realnet.py --dataset VisA --class_name candle

网络参数等均采用的Visa下的realnet.yaml文件中的参数,本地显卡显存为24G,直接运行后出现这个错误

File "/home/zhaoshiqiang/anacconda/enter/envs/realnet/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 446, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/home/zhaoshiqiang/anacconda/enter/envs/realnet/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 442, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Unable to find a valid cuDNN algorithm to run convolution
terminate called after throwing an instance of 'c10::CUDAError'
  what():  CUDA error: driver shutting down
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.
Exception raised from query at ../aten/src/ATen/cuda/CUDAEvent.h:95 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x42 (0x7f4a4d4bdd62 in /home/zhaoshiqiang/anacconda/enter/envs/realnet/lib/python3.8/site-packages/torch/lib/libc10.so)
frame #1: c10d::ProcessGroupNCCL::WorkNCCL::finishedGPUExecutionInternal() const + 0x11a (0x7f4adbd0424a in /home/zhaoshiqiang/anacconda/enter/envs/realnet/lib/python3.8/site-packages/torch/lib/libt
orch_cuda_cpp.so)
frame #2: c10d::ProcessGroupNCCL::WorkNCCL::isCompleted() + 0x50 (0x7f4adbd06540 in /home/zhaoshiqiang/anacconda/enter/envs/realnet/lib/python3.8/site-packages/torch/lib/libtorch_cuda_cpp.so)
frame #3: c10d::ProcessGroupNCCL::workCleanupLoop() + 0x11c (0x7f4adbd0700c in /home/zhaoshiqiang/anacconda/enter/envs/realnet/lib/python3.8/site-packages/torch/lib/libtorch_cuda_cpp.so)
frame #4: <unknown function> + 0xe6793 (0x7f4b49cdd793 in /lib/x86_64-linux-gnu/libstdc++.so.6)
frame #5: <unknown function> + 0x8609 (0x7f4b4b50f609 in /lib/x86_64-linux-gnu/libpthread.so.0)
frame #6: clone + 0x43 (0x7f4b4b2da133 in /lib/x86_64-linux-gnu/libc.so.6)

在这里插入图片描述

解决办法

将batch size将原来的16修改为8后,即可正常运行了,运行期间显存占用约为18G,nvidia-smi显示如下:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

↣life♚

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

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

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

打赏作者

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

抵扣说明:

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

余额充值