diff --git a/faiss/python/__init__.py b/faiss/python/__init__.py index 61bac72b55..9d956ebe71 100644 --- a/faiss/python/__init__.py +++ b/faiss/python/__init__.py @@ -9,6 +9,7 @@ # causes a ton of useless warnings. import numpy as np +import logging import sys import inspect @@ -30,6 +31,8 @@ FAISS_VERSION_MINOR, FAISS_VERSION_PATCH) +logger = logging.getLogger(__name__) + class_wrappers.handle_Clustering(Clustering) class_wrappers.handle_Clustering1D(Clustering1D) class_wrappers.handle_MatrixStats(MatrixStats) @@ -161,14 +164,13 @@ def replacement_function(*args): try: - from swigfaiss_gpu import GpuIndexIVFFlat, GpuIndexBinaryFlat, GpuIndexFlat, GpuIndexIVFPQ, GpuIndexIVFScalarQuantizer add_ref_in_constructor(GpuIndexIVFFlat, 1) add_ref_in_constructor(GpuIndexBinaryFlat, 1) add_ref_in_constructor(GpuIndexFlat, 1) add_ref_in_constructor(GpuIndexIVFPQ, 1) add_ref_in_constructor(GpuIndexIVFScalarQuantizer, 1) -except ImportError as e: - print("Failed to load GPU Faiss: %s. Will not load constructor refs for GPU indexes." % e.args[0]) +except NameError as e: + logger.info("Failed to load GPU Faiss: %s. Will not load constructor refs for GPU indexes." % e.args[0]) add_ref_in_constructor(IndexIVFFlat, 0) add_ref_in_constructor(IndexIVFFlatDedup, 0)