Debug Tensorflow PS的数据传输

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

内容简介:在分布式训练中,有时会碰到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名称,大小都可以看到了。


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

查看所有标签

猜你喜欢:

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

You Can Program in C++

You Can Program in C++

Francis Glassborow / John Wiley & Sons / 2006-7 / 406.80元

An interactive and fun way to learn C++, one of the most popular high-level programming languages for graphic applications This unique, hands-on approach to learning C++ makes t......一起来看看 《You Can Program in C++》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

html转js在线工具
html转js在线工具

html转js在线工具