Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

problem of fifo destroy

idata
Employee
1,596 Views

Hi there,

 

When I compiled my code and susccessfully generates graph file. But I've met the problem of fifo destroying after I tried to make it work with ncs. The following context is the message I got:

 

#

 

E: [ 0] dispatcherEventReceive:247 dispatcherEventReceive() Read failed -1

 

E: [ 0] eventReader:268 Failed to receive event, the device may have reset

 

E: [ 0] checkGraphMonitorResponse:922 XLink error

 

W: [ 0] ncFifoDestroy:2545 myriad NACK

 

Error - could not close/destroy Graph/NCS device.

 

#

 

Thing to be clear is that I tried every USB port on my laptop.Also, my OS is ubuntu16.04, using ncs1 and ncsdk api 2.

 

Here is my code https://ideone.com/v4CGll

 

Thanks.
0 Kudos
5 Replies
idata
Employee
1,253 Views

Hi @yi-ru

 

In order to make sure that your system is recognizing the NCS and that it is able to run properly, can you try running any of the samples that are included in the NCSDK? If hello_ncs_cpp or hello_ncs_py run correctly, then we know that the NCS was able successfully open and close.

 

Sincerely,

 

Sahira
0 Kudos
idata
Employee
1,253 Views

I'm pretty sure that it can successfully open and close, cause I tried others code on the net and it did work.

 

So that's the reason I'm confused.

 

Thanks.
0 Kudos
idata
Employee
1,253 Views

I found out that the problem is the graph file I created can't be destroyed.

 

But there isn't much inform about this situation on the net.

 

Thanks.
0 Kudos
idata
Employee
1,253 Views

Same happens with me as well.

0 Kudos
idata
Employee
1,253 Views

Hi @yi-ru and @Sayak_Paul

 

Below is a Python script that will load up a graph file and then destroy it. When i ran this script, I did not run into the above error.

 

Please run this and let me know if this is helpful.

 

#!/usr/bin/env python3 import cv2 import numpy import ntpath import skimage.io import skimage.transform import mvnc.mvncapi as mvnc graph_file = 'graph' # <path-to>/ncappzoo/caffe/GoogLeNet/graph test_image = 'cat.jpg' # <path-to>/ncappzoo/data/images/cat.jpg labels_val = 'synset_words.txt' # <path-to>/ncapzoo/data/ilsvrc12/synset_words.txt mean_val = [104.00698793, 116.66876762, 122.67891434] # delimited floating point values for image mean scale_val = 1 dim_val = [224, 224] # image dimensions, i.e. -D 224 224 colormode = 'BGR' # RGB for TensorFlow # Number of top prodictions to print TOP_PREDICTIONS = 5 # Look for enumerated NCS device(s); quit program if none found. devices = mvnc.enumerate_devices() if len( devices ) == 0: print( "No NCS device found" ) quit() # Get a handle to the first enumerated device and open it device = mvnc.Device( devices[0] ) device.open() # Read the graph file into a buffer with open( graph_file, mode='rb' ) as f: blob = f.read() # Load the graph buffer into the NCS graph = mvnc.Graph( graph_file ) # Set up fifos fifo_in, fifo_out = graph.allocate_with_fifos( device, blob ) # Load the labels file labels =[ line.rstrip('\n') for line in open( labels_val ) if line != 'classes\n'] # Read & resize image [Image size is defined during training] img = skimage.io.imread( test_image ) img = skimage.transform.resize( img, dim_val, preserve_range=True ) # Convert RGB to BGR [skimage reads image in RGB, but Caffe uses BGR] if( colormode == "BGR" ): img = img[:, :, ::-1] # Mean subtraction & scaling [A common technique used to center the data] img = ( img - mean_val ) * scale_val # The first inference takes an additional ~20ms due to memory # initializations, so we make a 'dummy forward pass'. graph.queue_inference_with_fifo_elem( fifo_in, fifo_out, img.astype(numpy.float32), None ) output, userobj = fifo_out.read_elem() # Load the image as an array graph.queue_inference_with_fifo_elem( fifo_in, fifo_out, img.astype(numpy.float32), None ) # Get the results from NCS output, userobj = fifo_out.read_elem() # Sort the indices of top predictions order = output.argsort()[::-1][:TOP_PREDICTIONS] # Get execution time inference_time = graph.get_option( mvnc.GraphOption.RO_TIME_TAKEN ) # Print the results print( "\n============================================" ) print( "Top predictions for", ntpath.basename( test_image ) ) print( "Execution time: " + str( numpy.sum( inference_time ) ) + "ms" ) print( "--------------------------------------------" ) for i in range( 0, TOP_PREDICTIONS ): print( "%3.1f%%\t" % (100.0 * output[ order[i] ] ) + labels[ order[i] ] ) print( "============================================\n" ) try: fifo_in.destroy() print("0 fifo_in destroyed") fifo_out.destroy() print("1 fifo_out destroyed") graph.destroy() print("2 graph destroyed") device.close() print("3 device closed") device.destroy() print("4 device destroyed") except: print("Error - could not close/destroy Graph/NCS device.") quit()

 

Best Regards,

 

Sahira
0 Kudos
Reply