Skip to content

Commit 4aa80fc

Browse files
authored
Cache GPUSupport.isSupported value (elastic#136665) (elastic#136693)
1 parent e29e610 commit 4aa80fc

File tree

1 file changed

+4
-2
lines changed
  • x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu

1 file changed

+4
-2
lines changed

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/GPUPlugin.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public enum GpuMode {
3131
AUTO
3232
}
3333

34+
private final boolean isGpuSupported = GPUSupport.isSupported(true);
35+
3436
/**
3537
* Setting to control whether to use GPU for vectors indexing.
3638
* Currently only applicable for index_options.type: hnsw.
@@ -68,14 +70,14 @@ public VectorsFormatProvider getVectorsFormatProvider() {
6870
"[index.vectors.indexing.use_gpu] doesn't support [index_options.type] of [" + indexOptions.getType() + "]."
6971
);
7072
}
71-
if (GPUSupport.isSupported(true) == false) {
73+
if (isGpuSupported == false) {
7274
throw new IllegalArgumentException(
7375
"[index.vectors.indexing.use_gpu] was set to [true], but GPU resources are not accessible on the node."
7476
);
7577
}
7678
return getVectorsFormat(indexOptions, similarity);
7779
}
78-
if (gpuMode == GpuMode.AUTO && vectorIndexTypeSupported(indexOptions.getType()) && GPUSupport.isSupported(false)) {
80+
if (gpuMode == GpuMode.AUTO && vectorIndexTypeSupported(indexOptions.getType()) && isGpuSupported) {
7981
return getVectorsFormat(indexOptions, similarity);
8082
}
8183
}

0 commit comments

Comments
 (0)