RuntimeError:inverse_cuda:对于批处理0:U(19536384,19536384)为零,单数U

时间:2019-11-02 22:57:22

标签: pytorch google-colaboratory

我正在尝试使用fastaiv2运行图像点增强。当开发人员在全新安装的环境中运行它时,它可以正常工作,但是当我在colab中运行时,我无法使其工作。

我已经研究了aug_transforms函数,以查看出现此问题的位置,这与增加图像点有关。

这是完整步骤:


!pip install git+https://github.com/fastai/fastai_dev > /dev/null
!pip install Pillow --upgrade # to get libraries

from fastai2.basics import *
from fastai2.callback.all import *
from fastai2.vision.all import *

path = untar_data(URLs.BIWI_HEAD_POSE)
cal = np.genfromtxt(path/'01'/'rgb.cal', skip_footer=6)
def img2txt_name(f): return path/f'{str(f)[:-7]}pose.txt'

def convert_biwi(coords:array):
  x = coords[0] * cal[0][0]/coords[2] + cal[0][2]
  y = coords[1] * cal[1][1]/coords[2] + cal[1][2]
  return tensor([x,y])

def get_ctr(f:Path):
  ctr = np.genfromtxt(img2txt_name(f), skip_header=3)
  return convert_biwi(ctr)

def get_ip(img:PILImage, pts:array): return TensorPoint.create(pts, sz=img.size)

splitter = FuncSplitter(lambda o: o.parent.name=='13')
dblock = DataBlock(blocks=(ImageBlock, PointBlock),
                   get_items=get_image_files,
                   splitter=splitter,
                   get_y=get_ctr)

batch_tfms = [*aug_transforms(size=(120,160), max_warp=0), Normalize(*imagenet_stats)]

dbunch = dblock.databunch(path, path=path, bs=64, batch_tfms=batch_tfms)
dbunch.show_batch(max_n=9, figsize=(9,6)) # breaks here

预期结果是显示一批增强图像,相反,我得到了带有以下RuntimeError的堆栈跟踪:

/usr/local/lib/python3.6/dist-packages/fastai2/vision/augment.py in affine_coord(x, mat, coord_tfm, sz, mode, pad_mode)
    260     if sz is None: sz = x._meta.get('sz', None)
    261     if coord_tfm is not None: x = coord_tfm(x, invert=True)
--> 262     if mat is not None: x = (x - mat[:,:,2].unsqueeze(1)) @ torch.inverse(mat[:,:,:2].transpose(1,2))
    263     return TensorPoint(x, sz=sz)
    264 

RuntimeError: inverse_cuda: For batch 0: U(19536384,19536384) is zero, singular U.

关于如何解决此问题的任何想法?当我也在新机器上尝试此操作时,它工作正常。

谢谢!

0 个答案:

没有答案