"...git@developer.sourcefind.cn:OpenDAS/openpcdet.git" did not exist on "ac5198a7ad7facc5d2febaa46c92116440541502"
Commit 59442d9b authored by Jeremy Francis Reizenstein's avatar Jeremy Francis Reizenstein
Browse files

report whether CUDA is built

parent 305ef8df
......@@ -7,8 +7,14 @@
import torch
import sparseconvnet as scn
# Use the GPU if there is one, otherwise CPU
device = 'cuda:0' if torch.cuda.is_available() else 'cpu'
# Use the GPU if there is one and sparseconvnet can use it, otherwise CPU
use_cuda = torch.cuda.is_available() and scn.SCN.is_cuda_build()
device = 'cuda:0' if use_cuda else 'cpu'
if use_cuda:
print("Using CUDA.")
else:
print("Not using CUDA.")
model = scn.Sequential().add(
scn.SparseVggNet(2, 1,
......
......@@ -232,4 +232,5 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
&CopyFeaturesHelper_updateGradInput, "");
m.def("n_rulebook_bits", []() { return 8 * sizeof(Int); }, "");
m.def("is_cuda_build", &is_cuda_build, "");
}
......@@ -237,3 +237,4 @@ void CopyFeaturesHelper_updateOutput(at::Tensor &rules, at::Tensor &context,
at::Tensor &Context);
void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext,
at::Tensor &dContext);
bool is_cuda_build();
......@@ -589,3 +589,5 @@ void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext,
at::Tensor &dContext) {
cpu_CopyFeaturesHelper_updateGradInput<float>(rules, dcontext, dContext);
}
bool is_cuda_build() {return false;}
......@@ -819,3 +819,5 @@ void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext,
else
cpu_CopyFeaturesHelper_updateGradInput<float>(rules, dcontext, dContext);
}
bool is_cuda_build() {return true;}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment