Cannot call host function in CUDA global function for ZED camera and Jetson TX1

Hello,

I am using the ZED Stereo camera from Stereo labs to acquire rgb and depth images on Jetson TX1. However, when I try to acquire both the streams in parallel on two different threads using CUDA global function, it gives me an error “cannot call a host function in global function”.

I am using “zed->retrieveImage” function of ZED in CUDA global function to retrieve rgb image from the ZED camera. Zed header file is included in the program code.

Please give inputs if anyone has faced similar issues.

Regards,
BHARATS

What’s the output of nvcc -V ?

Setting up the ZED was pretty straightforward for me. Also, make sure you’re using the 3.0 port.

I think your error “cannot call a host function in global function” mean that you try to use a CPU method instead of using the GPU one (the global function). Try with the

retrieveImage<b>_gpu</b>

.

Thanks AlexP312 for the reply.

The output of nvcc -V is

nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2015 NVIDIA Corporation
Built on Sun_Nov_15_11:52:02_CST_2015
Cuda compilation tools, release 7.0, V7.0.72

I am using usb 3.0 port on Jetson TX1.

I am able to view the rgb and depth streams through the zed explorer which comes with the zed sdk, that means zed is setup properly.

Thanks NotANumber for the reply.

I tried with retrieveImage_gpu but no success.

I am including zed/Camera.hpp file in the code and then allocating memory on the gpu for zed mat container and calling the global function from main function to retrieve rgb images.
The chunk of code shown below is what I am trying.

#include <zed/Camera.hpp>

global void getRGB(sl::zed::Camera *zed,sl::zed::Mat *left)
{
left = zed->retrieveImage_gpu(sl::zed::SIDE::LEFT);
}

int main(int argc, char** argv)
{

sl::zed::Camera* zed = new sl::zed::Camera(sl::zed::HD720);
sl::zed::ERRCODE err = zed->init(sl::zed::MODE::PERFORMANCE, -1, true);

cv::Mat *h_image ;
h_image= new cv::Mat(width, height, CV_8UC4, cv::Scalar::all(0));
sl::zed::Mat *d_image ;
d_image= new sl::zed::Mat();

if (!zed->grab(sl::zed::SENSING_MODE::FULL))
{
cudaMalloc((void**)&d_image, widthheight4sizeof(uchar));
getRGB<<<1, 1>>>(zed, d_image);
cudaMemcpy(h_image->data,d_image->data,width
height4sizeof(uchar), cudaMemcpyDeviceToHost);

      while(1)
      {
     // Display image in OpenCV window	 
      }

}
}