Skip to content

Commit

Permalink
[inf2] Fixes NeuronUtils.getNeuronCores() bug (deepjavalibrary#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu authored Mar 8, 2023
1 parent c6146eb commit 8a90769
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions serving/src/main/java/ai/djl/serving/util/NeuronUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public static int getNeuronCores() {
if (!hasNeuron()) {
return 0;
}
try (Stream<Path> paths = Files.walk(Paths.get("/dev"))) {
int nd = (int) paths.filter(ele -> ele.startsWith("neuron")).count();
try (Stream<Path> paths = Files.list(Paths.get("/dev"))) {
long nd = paths.filter(p -> p.getFileName().toString().startsWith("neuron")).count();
if (isInf1()) {
// inf1 has 4 cores on each device
return nd * 4;
return (int) nd * 4;
}
// inf2 has 2 cores on each device
return nd * 2;
return (int) nd * 2;
} catch (IOException e) {
throw new AssertionError("Failed to list neuron cores", e);
}
Expand Down

0 comments on commit 8a90769

Please sign in to comment.