Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
SparseConvNet
Commits
59442d9b
"...git@developer.sourcefind.cn:OpenDAS/openpcdet.git" did not exist on "ac5198a7ad7facc5d2febaa46c92116440541502"
Commit
59442d9b
authored
Sep 13, 2019
by
Jeremy Francis Reizenstein
Browse files
report whether CUDA is built
parent
305ef8df
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
2 deletions
+14
-2
examples/hello-world.py
examples/hello-world.py
+8
-2
sparseconvnet/SCN/pybind.cpp
sparseconvnet/SCN/pybind.cpp
+1
-0
sparseconvnet/SCN/sparseconvnet.h
sparseconvnet/SCN/sparseconvnet.h
+1
-0
sparseconvnet/SCN/sparseconvnet_cpu.cpp
sparseconvnet/SCN/sparseconvnet_cpu.cpp
+2
-0
sparseconvnet/SCN/sparseconvnet_cuda.cpp
sparseconvnet/SCN/sparseconvnet_cuda.cpp
+2
-0
No files found.
examples/hello-world.py
View file @
59442d9b
...
...
@@ -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
,
...
...
sparseconvnet/SCN/pybind.cpp
View file @
59442d9b
...
...
@@ -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
,
""
);
}
sparseconvnet/SCN/sparseconvnet.h
View file @
59442d9b
...
...
@@ -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
();
sparseconvnet/SCN/sparseconvnet_cpu.cpp
View file @
59442d9b
...
...
@@ -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
;}
sparseconvnet/SCN/sparseconvnet_cuda.cpp
View file @
59442d9b
...
...
@@ -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
;}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment