Skip to content

Commit cd2c2ac

Browse files
committed
Example program manipulate_current_device: Don't fail inadvertantly just because we only have one GPU on the system
1 parent 82a3de2 commit cd2c2ac

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/other/manipulate_current_device.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ int main()
2424
cuda::context::handle_t pc_handle[2];
2525

2626
cuda::initialize_driver();
27+
if (cuda::device::count() < 2) {
28+
std::cout << "The example program requires at least 2 GPUs, while this system only has "
29+
<< cuda::device::count() << '\n';
30+
return EXIT_SUCCESS;
31+
}
2732
dev_idx[0] = cur_dev::get_id();
2833
report_current_device();
2934
assert_(cur_dev::get_id() == 0);

0 commit comments

Comments
 (0)