Skip to content

Commit b8b9c1e

Browse files
authored
Cache GPUSupport.isSupported value (elastic#136665)
1 parent 2ec3a44 commit b8b9c1e

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
@@ -32,6 +32,8 @@ public enum GpuMode {
3232
AUTO
3333
}
3434

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

0 commit comments

Comments
 (0)