From 6b96b0784de528506848b72bc0a8ad7782e4aa0c Mon Sep 17 00:00:00 2001 From: ramilbakhshyiev <7597197+ramilbakhshyiev@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:28:42 -0700 Subject: [PATCH 1/2] Add midding hipStream SWIG typedef to fix ROCm memleak in Python Summary: This fixes the memleak and the warning received after running Python tests under ROCm since no destructor was declared and objects would remain allocated. Differential Revision: D61357579 --- faiss/python/swigfaiss.swig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/faiss/python/swigfaiss.swig b/faiss/python/swigfaiss.swig index 43c8d6c422..752b64b55b 100644 --- a/faiss/python/swigfaiss.swig +++ b/faiss/python/swigfaiss.swig @@ -352,6 +352,8 @@ void gpu_sync_all_devices() %include %include +typedef ihipStream_t* hipStream_t; + %inline %{ // interop between pytorch exposed hipStream_t and faiss From e1ff45fe5fc4e6e9d543be2da2719ac56628c603 Mon Sep 17 00:00:00 2001 From: ramilbakhshyiev <7597197+ramilbakhshyiev@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:28:42 -0700 Subject: [PATCH 2/2] Reorder imports in torch_test_contrib_gpu (#3761) Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3761 This fixes CUDA errors inside faiss in the test environment. If torch is loaded first (this change) then both torch and faiss see all GPUs available on the machine in the ROCm build. Without this change, torch sees the GPUs and faiss does not. AMD team is looking at finding the root cause but we wanted to fix this for now. Reviewed By: mnorris11 Differential Revision: D61358018 --- faiss/gpu/test/torch_test_contrib_gpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faiss/gpu/test/torch_test_contrib_gpu.py b/faiss/gpu/test/torch_test_contrib_gpu.py index f7444337f1..f1a92c33b3 100644 --- a/faiss/gpu/test/torch_test_contrib_gpu.py +++ b/faiss/gpu/test/torch_test_contrib_gpu.py @@ -3,10 +3,10 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -import faiss import torch import unittest import numpy as np +import faiss import faiss.contrib.torch_utils def to_column_major_torch(x):