未验证 提交 99bf7007 编写于 作者: Z zmxdream 提交者: GitHub

[GPUPS]Fix psgpuwrapper initialization (#44468)

* Update ps_gpu_wrapper.h

* Update ps_gpu_wrapper.h

* Update ps_gpu_wrapper.cc
上级 c99c70cb
......@@ -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,
......
......@@ -20,6 +20,7 @@ limitations under the License. */
#include <ctime>
#include <map>
#include <memory>
#include <mutex>
#include <random>
#include <string>
#include <unordered_map>
......@@ -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_;
}
......@@ -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_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册