Skip to content

cuda illegal memory access on tensor slice #104

Open
@jonathanasdf

Description

@jonathanasdf

When I run the following code:

cv = require 'cv'
require 'cv.cudawarping'
require 'cv.imgcodecs'
require 'image'
require 'xlua'

local I = image.lena():permute(2, 3, 1):cuda()
local h = I:size(1) / 2
local w = I:size(2) / 2
local t = (I:size(1) - h) / 2
local l = (I:size(2) - w) / 2
local N = 100000
for i=1,N do
  local slice = I[{{t, t+h-1}, {l, l+w-1}, {}}]
  cv.cuda.resize{slice, {I:size(1), I:size(2)}}
  xlua.progress(i, N)
end

I get

OpenCV Error: Gpu API call (an illegal memory access was encountered) in call_resize_linear_glob, file /opt/opencv/modules/cudawarping/src/cuda/resize.cu, line 220
THCudaCheck FAIL file=/opt/cutorch/lib/THC/generic/THCStorage.c line=147 error=77 : an illegal memory access was encountered
/opt/torch/install/bin/luajit: cuda runtime error (77) : an illegal memory access was encountered at /opt/cutorch/lib/THC/generic/THCStorage.c:147

If I replace resize{slice with resize{slice:clone() then it runs fine without error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions