Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw fatal exception during 'import cudaq' if missing dependencies #1152

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions python/utils/LinkedLibraryHolder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. *
* Copyright (c) 2022 - 2024 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
Expand Down Expand Up @@ -255,10 +255,27 @@ LinkedLibraryHolder::LinkedLibraryHolder() {

// Set the default target
// If environment variable set with a valid value, use it
// Otherwise, if GPU(s) available, set default to 'nvidia', else to 'qpp-cpu'
// Otherwise, if GPU(s) available and other dependencies are satisfied, set
// default to 'nvidia', else to 'qpp-cpu'
defaultTarget = "qpp-cpu";
if (countGPUs() > 0) {
defaultTarget = "nvidia";
// Before setting the defaultTarget to nvidia, make sure the simulator is
// available.
const std::string nvidiaTarget = "nvidia";
auto iter = targets.find(nvidiaTarget);
if (iter != targets.end()) {
auto target = iter->second;
if (std::find(availableSimulators.begin(), availableSimulators.end(),
target.simulatorName) != availableSimulators.end())
defaultTarget = nvidiaTarget;
else
cudaq::info(
"GPU(s) found but cannot select nvidia target because simulator "
"is not available. Are all dependencies installed?");
} else {
cudaq::info("GPU(s) found but cannot select nvidia target because nvidia "
"target not found.");
}
}
auto env = std::getenv("CUDAQ_DEFAULT_SIMULATOR");
if (env) {
Expand Down
Loading