Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cutorch failure in CUDA 8 #172

Open
apvijay opened this issue Jan 16, 2017 · 2 comments
Open

cutorch failure in CUDA 8 #172

apvijay opened this issue Jan 16, 2017 · 2 comments

Comments

@apvijay
Copy link

apvijay commented Jan 16, 2017

The below test code for image resize results in an error:

Specs:
Ubuntu 14.04
CUDA-8
OpenCV 3.2 / OpenCV 3.1 / OpenCV 3.1 (with CUDA 8 support)
Latest Torch-7and related packages
GPU: Titan X Pascal

Code:

require 'cutorch'
local cv = require 'cv'
require 'cv.cudawarping'
require 'cv.highgui'
require 'cv.imgcodecs'
require 'image'

cutorch.setDevice(3)
local img = cv.imread {arg[1] or 'lena.jpg', cv.IMREAD_COLOR}
print("Read image - done")
local imgCUDA = img:float():cuda() / 255
print("Cuda conversion - done")
for i=0,100,1
do
  print(i)
  local resized = cv.cuda.resize{imgCUDA, {1024, 768}}
  print("Resize - done")
  print(resized:size())
  print(resized:type())
  image.save('lenaresized.png',resized:transpose(1,3):transpose(2,3))
end

The output of the above test code is below:

Read image - done	
Cuda conversion - done	
0	
Resize - done	
  768
 1024
    3
[torch.LongStorage of size 3]

torch.CudaTensor	

.
.
.

15	
Resize - done	
  768
 1024
    3
[torch.LongStorage of size 3]

torch.CudaTensor	
THCudaCheck FAIL file=/tmp/luarocks_cutorch-scm-1-1283/cutorch/lib/THC/generic/THCStorage.c line=182 error=17 : invalid device pointer
/home/user/torch/install/bin/luajit: cuda runtime error (17) : invalid device pointer at /tmp/luarocks_cutorch-scm-1-1283/cutorch/lib/THC/generic/THCStorage.c:182


There is some memory conversion(?) issue after 15 times of looping. The corresponding line in THCStorage.c is

THCudaCheck(
        (*self->allocator->free)(self->allocatorContext, self->data));

This code runs in CUDA 6.5/OpenCV 3.1/ Torch 7. Does torch-opencv support CUDA-8?

Could someone look into this issue?

@shrubb
Copy link
Contributor

shrubb commented Jan 19, 2017

Hi,

unfortunately, I still don't have a machine with GPU to test on :(

Can you try this code? What's the output?

require 'cutorch'
local cv = require 'cv'
require 'cv.cudawarping'
require 'cv.highgui'
require 'cv.imgcodecs'
require 'image'

cutorch.setDevice(3)
local img = cv.imread {arg[1] or 'lena.jpg', cv.IMREAD_COLOR}
print("Read image - done")
local imgCUDA = img:float():cuda() / 255
print("Cuda conversion - done")
local img2 = imgCUDA:clone(); img2 = nil; collectgarbage()
print("Deallocate image - done")
local resized = cv.cuda.resize{imgCUDA, {1024, 768}}
print("Resize - done")
print(resized:size())
print(resized:type())
resized = nil; collectgarbage()
print("Deallocate resized image - done")

@apvijay
Copy link
Author

apvijay commented Jan 20, 2017

The error is the same. It does not execute the last statement print("Deallocate resized image - done").

Read image - done	
Cuda conversion - done	
Deallocate image - done	
Resize - done	
  768
 1024
    3
[torch.LongStorage of size 3]

torch.CudaTensor	
THCudaCheck FAIL file=/tmp/luarocks_cutorch-scm-1-1283/cutorch/lib/THC/generic/THCStorage.c line=182 error=17 : invalid device pointer
/home/ipcv/torch/install/bin/luajit: cuda runtime error (17) : invalid device pointer at /tmp/luarocks_cutorch-scm-1-1283/cutorch/lib/THC/generic/THCStorage.c:182

The code works with CUDA 6.5/OpenCV 3.1/ Torch 7 on GTX-980 (5.2 arch).

It shows the above error with CUDA 8.0 on Titan-X Pascal (6.1 arch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants