Skip to content

Commit

Permalink
[GPUPS]Fix psgpuwrapper initialization (#44468)
Browse files Browse the repository at this point in the history
* Update ps_gpu_wrapper.h

* Update ps_gpu_wrapper.h

* Update ps_gpu_wrapper.cc
  • Loading branch information
zmxdream authored Jul 20, 2022
1 parent c99c70c commit 99bf700
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions paddle/fluid/framework/fleet/ps_gpu_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ int AfsWrapper::mv(const std::string& old_path, const std::string& dest_path) {

std::shared_ptr<PSGPUWrapper> PSGPUWrapper::s_instance_ = NULL;
bool PSGPUWrapper::is_initialized_ = false;
std::mutex PSGPUWrapper::ins_mutex;
#ifdef PADDLE_WITH_PSLIB
void PSGPUWrapper::InitAfsApi(const std::string& fs_name,
const std::string& fs_user,
Expand Down
9 changes: 7 additions & 2 deletions paddle/fluid/framework/fleet/ps_gpu_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License. */
#include <ctime>
#include <map>
#include <memory>
#include <mutex>
#include <random>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -429,8 +430,11 @@ class PSGPUWrapper {

// PSGPUWrapper singleton
static std::shared_ptr<PSGPUWrapper> GetInstance() {
if (NULL == s_instance_) {
s_instance_.reset(new paddle::framework::PSGPUWrapper());
{
std::lock_guard<std::mutex> lk(ins_mutex);
if (NULL == s_instance_) {
s_instance_.reset(new paddle::framework::PSGPUWrapper());
}
}
return s_instance_;
}
Expand Down Expand Up @@ -537,6 +541,7 @@ class PSGPUWrapper {

private:
static std::shared_ptr<PSGPUWrapper> s_instance_;
static std::mutex ins_mutex;
Dataset* dataset_;
#ifdef PADDLE_WITH_PSLIB
paddle::ps::AfsApiWrapper afs_handler_;
Expand Down

0 comments on commit 99bf700

Please sign in to comment.