frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Problems with Python Multiprocessing using SDK 2.0.0.4

Using device on a Rpi 3 Model B+ with the latest OS for a robotics project

I'm using SSD MobileNets to do real time object detection for the robot. I kickoff a process to do the predictions function (similar def run_inference function in the Movidius NC App Zoo GitHub example (https://github.com/movidius/ncappzoo/blob/master/caffe/SSD_MobileNet/run.py)). The function works fine when its part of the main but it won't execute when dispatch it another core. I believe the issue is it can find the device. I'm surmising this because I tried to open the device on a core other then the main and got the following error:

W: [ 0] ncDeviceOpen:505 ncDeviceOpen() XLinkBootRemote returned error 3
the TraceBack toot me here:
File "/usr/local/lib/python2.7/dist-packages/mvnc/mvncapi.py", line 448, in open
raise Exception(Status(status))
Exception: Status.ERROR

Can the Movidius device only work on the main core on Rpi? Any help would be greatly appreciated.

Comments

  • 3 Comments sorted by Votes Date Added
  • @sggriset Check to see if your process running on the main core if it has released the device handle for the NCS device. It seems like the device may still be pegged on the main core.

  • Sorry for the long response. I turned off the Rpi 3 and unplugged the NCS device. I booted the Rpi3 and ran lsusb both without and with the NCS plugged in to get the VID & PID and got the following read out:

    pi@edge_rover:~ $ cd ~/edge_rover/edge_runner
    pi@edge_rover:~/edge_rover/edge_runner $ lsusb
    Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp. 
    Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
    Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    pi@edge_rover:~/edge_rover/edge_runner $ lsusb
    Bus 001 Device 005: ID 03e7:2150  
    Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp. 
    Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
    Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    pi@edge_rover:~/edge_rover/edge_runner
    

    So the VID = 0x3e7 and PID = 0x2150 are these for the NCS device. Then put this python snippet based on the program the hello_ncs.py snippet

    # import necessary libs
    import multiprocessing as mp
    import usb.core
    import usb.util
    import mvnc.mvncapi as movi
    
    VID = 0x03e7
    PID = 0x2150
    
    def find_dev():
        mob_device = usb.core.find(idVendor=VID, idProduct=PID)
        if not mob_device:
            print "[INFO] Movidius Device Not Found"
            exit(1)
        print "[INFO] Found Movidius Device"
        # set the logging level for the Movidius device
        movi.global_set_option(movi.GlobalOption.RW_LOG_LEVEL, 0)
    
        devices = movi.enumerate_devices()
        if(len(devices) < 1):
            print("[INFO] Error - no Movidius devices detected")
            exit(1)
    
        # get the first NCS device
        dev = movi.Device(devices[0])
    
        try:
            dev.open()
        except:
            print("[INFO] Error - Could not open NCS device.")
            exit(1)
    
        print("[INFO] NCS Device is found")
    
        try:
            dev.close()
        except:
            print("[INFO] Error - could not close device")
            exit(1)
    
        print("[INFO] NCS Device closed normally")
        print("NCS device working,")
        exit(0)     
    
    
    def main():
        devtest = mp.Process(target = find_dev)
        devtest.start()
        pid = devtest.pid
        print(pid)
        devtest.join()
    
    if __name__ == '__main__':
        main()
    

    I ran the program and got the following results

    [INFO] Found Movidius Device
    D : [         0] ncDeviceCreate:307 ncDeviceCreate index 0
    
    D : [         0] ncDeviceCreate:307 ncDeviceCreate index 1
    
    D : [         0] ncDeviceOpen:501   File path /usr/local/lib/mvnc/MvNCAPI-ma2450.mvcmd
    
    I: [         0] ncDeviceOpen:507    ncDeviceOpen() XLinkBootRemote returned success 0
    
    W: [         0] ncDeviceOpen:533    failed to find device
    
    [INFO] Error - Could not open NCS device.
    

    Now when I run lsusb

    Bus 001 Device 006: ID 03e7:f63b  
    Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp. 
    Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
    Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    

    So it looks like when you try to open the device in core other then in the main core it changes the PID (product ID). Can you please run a test using my snippet, I think I may have a bad device.

  • Sorry something happen with the paste on the code snippet:

    # import necessary libs
    import multiprocessing as mp
    import usb.core
    import usb.util
    import mvnc.mvncapi as movi
    
    VID = 0x03e7
    PID = 0x2150
    
    def find_dev():
        mob_device = usb.core.find(idVendor=VID, idProduct=PID)
        if not mob_device:
            print "[INFO] Movidius Device Not Found"
            exit(1)
        print "[INFO] Found Movidius Device"
        # set the logging level for the Movidius device
        movi.global_set_option(movi.GlobalOption.RW_LOG_LEVEL, 0)
    
        devices = movi.enumerate_devices()
        if(len(devices) < 1):
            print("[INFO] Error - no Movidius devices detected")
            exit(1)
    
        # get the first NCS device
        dev = movi.Device(devices[0])
    
        try:
            dev.open()
        except:
            print("[INFO] Error - Could not open NCS device.")
            exit(1)
    
        print("[INFO] NCS Device is found")
    
        try:
            dev.close()
        except:
            print("[INFO] Error - could not close device")
            exit(1)
    
        print("[INFO] NCS Device closed normally")
        print("NCS device working,")
        exit(0)     
    
    
    def main():
        devtest = mp.Process(target = find_dev)
        devtest.start()
        pid = devtest.pid
        print(pid)
        devtest.join()
    
    if __name__ == '__main__':
        main()
    
Sign In or Register to comment.