Skip to content

Commit

Permalink
gpu_bindings_test.go: added a test for TestFreeGPUResource
Browse files Browse the repository at this point in the history
Its not really the best, but I assume that most Gpus will run out of
memory when creating 20 gpu indices, so if the test passes, most likely
the free function is working ;)
  • Loading branch information
uhbuhb committed Sep 29, 2021
1 parent 681a91a commit 72e5dea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gpu_bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package faiss
import (
"github.com/stretchr/testify/require"
"testing"
"time"
)

func TestFlatIndexOnGpuFunctionality(t *testing.T) {
Expand Down Expand Up @@ -114,3 +115,19 @@ func TestTransferToGpuAndBack(t *testing.T) {

}

func TestFreeGPUResource(t *testing.T) {
for i := 0; i < 20; i++ {
t.Logf("creating index %v", i)
flatIndex, err := NewIndexFlatIP(256)
require.Nil(t, err)
flatIndexGpu, err := TransferToGpu(flatIndex)
require.Nil(t, err)

t.Log("created indexes, freeing..")
err = Free(flatIndexGpu)
require.Nil(t, err)
t.Log("freed, memory should be freed..")
time.Sleep(1 * time.Second)
}

}

0 comments on commit 72e5dea

Please sign in to comment.