From bfcd15d6f93c66e357ff53b9be28e12759788d21 Mon Sep 17 00:00:00 2001 From: Mark Cottman-Fields Date: Sun, 28 May 2023 19:32:03 +1000 Subject: [PATCH] fix: explain xpdf install failure Log list of GPUs for tensorflow. --- .idea/leaf-focus.iml | 1 + install_xpdf.py | 6 +++++- src/leaf_focus/ocr/keras_ocr.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.idea/leaf-focus.iml b/.idea/leaf-focus.iml index 3bbb890..e6b14a8 100644 --- a/.idea/leaf-focus.iml +++ b/.idea/leaf-focus.iml @@ -16,6 +16,7 @@ + diff --git a/install_xpdf.py b/install_xpdf.py index 39f6b38..7967e05 100644 --- a/install_xpdf.py +++ b/install_xpdf.py @@ -117,7 +117,7 @@ def run(self) -> bool: raise ValueError(msg) logger.info("Finished.") - return False + return True def _get_url_file_name(self, url: str) -> str: parsed_url = urlparse(url) @@ -163,6 +163,7 @@ def _gpg_verify( result_import = subprocess.run(cmd_import, capture_output=True) expected_import_return_code = 2 if result_import.returncode != expected_import_return_code: + logger.warning("Unexpected return code '%s'.", result_import) # expecting return code 2 because there is no ultimately trusted key return False contains_email = [ @@ -171,6 +172,7 @@ def _gpg_verify( if expected_email in line.decode() ] if len(contains_email) != 1: + logger.warning("Unexpected stderr '%s'.", result_import) # gpg key must contain the expected email address return False @@ -185,6 +187,7 @@ def _gpg_verify( ] result_verify = subprocess.run(cmd_verify, capture_output=True) if result_verify.returncode != 0: + logger.warning("Unexpected return code '%s'.", result_verify) # expecting status code 0 return False contains_good_email = [ @@ -193,6 +196,7 @@ def _gpg_verify( if f"Good signature from {expected_email}" in line.decode() ] if len(contains_good_email) != 1: + logger.warning("Unexpected stderr code '%s'.", result_verify) # must be a 'good' signature with the expected key return False diff --git a/src/leaf_focus/ocr/keras_ocr.py b/src/leaf_focus/ocr/keras_ocr.py index d88441a..97d2620 100644 --- a/src/leaf_focus/ocr/keras_ocr.py +++ b/src/leaf_focus/ocr/keras_ocr.py @@ -48,6 +48,10 @@ def engine_create(self) -> None: tf.get_logger().setLevel(log_level) + # check the CPU / GPU in use + gpus = tf.config.list_physical_devices("GPU") + logger.info("GPUs in use: '%s'.", gpus) + try: import keras_ocr # pylint: disable=import-outside-toplevel except ModuleNotFoundError as error: