Debug Tensorflow PS的数据传输

栏目: 数据库 · 发布时间: 7年前

内容简介:在分布式训练中,有时会碰到PS传输数据量很大的情况。这时候,可以在代码中加log来帮助找出哪个tensor消耗比较大。在grpc_remote_worker.cc中添加如下代码:就可以输出日志:

在分布式训练中,有时会碰到PS传输数据量很大的情况。这时候,可以在代码中加log来帮助找出哪个tensor消耗比较大。

在grpc_remote_worker.cc中添加如下代码:

void RecvTensorAsync(CallOptions* call_opts, const RecvTensorRequest* request,
                       TensorResponse* response, StatusCallback done) override {
    VLOG(1) << "RecvTensorAsync req: " << request->DebugString();
    int64 start_usec = Env::Default()->NowMicros();
    // Type-specialized logging for this method.
    bool logging_active = logger_->LoggingActive() || VLOG_IS_ON(2) || true;
    StatusCallback wrapper_done;
    const StatusCallback* cb_to_use;
    if (!logging_active) {
      cb_to_use = &done;  // No additional work to do, so just use done directly
    } else {
      wrapper_done = [this, request, response, done, start_usec](Status s) {
        int64 bytes = response->tensor().TotalBytes();
        const string& key = request->rendezvous_key();
        std::vector<string> key_parts = str_util::Split(key, ';');
        LOG(INFO) << "recv tensor name: " << key_parts[3] << " src: " << key_parts[0] << " dest: " << key_parts[2] << " bytes: " << bytes;

就可以输出日志:

recv tensor name: xx src: /job:ps/replica:0/task:0/device:CPU:0 dest: /job:worker/replica:0/task:0/device:CPU:0 bytes: 20889600

这样从src传输到dest, tensor名称,大小都可以看到了。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Hello World

Hello World

Hannah Fry / W. W. Norton Company / 2018-9 / GBP 17.99

A look inside the algorithms that are shaping our lives and the dilemmas they bring with them. If you were accused of a crime, who would you rather decide your sentence—a mathematically consistent ......一起来看看 《Hello World》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具