bugfixing: gpus specified in engine.xconf must have eligible ids
@@ -17,8 +17,33 @@ public class NeuralDecoderConfig extends DecoderConfig {
return gpus;
}
+// public void setGPUs(int[] gpus) {
+// this.gpus = gpus;
+// }
+
public void setGPUs(int[] gpus) {
- this.gpus = gpus;
+ // exclude gpus, specified in the config file, but not available
+ // multiple occurrences of the same gpu are allowed
+ int gpuCount = 0;
+ for (int i = 0; i < gpus.length; i++) {
+ if (gpus[i] < DEFAULT_GPUS.length) {
+ gpuCount++;
+ } else {
+ gpus[i] = -1;
+ }
+ }
+
+ if (gpuCount>0) {
+ this.gpus= new int[gpuCount];
+ gpuCount = 0;
+ for (int i = 0; i < gpus.length; i++) {
+ if (gpus[i] != -1) {
+ this.gpus[gpuCount++] = gpus[i];
+ }
+ }
+ } else{
+ this.gpus = DEFAULT_GPUS;
+ }
}
@Override
