From 416211916d49eb8a88bc4edd3f1a9b0ef6ff3dce Mon Sep 17 00:00:00 2001 From: yoni13 Date: Sat, 11 Jan 2025 17:59:16 +0800 Subject: [PATCH] Check if NPU drivers is loaded or not. --- machine-learning/rknn/rknnpool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine-learning/rknn/rknnpool.py b/machine-learning/rknn/rknnpool.py index 0f7d2b5705..1bb967904d 100644 --- a/machine-learning/rknn/rknnpool.py +++ b/machine-learning/rknn/rknnpool.py @@ -1,6 +1,7 @@ # This code is from leafqycc/rknn-multi-threaded # Following Apache License 2.0 +import os from concurrent.futures import ThreadPoolExecutor from queue import Queue @@ -10,8 +11,6 @@ try: from rknnlite.api import RKNNLite with open("/proc/device-tree/compatible") as f: - # Keep in mind that this is not in container by default. - # and this way of checking can't check if the rknpu driver is running or not. device_compatible_str = f.read() for soc in supported_socs: if soc in device_compatible_str: @@ -19,6 +18,7 @@ try: break else: is_available = False + is_available = os.path.exists("/sys/kernel/debug/rknpu/load") except (FileNotFoundError, ImportError): is_available = False