Skip to content
Snippets Groups Projects
Commit 660f603b authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Set cuda device to second device

parent a5ebfe39
No related branches found
No related tags found
2 merge requests!347Feature buckets experiment,!300Implement experimental SGM algorithms
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "middlebury.hpp" #include "middlebury.hpp"
#include "algorithms.hpp" #include "algorithms.hpp"
#include <cuda_runtime.h>
#include "../../components/common/cpp/include/ftl/config.h" #include "../../components/common/cpp/include/ftl/config.h"
struct Result { struct Result {
...@@ -141,6 +143,10 @@ void main_default(const std::vector<std::string> &paths, ...@@ -141,6 +143,10 @@ void main_default(const std::vector<std::string> &paths,
std::vector<std::pair<MiddleburyData, std::map<std::string, Result>>> results; std::vector<std::pair<MiddleburyData, std::map<std::string, Result>>> results;
int devices=0;
cudaGetDeviceCount(&devices);
cudaSetDevice(devices-1);
for (const auto &dir : paths) { for (const auto &dir : paths) {
auto input = load_input(dir); auto input = load_input(dir);
std::map<std::string, Result> result; std::map<std::string, Result> result;
......
...@@ -21,7 +21,7 @@ StereoBRefCensusSgm::StereoBRefCensusSgm() : impl_(nullptr) { ...@@ -21,7 +21,7 @@ StereoBRefCensusSgm::StereoBRefCensusSgm() : impl_(nullptr) {
void StereoBRefCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) { void StereoBRefCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) {
cudaSetDevice(0); //cudaSetDevice(0);
if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) { if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) {
delete impl_; impl_ = nullptr; delete impl_; impl_ = nullptr;
......
...@@ -16,7 +16,7 @@ StereoCensusSgm::StereoCensusSgm() : impl_(nullptr) { ...@@ -16,7 +16,7 @@ StereoCensusSgm::StereoCensusSgm() : impl_(nullptr) {
void StereoCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) { void StereoCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) {
cudaSetDevice(0); //cudaSetDevice(0);
if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) { if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) {
delete impl_; impl_ = nullptr; delete impl_; impl_ = nullptr;
......
...@@ -70,7 +70,7 @@ StereoHierCensusSgm::StereoHierCensusSgm() : impl_(nullptr) { ...@@ -70,7 +70,7 @@ StereoHierCensusSgm::StereoHierCensusSgm() : impl_(nullptr) {
void StereoHierCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) { void StereoHierCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) {
cudaSetDevice(0); //cudaSetDevice(0);
if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) { if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) {
delete impl_; impl_ = nullptr; delete impl_; impl_ = nullptr;
......
...@@ -20,7 +20,7 @@ StereoMeanCensusSgm::StereoMeanCensusSgm() : impl_(nullptr) { ...@@ -20,7 +20,7 @@ StereoMeanCensusSgm::StereoMeanCensusSgm() : impl_(nullptr) {
void StereoMeanCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) { void StereoMeanCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) {
cudaSetDevice(0); //cudaSetDevice(0);
if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) { if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) {
delete impl_; impl_ = nullptr; delete impl_; impl_ = nullptr;
......
...@@ -16,7 +16,7 @@ StereoStableSgm::StereoStableSgm() : impl_(nullptr) { ...@@ -16,7 +16,7 @@ StereoStableSgm::StereoStableSgm() : impl_(nullptr) {
void StereoStableSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) { void StereoStableSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) {
cudaSetDevice(0); //cudaSetDevice(0);
if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) { if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) {
delete impl_; impl_ = nullptr; delete impl_; impl_ = nullptr;
......
...@@ -16,7 +16,7 @@ StereoTCensusSgm::StereoTCensusSgm() : impl_(nullptr) { ...@@ -16,7 +16,7 @@ StereoTCensusSgm::StereoTCensusSgm() : impl_(nullptr) {
void StereoTCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) { void StereoTCensusSgm::compute(cv::InputArray l, cv::InputArray r, cv::OutputArray disparity) {
cudaSetDevice(0); //cudaSetDevice(0);
if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) { if (l.rows() != impl_->cost.height() || r.cols() != impl_->cost.width()) {
delete impl_; impl_ = nullptr; delete impl_; impl_ = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment