From 7d7e075519ec86e867f52a426488449606c3f19f Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Sun, 20 Jun 2021 14:42:03 +0300 Subject: [PATCH] Make TF availability check optional (#305) * Make tf availability check optional * update changelog --- CHANGELOG.md | 2 +- datumaro/util/tf_util.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c17e398a02b3..8d7b6d86eaf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - A base class for dataset validation plugins () ### Changed -- +- Tensorflow AVX check is made optional in API and is disabled by default () ### Deprecated - diff --git a/datumaro/util/tf_util.py b/datumaro/util/tf_util.py index 9eda97bab9c8..a185704e52bf 100644 --- a/datumaro/util/tf_util.py +++ b/datumaro/util/tf_util.py @@ -4,6 +4,8 @@ # SPDX-License-Identifier: MIT +enable_tf_check = False + def check_import(): # Workaround for checking import availability: # Official TF builds include AVX instructions. Once we try to import, @@ -32,7 +34,7 @@ def check_import(): raise ImportError(message) -def import_tf(check=True): +def import_tf(check=None): import sys not_found = object() @@ -46,6 +48,9 @@ def import_tf(check=True): import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' + if check is None: + check = enable_tf_check + if check: try: check_import()