Browse Source

!21433 Recover the environment variable MS_DEBUGGER_HOST

Merge pull request !21433 from maning202007/master
tags/v1.5.0-rc1
i-robot Gitee 4 years ago
parent
commit
6b635cc718
4 changed files with 34 additions and 6 deletions
  1. +2
    -2
      mindspore/ccsrc/debug/data_dump/dump_json_parser.cc
  2. +28
    -3
      mindspore/ccsrc/debug/debugger/debugger.cc
  3. +3
    -0
      mindspore/ccsrc/debug/debugger/debugger.h
  4. +1
    -1
      mindspore/ccsrc/debug/debugger/offline_debug/dbg_services.cc

+ 2
- 2
mindspore/ccsrc/debug/data_dump/dump_json_parser.cc View File

@@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2020-2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -184,7 +184,7 @@ void DumpJsonParser::CopyMSCfgJsonToDir(uint32_t rank_id) {
auto context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context);
ms_info["device_target"] = context->get_param<std::string>(MS_CTX_DEVICE_TARGET);
ms_info["ms_version"] = "1.3.0";
ms_info["ms_version"] = "1.4.0";
const std::string file_path = realpath.value();
ChangeFileMode(file_path, S_IWUSR);
std::ofstream json_create(file_path);


+ 28
- 3
mindspore/ccsrc/debug/debugger/debugger.cc View File

@@ -113,7 +113,7 @@ void Debugger::Init(const uint32_t device_id, const std::string device_target) {
device_id_ = device_id;
MS_LOG(INFO) << "Debugger got device_target: " << device_target;
device_target_ = device_target;
version_ = "1.3.0";
version_ = "1.4.0";
}

bool IsTypeDebuggerSupported(TypeId type) {
@@ -147,8 +147,22 @@ void Debugger::EnableDebugger() {
}

if (debugger_enabled_) {
std::string host = "localhost";

// configure grpc host
std::string env_host_str = common::GetEnv("MS_DEBUGGER_HOST");
std::string host;
if (!env_host_str.empty()) {
if (CheckIp(env_host_str)) {
MS_LOG(INFO) << "Getenv MS_DEBUGGER_HOST: " << env_host_str;
host = env_host_str;
} else {
debugger_enabled_ = false;
MS_EXCEPTION(ValueError) << "Environment variable MS_DEBUGGER_HOST isn't a valid IP address. "
"Please set environment variable MS_DEBUGGER_HOST=x.x.x.x to a valid IP";
}
} else {
MS_LOG(INFO) << "Environment variable MS_DEBUGGER_HOST doesn't exist. Using default debugger host: localhost";
host = "localhost";
}
// configure grpc port
std::string env_port_str = common::GetEnv("MS_DEBUGGER_PORT");
std::string port;
@@ -1120,6 +1134,17 @@ bool Debugger::CheckPort(const std::string &port) const {
return true;
}

bool Debugger::CheckIp(const std::string &host) const {
std::regex reg_ip(
"(25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])"
"[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"
"[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"
"[.](25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])");
std::smatch smat;
std::string host_str = host;
return std::regex_match(host_str, smat, reg_ip);
}

uint32_t Debugger::GetFirstRunGraphId() const { return rungraph_id_list_.front(); }

void Debugger::LoadSingleAnfnode(const AnfNodePtr &anf_node, const size_t output_index) {


+ 3
- 0
mindspore/ccsrc/debug/debugger/debugger.h View File

@@ -235,6 +235,9 @@ class Debugger : public std::enable_shared_from_this<Debugger> {
// Check if the port is valid
bool CheckPort(const std::string &port) const;

// Check if the IP is valid
bool CheckIp(const std::string &host) const;

void LoadSingleAnfnode(const AnfNodePtr &anf_node, const size_t output_index);

// class members


+ 1
- 1
mindspore/ccsrc/debug/debugger/offline_debug/dbg_services.cc View File

@@ -48,7 +48,7 @@ DbgServices::~DbgServices() {

std::string DbgServices::GetVersion() {
MS_LOG(INFO) << "get version is called";
return "1.3.0";
return "1.4.0";
}

int32_t DbgServices::Initialize(std::string net_name, std::string dump_folder_path, bool is_sync_mode) {


Loading…
Cancel
Save