Sony's Developer World forum

    • Home
    • Forum guidelines

    DNNRT: runtime error

    Spresense
    3
    7
    232
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      neo11 0 last edited by

      hello,
      I was trying to implement a ML model on spresense using the DNNRT library, but I am facing an error

      dnnrt-mp included in bootloader isn't installed, or no memory space to load it
      

      more precisely, the

      dnnrt.begin() returns -16
      

      How to correct this issue?

      Thank you

      Armaghan 1 Reply Last reply Reply Quote
      • Referenced by  N neo11 0 
      • Armaghan
        Armaghan DeveloperWorld @neo11 0 last edited by

        @neo11-0
        I am not sure if you are running the example in the Spresense doc or if it is your own implementation, to start with DNNRT, please refer to section 5.5. DNN Runtime and run the sample code: https://developer.sony.com/develop/spresense/docs/sdk_developer_guide_en.html#_dnn_runtimehttps://developer.sony.com/develop/spresense/docs/sdk_developer_guide_en.html#_dnn_runtime

        Sample code is here:
        https://github.com/sonydevworld/spresense/tree/master/examples/dnnrt_lenet/

        I hope this helps.

        N 1 Reply Last reply Reply Quote
        • N
          neo11 0 @Armaghan last edited by

          @Armaghan
          sorry, i forgot to mention that i am using my model's code but facing error in dnnrt.begin section. Samples are runnin but same model on custom dataset isn't.

          Thanks

          J 1 Reply Last reply Reply Quote
          • J
            jens6151 0 1 1 @neo11 0 last edited by jens6151 0 1 1

            @neo11-0 I haven't used DNNRT once, but l can give some hints.

            I assume the bootloader is installed and the example sketch works.

            What is your model size?
            What is your setting of the memory for subcores?
            How much memory do you have left?

            If you do not know about the memory ...

            #include <MP.h>
            #include <fcntl.h>
            
              int used;
              int free;
              int freeContinuous;
              MP.GetMemoryInfo(used, free, freeContinuous);
              printf("Memory tile usage: used:%dK / free:%dK (Largest free:%dK)", used / 1024,
                            free / 1024, freeContinuous / 1024);
            
              int fd;
              char procfs_read_buf[128] = {0};
              
              fd = open(CONFIG_NSH_PROC_MOUNTPOINT "/meminfo", O_RDONLY);
            
              while (true) {
                memset(procfs_read_buf, 0, sizeof(procfs_read_buf));
                int nbytesread = read(fd, (void*)procfs_read_buf, sizeof(procfs_read_buf) - 1);
                if (nbytesread <= 0) {
                  break;
                } else {
            // If this line does not compile, please fix it.
                 Serial.print(procfs_read_buf, nbytesread);
                }
              }
            

            Btw if you search for EBUSY and files dnn*, there is only one hit

              ret = dnn_mpmgr_load(config->cpu_num - 1);
              if (ret != RT_RET_NOERROR)
                {
                  return -EBUSY;
                }
            

            Following the code I would guess the memory setting for the subcores is wrong.

            N 1 Reply Last reply Reply Quote
            • N
              neo11 0 @jens6151 0 1 1 last edited by

              @jens6151-0-1-1 yes the example search is working, thanks for your help. Your guess regarding the memory was correct, but can you please explain where to run this code? and where I need to search for the EBUSY you are have mentioned in the second code section?

              J 1 Reply Last reply Reply Quote
              • J
                jens6151 0 1 1 @neo11 0 last edited by

                @neo11-0 This is the concrete link to the file
                https://github.com/sonydevworld/spresense/blob/6cb78083aa3d58ef1a991f1477d9415f8951dc7e/sdk/modules/dnnrt/src-mp/runtime/runtime_client.c#L54

                It will call dnn_mpmgr_start_task
                There are 7 reasons to fail. So if you cannot find the issue, you could add printf statements there. If you are using Arduino IDE, it is some effort to recompile the SDK though.

                The above code just prints the memory situation. You can call it before dnnrt.begin().

                N 1 Reply Last reply Reply Quote
                • N
                  neo11 0 @jens6151 0 1 1 last edited by

                  @jens6151-0-1-1 Thank you so much, now its working fine.

                  1 Reply Last reply Reply Quote
                  • First post
                    Last post
                  Developer World
                  Copyright © 2021 Sony Group Corporation. All rights reserved.
                  • Contact us
                  • Legal