Skip to content

Commit

Permalink
Merge pull request #9 from qingshui/paddlebox
Browse files Browse the repository at this point in the history
add cgpu and file parser block bug fix
  • Loading branch information
qingshui authored Jul 2, 2021
2 parents 30b445d + f7bd5f0 commit e49656a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
32 changes: 16 additions & 16 deletions paddle/fluid/framework/data_feed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2815,19 +2815,17 @@ void SlotPaddleBoxDataFeed::LoadIntoMemoryByFile(void) {
timeline.Start();

int lines = 0;
bool is_error = false;
bool is_ok = true;
do {
if (BoxWrapper::GetInstance()->UseAfsApi() && pipe_command_.empty()) {
while (reader->open(filename) < 0) {
sleep(1);
}
if (!parser->ParseFileInstance(
[this, reader](char* buf, int len) {
return reader->read(buf, len);
},
pull_record_func, lines)) {
is_error = true;
}
is_ok = parser->ParseFileInstance(
[this, reader](char* buf, int len) {
return reader->read(buf, len);
},
pull_record_func, lines);
reader->close();
} else {
if (BoxWrapper::GetInstance()->UseAfsApi()) {
Expand All @@ -2839,15 +2837,17 @@ void SlotPaddleBoxDataFeed::LoadIntoMemoryByFile(void) {
}
CHECK(this->fp_ != nullptr);
__fsetlocking(&*(this->fp_), FSETLOCKING_BYCALLER);
if (!parser->ParseFileInstance(
[this](char* buf, int len) {
return fread(buf, sizeof(char), len, this->fp_.get());
},
pull_record_func, lines)) {
is_error = true;
}
is_ok = parser->ParseFileInstance(
[this](char* buf, int len) {
return fread(buf, sizeof(char), len, this->fp_.get());
},
pull_record_func, lines);
}
if (!is_ok) {
LOG(WARNING) << "parser error, filename=" << filename
<< ", lines=" << lines;
}
} while (is_error);
} while (!is_ok);
timeline.Pause();
VLOG(3) << "LoadIntoMemoryByLib() read all file, file=" << filename
<< ", cost time=" << timeline.ElapsedSec()
Expand Down
12 changes: 12 additions & 0 deletions paddle/fluid/platform/gpu_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License. */

#include "gflags/gflags.h"
#include "paddle/fluid/platform/cuda_device_guard.h"
#include "paddle/fluid/platform/dynload/cuda_driver.h"
#include "paddle/fluid/platform/dynload/cudnn.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/lock_guard_ptr.h"
Expand Down Expand Up @@ -488,5 +489,16 @@ bool IsCudaMallocRecorded(int dev_id) {
return RecordedCudaMallocHelper::Instance(dev_id)->NeedRecord();
}

//! cgpu acquire
bool CGPUMemBfcTimeSharingAcquire(void) {
int acquire = -1001;
return platform::dynload::cuDriverGetVersion(&acquire) == CUDA_SUCCESS;
}
//! cgpu release
bool CGPUMemBfcTimeSharingRelease(void) {
int release = -1002;
return platform::dynload::cuDriverGetVersion(&release) == CUDA_SUCCESS;
}

} // namespace platform
} // namespace paddle
4 changes: 4 additions & 0 deletions paddle/fluid/platform/gpu_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ bool RecordedCudaMemGetInfo(size_t *avail, size_t *total, size_t *actual_avail,
uint64_t RecordedCudaMallocSize(int dev_id);

bool IsCudaMallocRecorded(int dev_id);
//! cgpu acquire
bool CGPUMemBfcTimeSharingAcquire(void);
//! cgpu release
bool CGPUMemBfcTimeSharingRelease(void);

} // namespace platform
} // namespace paddle
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/pybind/pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ PYBIND11_MODULE(core_noavx, m) {

#ifdef PADDLE_WITH_CUDA
m.def("cudnn_version", &platform::CudnnVersion);
m.def("cgpu_mem_acquire", &platform::CGPUMemBfcTimeSharingAcquire);
m.def("cgpu_mem_release", &platform::CGPUMemBfcTimeSharingRelease);
#endif

m.def("from_dlpack", [](py::capsule *dltensor) {
Expand Down

0 comments on commit e49656a

Please sign in to comment.