方法1:
num_workers设为0
即
torch.utils.data.DataLoader(
dataset_test, batch_size=2, shuffle=False, num_workers=0,
collate_fn=utils.collate_fn)
方法2
使用torch1.9,即可解决
conda create -n condapy python=3.7
pip install torch torchvision torchaudio
为此,我重新安装回pytorch==1.9.0
那么我之前修改的东西需要重新改回去。真Cao Dan
http://www.manongjc.com/detail/28-llivmebvzwrvnfa.html
降低PyTorch的版本到1.9.0,PyTorch的历史版本Previous PyTorch Versions | PyTorch
或者去掉该参数,参考:
解决方案:
…\torch\nn\modules\upsampling.py #torch文件
修改:
def forward(self, input: Tensor) -> Tensor:
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
recompute_scale_factor=self.recompute_scale_factor
)
结果:
def forward(self, input: Tensor) -> Tensor:
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
#recompute_scale_factor=self.recompute_scale_factor
)
conda install pytorch1.9.0 torchvision0.10.0 torchaudio==0.9.0 cudatoolkit=10.2 -c pytorch
conda install pytorch1.9.0 torchvision0.10.0 torchaudio==0.9.0 cudatoolkit=11.3 -c pytorch -c conda-forge
conda install pytorch1.9.0 torchvision0.10.0 torchaudio==0.9.0 cpuonly -c pytorch
方法二:
upsampling.py并打开,修改里面的代码即可解决
https://blog.csdn.net/qq_40280673/article/details/125095353
https://blog.csdn.net/baidu_39629638/article/details/128025583
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.
Epoch gpu_mem box obj cls kpt kptv total labels img_size
10/299 19.7G 0.04496 0.01988 0 0.06022 0.0118 0.1369 147 640: 38%|████████████▉ | 19/50 [00:13<00:22, 1.36it/s]
Traceback (most recent call last):
File “/home/wqt/Projects/yolo5landmark/train.py”, line 552, in
train(hyp, opt, device, tb_writer)
File “/home/wqt/Projects/yolo5landmark/train.py”, line 308, in train
loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size
File “/home/wqt/Projects/yolo5landmark/utils/loss.py”, line 166, in call
tcls, tbox, tkpt, indices, anchors = self.build_targets(p, targets) # targets
File “/home/wqt/Projects/yolo5landmark/utils/loss.py”, line 271, in build_targets
j = torch.stack((torch.ones_like(j), j, k, l, m))