K230_SDK_update_nncase_runtime_tutorial#
Nncase Runtime Library Version Description#
Kmodel Version Description#
Since the kmodel does not contain version information about “nncase”, it is impossible to directly determine which version of nncase was used to generate the kmodel. It is necessary to manage version information independently; here are two approaches for reference:
Retain the complete compilation project (calibration set, parameter configurations), making it convenient to generate the
kmodel.Differentiate versions by naming the
kmodel, as demonstrated in the following sample code.with open("test.kmodel", "wb") as f: f.write(kmodel) # Replace the above code with the following content import _nncase with open("test_{}.kmodel".format(_nncase.__version__), "wb") as f: f.write(kmodel)
Version Incompatibility Issue#
Due to potential incompatibilities between different versions of nncase, the version of the nncase runtime library included in the SDK may not match the version of nncase used to compile the kmodel, which could lead to abnormalities during on-board inference. Therefore, it is advisable to check whether the two versions are compatible before performing on-board inference.
There are two methods available for verifying the version compatibility:
Query the version correspondence table: Refer to the Version Correspondence Table to confirm that the SDK and nncase versions match.
Determine the versions through the image name: For instance, in the image file named
k230_canmv_sdcard_v1.4_nncase_v2.8.0.img.gz,v1.4represents the SDK version, whilev2.8.0indicates the nncase version. This means that SDK-v1.4 can correctly inferkmodelhas compiled by nncase-v2.8.0. The corresponding images can be obtained from the Canaan Developer Community.
Solutions for Version Incompatibility#
Align with SDK Version After determining the required nncase version, install it using
pip, referring to the nncase Installation Guide for specific instructions.Align with Nncase Version Download the runtime library that matches the version of nncase used when compiling the
kmodelfile from the nncase Release Page. For instance, ‘nncase_k230_v2.8.0_runtime.tgz’ represents the runtime library compatible with nncase version 2.8.0. Following this, proceed with updating the nncase runtime library version within the SDK by following these steps:#Preparation work. git clone https://github.com/kendryte/k230_sdk.git cd k230_sdk PATH_TO_K230_SDK=`pwd` make prepare_sourcecode # Please make sure to verify if the following directory exists after running the given command. # src/big/nncase/riscv64/nncase/ #decompressing files "nncase_k230_v2.8.0_runtime.tgz" tar -xf nncase_k230_v2.8.0_runtime.tgz #update nncase runtime library. cp -r nncase_k230_v2.8.0_runtime/* $PATH_TO_K230_SDK/src/big/nncase/riscv64/nncase/ #Check whether the nncase runtime library has been correctly updated. cat $PATH_TO_K230_SDK/src/big/nncase/riscv64/nncase/include/nncase/version.h | grep NNCASE_VERSION > #define NNCASE_VERSION "2.8.0"
Now, the version of nncase runtime library within the SDK has been upgraded to nncase-2.8.0. Should you require switching to a different version, just download the matching runtime library and proceed with the update using the aforementioned steps.
