From 646c911f81cec0a199afd5e0e41db40b5fe0c6b3 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Fri, 7 Aug 2026 11:50:59 -0700 Subject: [PATCH] Query Realm machine to figure out if we have GPUs to run on. --- bin/run-model/src/run-model/main.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/run-model/src/run-model/main.cc b/bin/run-model/src/run-model/main.cc index 79830cfb6f..898faf9e22 100644 --- a/bin/run-model/src/run-model/main.cc +++ b/bin/run-model/src/run-model/main.cc @@ -95,6 +95,13 @@ int main(int argc, char **argv) { /*workSpaceSize=*/1024 * 1024, /*allowTensorOpMathConversion=*/true); + bool has_gpus = []() { + FlexFlow::Realm::Machine::ProcessorQuery pq( + FlexFlow::Realm::Machine::get_machine()); + pq.only_kind(FlexFlow::Realm::Processor::Kind::TOC_PROC); + return pq.count() > 0; + }(); + PCGInstance pcg_instance = create_pcg_instance( /*ctx=*/ctx, /*mpcg=*/mpcg, @@ -102,7 +109,7 @@ int main(int argc, char **argv) { /*loss=*/std::nullopt, /*input_tensors=*/input_tensors, /*device_handle=*/device_handle, - /*device_type=*/DeviceType::GPU); + /*device_type=*/has_gpus ? DeviceType::GPU : DeviceType::CPU); // begin training loop int num_epochs = 5;