KL720 Description: ApiReturnCode.KP_ERROR_DEVICE_NOT_EXIST_10

I'm loading the same model for two chips. Sometimes, i will receive the error message below.

Error: upload model failed, error = 'Error raised in function: load_model. Error code: 10. Description: ApiReturnCode.KP_ERROR_DEVICE_NOT_EXIST_10'

Segmentation fault

My hardware information:

kn_number:  0x9C0A2D84

FW_version:  2.2.0-build.1226

PLUS_version: 2.2.0

Comments

  • Hi,

    Could you describe the environment/OS you're using the chips on? Are they both KL720 chips? How are they connected to your device? Which program on PLUS are you running? Thanks!

  • OS is busybox on armv7l GNU/Linux.

    Both chips are KL720 chips.

    Model is the yolov5 in res/models/KL720/YoloV5s_640_640_3

    I just extract the sample code which only initialize device and load model below.

    The usb_port_ids are all correct.

    import os

    import kp_yolo as kp

    from utils.ExampleHelper import get_device_usb_speed_by_port_id

    def init_device(usb_port_ids = [0]):

    """

    check device USB speed (Recommend run KL720 at super speed)

    """

    for usb_port_id in usb_port_ids:

    try:

    if kp.UsbSpeed.KP_USB_SPEED_SUPER != get_device_usb_speed_by_port_id(usb_port_id=usb_port_id):

    print('\033[91m' + '[Warning] Device is not run at super speed.' + '\033[0m')

    except Exception as exception:

    print('Error: check device USB speed fail, port ID = \'{}\', error msg: [{}]'.format(usb_port_id,

    str(exception)))

    exit(0)


    """

    connect the device

    """

    try:

    print('[Connect Device]')

    print(usb_port_ids)

    device_group = kp.core.connect_devices(usb_port_ids=usb_port_ids)

    print(' - Success')

    except kp.ApiKPException as exception:

    print('Error: connect device fail, port ID = \'{}\', error msg: [{}]'.format(usb_port_ids,

    str(exception)))

    exit(0)


    """

    setting timeout of the usb communication with the device

    """

    print('[Set Device Timeout]')

    kp.core.set_timeout(device_group=device_group, milliseconds=5000)

    print(' - Success')


    return device_group


    def init_model(device_group, args, name):

    """

    upload model to device

    """

    # MODEL_FILE_PATH = os.path.join(PWD, args.model)

    MODEL_FILE_PATH = os.path.join(PWD, name)

    try:

    print('[Upload Model]')

    model_nef_descriptor = kp.core.load_model_from_file(device_group=device_group,

    file_path=MODEL_FILE_PATH)

    print(' - Success')

    except kp.ApiKPException as exception:

    print('Error: upload model failed, error = \'{}\''.format(str(exception)))

    exit(0)


    device_group = init_device(usb_port_ids = [134])

    model_nef_descriptor, app_yolo_config = init_model(device_group, args, './models_720.nef')

    device_group1 = init_device(usb_port_ids = [262])

    model_nef_descriptor1, app_yolo_config1 = init_model(device_group1, args, './models_720.nef')

  • I found that when I execute the kp.core.load_model_from_file, the kl720 will disconnect and reconnect.

    The message below.

    [166578.771407] usb 2-1.2: USB disconnect, device number 84

    [166578.975077] usb 2-1.1: USB disconnect, device number 83

    [166580.094367] usb 2-1.2: new SuperSpeed USB device number 85 using xhci-hcd

    [166580.124511] usb 2-1.2: LPM exit latency is zeroed, disabling LPM.

    [166580.131699] usb 2-1.2: New USB device found, idVendor=3231, idProduct=0720

    [166580.138700] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

    [166580.146254] usb 2-1.2: Product: Kneron KL720

    [166580.150625] usb 2-1.2: Manufacturer: Kneron

    [166580.155026] usb 2-1.2: SerialNumber: 210A2D84

    [166580.454364] usb 2-1.1: new SuperSpeed USB device number 86 using xhci-hcd

    [166580.485095] usb 2-1.1: LPM exit latency is zeroed, disabling LPM.

    [166580.492471] usb 2-1.1: New USB device found, idVendor=3231, idProduct=0720

    [166580.500642] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

    [166580.508346] usb 2-1.1: Product: Kneron KL720

    [166580.512692] usb 2-1.1: Manufacturer: Kneron

    [166580.516960] usb 2-1.1: SerialNumber: 9C0A2D84

  • Hi,

    Thank you for answering the questions. I have some more questions: Are you using KL720 dongles? Or are you using KL720 development board?

    Also, have you followed the instructions in our documentation center? Install Dependency - Document Center (kneron.com)

    Have you tried running any examples in Kneron PLUS, such as KL720DemoGenericImageInference.py, and did they work properly?

    And yes, after loading a model, it is normal that the KL720 will reset its connection.

  • I'm using custom development board with KL720 soc.

    I'm installing the python package of KneronPLUS and KneronPLUS YOLO.

    Your examples are for one chips. But I encounter this problme only when I'm loading model on two chips.

  • Hi,

    According to your first post, it seems like the error appears sometimes and not every time. Do you know exactly where you encounter the error? Is it when you're uploading model onto the first KL720 chip or the second KL720 chip? Does your code loop through uploading model on one chip then another?

    Also, after you've encountered the error, when you perform scan_devices(), what KL720 device(s) can you see?


    Instead of straight-up uploading model on two chips, you can also go through these step by step:

    -Check if you can find both KL720 chips by using scan_devices()

    -Try uploading model with only one KL720 chip to see if it works (and try it with the other KL720 chip too, separately)

    -Try uploading model with two KL720 chips, uploading the model one at a time

    Please let us know if you tried every step, and where you got an error. Thanks!

  • edited May 28

    Hi Maria,

    Check if you can find both KL720 chips by using scan_devices()


    Try uploading model with only one KL720 chip to see if it works (and try it with the other KL720 chip too, separately)

    Almost worked


    Try uploading model with two KL720 chips, uploading the model one at a time

    Sometime will get error above

    All results were tested in previous comment code.

    After get this error, scan_devices() can see two chips.

  • Hi,

    Thank you for answering the questions and providing data.

    We can upload the same model onto 2 KL720 devices/chips by connecting different ports (in my case, port 61 and 53) at the same time with connect_devices(), then use load_model_from_file() and include the whole device group.

    After loading model, you could check if the model is correctly uploaded to your KL720 devices by running GenericCommand.py, specifying target (KL720) and each port ID.

    Also, it seems like your KL720 devices says "Connectable - False." Could you check which Boot Mode the chips are on with UART? Thanks!

    Documentation on UART: Flash Management - Document Center (kneron.com)

  • Hi Maria,

    I used the test code below. sometime load model on two chips will failed

    Model is the yolov5 in res/models/KL720/YoloV5s_640_640_3

    sometime load model on two chips will failed, but load model on one chips is successful.

    After this test, all chips can connect successfully.

    Also, I will check the boot mode with the machine integrator.

  • Hi,

    This could be a timing issue. When a model is already inside the KL720, the device would reset and reconnect. This reconnection would depend on the host to detect the KL720 device. At this time, if it takes too long, there's a possibility that the KL720 device can't be detected in time, causing the "KP_ERROR_DEVICE_NOT_EXIST_10" error.

    We could test this by manually resetting and reconnecting before loading the model, by going through these steps: Connect -> Reset -> Sleep -> Connect -> Load model

    The code flow would look something like this:

    -connect_devices() to connect to both KL720 devices

    -reset_device() (For the usage, please refer to GenericCommand.py). The function time.sleep() is included.

    -connect_devices() again to connect to both KL720 devices

    -load_model_from_file() to load the same model onto the two devices at the same time, just like your last code

    If the same error still appears, please set the parameter "sleep_secs" inside reset_device() longer and try again. Thanks!

  • edited May 30

    @Maria Chen

    Hi Maria,

    Does this test solve the "KP_ERROR_DEVICE_NOT_EXIST_10" error or just a test?

    I'm following your test steps below.

    After reset, I'm losing one of chips.

    But the losing chips can connect when I run this script again.


  • Hi,

    This should solve the error. Could you try it out with different sleep_secs and see which ones would work? (1 sec, 5 secs, 10 secs, etc.)

    Also, could you also try using connect_devices() instead of init_device()? Thanks!

  • @Maria Chen

    Hi Maria,

    I get the same results after change sleep_secs(1 sec, 5 secs, 10 secs) and replace init_device() with connect_devices().

    After reset device, I check with scan_device()

    I found that I lost the chips(262) and chips(134) "is_connectable": false.

    So I can't reconnect [134,262] again.

    But I can run script before reset successfully again.

  • Hi,

    If that's the case, could you test our Python code without editing anything? You could place it inside kneron_plus/python/example folder and run it. Thanks!

    By the way, when you print out your device info after connecting, it's normal that the connectivity could appear to be false.

  • edited May 31

    @Maria Chen

    Hi, Maria

    I tested your example for multiple chip which successes most of time.

    But I still get this error when load model first time.

    (Because your skip the disconnect chips, so I print the connect status)

    After this error, all chips can pass connect test by generic_command

    By the way, when I connect chips separately(with two device groups) then load model from file.

    I usually get the error above.

    Because I want to inference with two chips in multi-thread, so I create two device groups for this situation.

  • Hi,

    Thank you for testing the code. Since it would fail when loading the model for the first time, we've taken that out. Could you try running this code and see if it works? Thanks!


Sign In or Register to comment.