| 9 | } |
| 10 | |
| 11 | void Configure::ReadConf(std::string path) { |
| 12 | using namespace boost; |
| 13 | using namespace boost::property_tree; |
| 14 | |
| 15 | ptree root; |
| 16 | read_json<ptree>(path, root); |
| 17 | |
| 18 | serverIp_ = root.get<string>("ServerConfig.serverIp_"); |
| 19 | serverPort_ = root.get<uint16_t>("ServerConfig.serverPort_"); |
| 20 | |
| 21 | dpcIp_ = root.get<string>("DispatcherConfig.dpcIp_"); |
| 22 | dpcPort_ = root.get<uint16_t>("DispatcherConfig.dpcPort_"); |
| 23 | |
| 24 | monIp_ = root.get<string>("MonitorConfig.monitorIp_"); |
| 25 | monPort_ = root.get<uint16_t>("MonitorConfig.monitorPort_"); |
| 26 | |
| 27 | if (isClient_) { |
| 28 | const char* envClientID = std::getenv("FLEXGV_CLIENT_ID"); |
| 29 | const char* envPriority = std::getenv("FLEXGV_PRIORITY"); |
| 30 | const char* envReqGPUnum = std::getenv("FLEXGV_REQ_NUM"); |
| 31 | const char* envModel = std::getenv("FLEXGV_MODEL"); |
| 32 | const char* envBatchSize = std::getenv("FLEXGV_BATCH_SIZE"); |
| 33 | clientID_ = envClientID ? std::stoull(envClientID) : root.get<uint64_t>("ClientConfig.clientID_"); |
| 34 | reqGPUnum_ = root.get<size_t>("ClientConfig.requestGPUnum_"); |
| 35 | priority_ = envPriority ? std::stoull(envPriority) : root.get<size_t>("ClientConfig.priority_"); |
| 36 | proxyIp_ = root.get<string>("ClientConfig.proxyIp_"); |
| 37 | proxyPort_ = root.get<uint16_t>("ClientConfig.proxyPort_"); |
| 38 | DDPreqGPUnum_ = envReqGPUnum ? std::stoull(envReqGPUnum) : 1; |
| 39 | model_ = envModel ? envModel : "resnet18"; |
| 40 | batchSize_ = envBatchSize ? std::stoull(envBatchSize) : 32; |
| 41 | } |
| 42 | return ; |
| 43 | } |