Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,18 @@ type gpuSnapshotStore struct {
func newGPUSnapshotStore() *gpuSnapshotStore {
snapshots := make([]*gpuSnapshot, gpuCount)
for device := 0; device < gpuCount; device++ {
// get total free memory for the GPU device.
cDev := C.int(device)
totMemory := uint64(0)
var freeBytes C.size_t
if c := C.faiss_gpu_free_memory(
C.int(device),
&freeBytes,
); c == 0 {
totMemory = uint64(freeBytes)
// first probe if the device is healthy and can be used
var probeResult C.int
if c := C.faiss_probe_gpu(cDev, &probeResult); c == 0 && probeResult == 0 {
var freeBytes C.size_t
if c := C.faiss_gpu_free_memory(
Comment thread
CascadingRadium marked this conversation as resolved.
cDev,
&freeBytes,
); c == 0 {
totMemory = uint64(freeBytes)
}
}
Comment thread
CascadingRadium marked this conversation as resolved.
// if we fail to get the free memory for the GPU,
// we still create a snapshot with 0 total and free memory,
Expand Down