Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
713b7a94
Commit
713b7a94
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Detect and choose cuda device
parent
f170f3d0
No related branches found
No related tags found
1 merge request
!58
Implements #68 gpu selection
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
applications/reconstruct/include/ftl/voxel_scene.hpp
+2
-0
2 additions, 0 deletions
applications/reconstruct/include/ftl/voxel_scene.hpp
applications/reconstruct/src/voxel_scene.cpp
+29
-0
29 additions, 0 deletions
applications/reconstruct/src/voxel_scene.cpp
with
31 additions
and
0 deletions
applications/reconstruct/include/ftl/voxel_scene.hpp
+
2
−
0
View file @
713b7a94
...
@@ -81,6 +81,7 @@ class SceneRep : public ftl::Configurable {
...
@@ -81,6 +81,7 @@ class SceneRep : public ftl::Configurable {
private
:
private
:
bool
_initCUDA
();
HashParams
_parametersFromConfig
();
HashParams
_parametersFromConfig
();
void
_create
(
const
HashParams
&
params
);
void
_create
(
const
HashParams
&
params
);
void
_destroy
();
void
_destroy
();
...
@@ -102,6 +103,7 @@ class SceneRep : public ftl::Configurable {
...
@@ -102,6 +103,7 @@ class SceneRep : public ftl::Configurable {
std
::
vector
<
Cameras
>
cameras_
;
std
::
vector
<
Cameras
>
cameras_
;
cudaStream_t
integ_stream_
;
cudaStream_t
integ_stream_
;
bool
reg_mode_
;
bool
reg_mode_
;
int
cuda_device_
;
};
};
};
// namespace voxhash
};
// namespace voxhash
...
...
This diff is collapsed.
Click to expand it.
applications/reconstruct/src/voxel_scene.cpp
+
29
−
0
View file @
713b7a94
...
@@ -5,10 +5,13 @@
...
@@ -5,10 +5,13 @@
#include
<opencv2/core/cuda_stream_accessor.hpp>
#include
<opencv2/core/cuda_stream_accessor.hpp>
#include
<vector>
using
namespace
ftl
::
voxhash
;
using
namespace
ftl
::
voxhash
;
using
ftl
::
rgbd
::
Source
;
using
ftl
::
rgbd
::
Source
;
using
ftl
::
Configurable
;
using
ftl
::
Configurable
;
using
cv
::
Mat
;
using
cv
::
Mat
;
using
std
::
vector
;
#define SAFE_DELETE_ARRAY(a) { delete [] (a); (a) = NULL; }
#define SAFE_DELETE_ARRAY(a) { delete [] (a); (a) = NULL; }
...
@@ -23,6 +26,8 @@ extern "C" void integrateDepthMapCUDA(ftl::voxhash::HashData& hashData, const ft
...
@@ -23,6 +26,8 @@ extern "C" void integrateDepthMapCUDA(ftl::voxhash::HashData& hashData, const ft
SceneRep
::
SceneRep
(
nlohmann
::
json
&
config
)
:
Configurable
(
config
),
do_reset_
(
false
),
m_frameCount
(
0
)
{
SceneRep
::
SceneRep
(
nlohmann
::
json
&
config
)
:
Configurable
(
config
),
do_reset_
(
false
),
m_frameCount
(
0
)
{
_initCUDA
();
// Allocates voxel structure on GPU
// Allocates voxel structure on GPU
_create
(
_parametersFromConfig
());
_create
(
_parametersFromConfig
());
...
@@ -62,6 +67,30 @@ SceneRep::~SceneRep() {
...
@@ -62,6 +67,30 @@ SceneRep::~SceneRep() {
cudaStreamDestroy
(
integ_stream_
);
cudaStreamDestroy
(
integ_stream_
);
}
}
bool
SceneRep
::
_initCUDA
()
{
// Do an initial CUDA check
int
cuda_device_count
=
0
;
cudaSafeCall
(
cudaGetDeviceCount
(
&
cuda_device_count
));
CHECK_GE
(
cuda_device_count
,
1
)
<<
"No CUDA devices found"
;
LOG
(
INFO
)
<<
"CUDA Devices ("
<<
cuda_device_count
<<
"):"
;
vector
<
cudaDeviceProp
>
properties
(
cuda_device_count
);
for
(
int
i
=
0
;
i
<
cuda_device_count
;
i
++
)
{
cudaSafeCall
(
cudaGetDeviceProperties
(
&
properties
[
i
],
i
));
LOG
(
INFO
)
<<
" - "
<<
properties
[
i
].
name
;
}
int
desired_device
=
value
(
"cudaDevice"
,
0
);
cuda_device_
=
(
desired_device
<
cuda_device_count
)
?
desired_device
:
cuda_device_count
-
1
;
cudaSafeCall
(
cudaSetDevice
(
cuda_device_
));
// TODO(Nick) Check memory is sufficient
// TODO(Nick) Find out what our compute capability should be.
return
true
;
}
void
SceneRep
::
addSource
(
ftl
::
rgbd
::
Source
*
src
)
{
void
SceneRep
::
addSource
(
ftl
::
rgbd
::
Source
*
src
)
{
auto
&
cam
=
cameras_
.
emplace_back
();
auto
&
cam
=
cameras_
.
emplace_back
();
cam
.
source
=
src
;
cam
.
source
=
src
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment