我试图打开几个图像文件并将它们移动到GPU内存中,以便可以在GPU上计算它们之间的差异:
img1 = torchvision.io.read_image(IMAGE1).float()
img1.cuda()
但是,我一直收到以下错误:
RuntimeError: CUDA error: unspecified launch failure
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.
如果我跑:
img1 = torchvision.io.read_image(IMAGE1).float()
img2 = torchvision.io.read_image(IMAGE2).float()
(img2-img1).is_cuda # False
有人知道为什么会这样吗?
发布于 2022-07-03 12:29:23
将张量传递到带有torch.Tensor.cuda
的设备上是没有完成的,它返回原始张量的副本。因此,你需要:
img1 = img1.cuda()
img2 = img2.cuda()
https://stackoverflow.com/questions/72846267
复制相似问题