How to get the input values of each layer with TensorRT-3.0?

I created a net of SSD using TensorRT with Plugin layers such as Permute, Flatten, Reshape and so on. I run the net, the result is wrong. I want to print the input values of each layer to find out which layer is wrong. While I print the input values of the Flatten layer which I create as a plugin layer as follows:

class Flatten : public IPlugin
{
......
	int enqueue(int batchSize, const void*const *inputs, void** outputs, void*, cudaStream_t stream) override
	{
		printf("\nFlatten:\n");
		float* input_0 = (float*)inputs[1];
		for(int i = 0; i < 100; i++)
			printf("%f ", input_0[i]);
		printf("\nend\n");
		CHECK(cudaMemcpyAsync(outputs[0], inputs[0], mCopySize * batchSize, cudaMemcpyDeviceToDevice, stream));
		return 0;
	}

......
}

But the print result is all 0.00000. I change float* input_0 = (float*)inputs[1]; to float* input_0 = (float*)inputs[0]; it comes out “Segmentation fault (core dumped)”. I’m not sure what’s wrong with the print.
Could someone give me some suggestions? Thank you in advance!

Hi,

TensorRT input/output blob is GPU memory.
Please remember to copy the memory back to CPU first, or it will lead to the segmentation fault.

Thanks.

Hi, AastaLLL, I have run the Face-Recognition(https://github.com/AastaNV/Face-Recognition) on my TX2 using a USB camera, while it came out the following error:

Building and running a GPU inference engine for /home/nvidia/Face-Recognition/data/deploy.prototxt, N=1...
[gstreamer] initialized gstreamer, version 1.8.3.0
[gstreamer] gstreamer decoder pipeline string:
v4l2src device=/dev/video0 ! video/x-raw, width=(int)1280, height=(int)720, format=RGB ! videoconvert ! video/x-raw, format=RGB ! videoconvert !appsink name=mysink
successfully initialized video device
    width:  1280
   height:  720
    depth:  24 (bpp)

Bindings after deserializing:
Binding 0 (data): Input.
Binding 1 (coverage_fd): Output.
Binding 2 (bboxes_fd): Output.
Binding 3 (count_fd): Output.
Binding 4 (bbox_fr): Output.
Binding 5 (bbox_id): Output.
Binding 6 (softmax_fr): Output.
Binding 7 (label): Output.
loaded image  /home/nvidia/Face-Recognition/data/fontmapA.png  (256 x 512)  2097152 bytes
[cuda]  cudaAllocMapped 2097152 bytes, CPU 0x102a00000 GPU 0x102a00000
[cuda]  cudaAllocMapped 8192 bytes, CPU 0x102c00000 GPU 0x102c00000
default X screen 0:   1920 x 1080
[OpenGL]  glDisplay display window initialized
[OpenGL]   creating 1280x720 texture
[gstreamer] gstreamer transitioning pipeline to GST_STATE_PLAYING
[gstreamer] gstreamer changed state from NULL to READY ==> mysink
[gstreamer] gstreamer changed state from NULL to READY ==> videoconvert1
[gstreamer] gstreamer changed state from NULL to READY ==> capsfilter1
[gstreamer] gstreamer changed state from NULL to READY ==> videoconvert0
[gstreamer] gstreamer changed state from NULL to READY ==> capsfilter0
[gstreamer] gstreamer changed state from NULL to READY ==> v4l2src0
[gstreamer] gstreamer changed state from NULL to READY ==> pipeline0
[gstreamer] gstreamer changed state from READY to PAUSED ==> videoconvert1
[gstreamer] gstreamer changed state from READY to PAUSED ==> capsfilter1
[gstreamer] gstreamer changed state from READY to PAUSED ==> videoconvert0
[gstreamer] gstreamer changed state from READY to PAUSED ==> capsfilter0
[gstreamer] gstreamer stream status CREATE ==> src
[gstreamer] gstreamer changed state from READY to PAUSED ==> v4l2src0
[gstreamer] gstreamer changed state from READY to PAUSED ==> pipeline0
[gstreamer] gstreamer msg new-clock ==> pipeline0
[gstreamer] gstreamer changed state from PAUSED to PLAYING ==> videoconvert1
[gstreamer] gstreamer changed state from PAUSED to PLAYING ==> capsfilter1
[gstreamer] gstreamer changed state from PAUSED to PLAYING ==> videoconvert0
[gstreamer] gstreamer changed state from PAUSED to PLAYING ==> capsfilter0
[gstreamer] gstreamer changed state from PAUSED to PLAYING ==> v4l2src0
[gstreamer] gstreamer decoder onEOS
[gstreamer] gstreamer stream status ENTER ==> src
[gstreamer] gstreamer msg stream-start ==> pipeline0
[gstreamer] gstreamer v4l2src0 ERROR Internal data flow error.
[gstreamer] gstreamer Debugging info: gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason not-negotiated (-4)
[gstreamer] gstreamer changed state from READY to PAUSED ==> mysink
Allocate memory: input blob
Allocate memory: coverage
Allocate memory: box
Allocate memory: count
Allocate memory: selected bbox
Allocate memory: selected index
Allocate memory: softmax
Allocate memory: label
failed to capture frame
failed to convert from NV12 to RGBA
[cuda]   cudaPreImageNetMean((float4*)imgRGBA, camera->GetWidth(), camera->GetHeight(), data, dimsData.w(), dimsData.h(), make_float3(127.0f, 127.0f, 127.0f))
[cuda]      invalid device pointer (error 17) (hex 0x11)
[cuda]      /home/nvidia/Face-Recognition/face-recognition/face-recognition.cpp:223
cudaPreImageNetMean failed

Could you please give me some advice?

Hi,

It’s recommended to file another topic for a new question.
This will help users to find the information they needed more efficiently.

Thanks.