Skip to content

Commit

Permalink
fix(torch): Raise an exception if gpu is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
Bycob authored and sileht committed Nov 9, 2020
1 parent eb74a51 commit 1f0887a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/backends/torch/torchlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ namespace dd
if (lib_ad.has("template"))
_template = lib_ad.get("template").get<std::string>();
if (lib_ad.has("gpu"))
gpu = lib_ad.get("gpu").get<bool>() && torch::cuda::is_available();
gpu = lib_ad.get("gpu").get<bool>();
if (gpu && !torch::cuda::is_available())
{
throw MLLibBadParamException(
"GPU is not available, service could not be created");
}
if (lib_ad.has("gpuid"))
gpuid = lib_ad.get("gpuid").get<int>();
if (lib_ad.has("nclasses"))
Expand Down

0 comments on commit 1f0887a

Please sign in to comment.