"git@developer.sourcefind.cn:OpenDAS/openpcdet.git" did not exist on "4a8a3bf72f563bf8f3ea76b72e49fec4c2414b3f"
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 @@ ...@@ -7,8 +7,14 @@
import torch import torch
import sparseconvnet as scn 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( model = scn.Sequential().add(
scn.SparseVggNet(2, 1, scn.SparseVggNet(2, 1,
......
...@@ -232,4 +232,5 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { ...@@ -232,4 +232,5 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
&CopyFeaturesHelper_updateGradInput, ""); &CopyFeaturesHelper_updateGradInput, "");
m.def("n_rulebook_bits", []() { return 8 * sizeof(Int); }, ""); 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, ...@@ -237,3 +237,4 @@ void CopyFeaturesHelper_updateOutput(at::Tensor &rules, at::Tensor &context,
at::Tensor &Context); at::Tensor &Context);
void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext, void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext,
at::Tensor &dContext); at::Tensor &dContext);
bool is_cuda_build();
...@@ -589,3 +589,5 @@ void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext, ...@@ -589,3 +589,5 @@ void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext,
at::Tensor &dContext) { at::Tensor &dContext) {
cpu_CopyFeaturesHelper_updateGradInput<float>(rules, dcontext, 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, ...@@ -819,3 +819,5 @@ void CopyFeaturesHelper_updateGradInput(at::Tensor &rules, at::Tensor &dcontext,
else else
cpu_CopyFeaturesHelper_updateGradInput<float>(rules, dcontext, dContext); 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