2020-07-15 19:54:13 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
|
|
#include "e2e_test_base.h"
|
|
|
|
|
|
|
|
|
|
#include <c10d/ProcessGroupGloo.hpp>
|
|
|
|
|
#include <torch/csrc/distributed/rpc/process_group_agent.h>
|
|
|
|
|
#include <torch/csrc/distributed/rpc/request_callback_no_python.h>
|
|
|
|
|
#include <torch/torch.h>
|
|
|
|
|
|
|
|
|
|
namespace torch {
|
|
|
|
|
namespace distributed {
|
|
|
|
|
namespace rpc {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestE2EProcessGroup : public TestE2EBase {
|
|
|
|
|
protected:
|
|
|
|
|
void buildRpcAgent() override {
|
2021-03-18 01:38:15 +00:00
|
|
|
auto options = c10d::ProcessGroupGloo::Options::create();
|
|
|
|
|
options->devices.push_back(
|
2020-07-15 19:54:13 +00:00
|
|
|
::c10d::ProcessGroupGloo::createDeviceForHostname(serverAddress));
|
|
|
|
|
std::chrono::milliseconds rpcTimeout(30000);
|
2021-03-18 01:38:15 +00:00
|
|
|
options->timeout = rpcTimeout;
|
2020-07-15 19:54:13 +00:00
|
|
|
|
|
|
|
|
// Initialize server rpc agent.
|
2020-11-12 15:34:13 +00:00
|
|
|
auto pg = c10::make_intrusive<c10d::ProcessGroupGloo>(
|
|
|
|
|
store, 0, numWorkers, options);
|
2020-07-15 19:54:13 +00:00
|
|
|
|
|
|
|
|
rpcAgent = std::make_shared<ProcessGroupAgent>(
|
2021-03-08 00:46:13 +00:00
|
|
|
store,
|
2020-07-15 19:54:13 +00:00
|
|
|
"worker",
|
|
|
|
|
pg,
|
|
|
|
|
std::max(16U, std::thread::hardware_concurrency()),
|
|
|
|
|
rpcTimeout,
|
|
|
|
|
std::make_unique<RequestCallbackNoPython>());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// End to end training loop test in C++ so that we can run LSAN on this test to
|
|
|
|
|
// catch memory leaks. Enabling LSAN with python multiprocessing has been
|
|
|
|
|
// challenging and we don't have a good solution yet.
|
|
|
|
|
TEST_F(TestE2EProcessGroup, TestTrainingLoop) {
|
|
|
|
|
runTrainingLoop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace rpc
|
|
|
|
|
} // namespace distributed
|
|
|
|
|
} // namespace torch
|