Skip to content

Commit c9aa560

Browse files
authored
Make device_count() return 0 when there is no GPU (#3486)
1 parent ff57d87 commit c9aa560

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

mlx/backend/metal/device_info.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ bool is_available() {
1313
}
1414

1515
int device_count() {
16-
return 1;
16+
try {
17+
metal::device(Device::gpu);
18+
return 1;
19+
} catch (...) {
20+
return 0;
21+
}
1722
}
1823

1924
const std::unordered_map<std::string, std::variant<std::string, size_t>>&

0 commit comments

Comments
 (0)