<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10</li>
<li>TensorFlow installed from (source or binary): binary</li>
<li>TensorFlow version (use command below): 2.0.0-beta0</li>
<li>Python version: 3.6.8</li>
<li>CUDA/cuDNN version: 10.0</li>
<li>GPU model and memory: GeForce GTX 750 Ti</li>
</ul>
<p dir="auto"><strong>Describe the current behavior</strong><br>
When using Reshape layer of Keras and -1 is used to infer the shape, the output shape is incorrect.</p>
<p dir="auto"><strong>Describe the expected behavior</strong></p>
<p dir="auto"><strong>Code to reproduce the issue</strong><br>
<code class="notranslate">from tensorflow.python.keras.layers import Input, Lambda, Conv2D, Reshape, TimeDistributed</code><br>
<code class="notranslate">from tensorflow.python.keras.models import *</code><br>
<code class="notranslate">import tensorflow.keras as keras</code></p>
<p dir="auto"><code class="notranslate">a = Input(shape=(12,), dtype = 'int32')</code><br>
<code class="notranslate"># a.shape == (None, 12)</code><br>
<code class="notranslate">d = Reshape((-1, 2, 2))(a)</code><br>
<code class="notranslate"># actual result： d.shape == (None, None, 2, 2)</code><br>
<code class="notranslate"># expected result： d.shape == (None, 3, 2, 2)</code></p>
<p dir="auto">Hello tensorflow team,</p>
<p dir="auto">I have been starting to use your tensorflow debugger but have run into the issue that when I try and use it on a multi-gpu model I get <code class="notranslate">ValueError: Duplicate node name: 'n/_0'</code>.</p>
<p dir="auto">Inspecting things closer, I saw that the issue originated from the run_metadata, whose partition graphs have many _Send and _HostRecv ops with names like 'n/_0'.  These ops are replicated with identical names across my towers which is what is causing the issue.</p>
<p dir="auto">Looking through the tensorflow code, I believe I tracked where this name is set down to <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/graph/graph_partition.cc#L195">graph_partition.cc:195</a> where the edge's source name is used as the prefix 'n'.  Unfortunately, I have not been able to figure out why the source's name is only 'n', but that seems to be the root of the issue here.</p>
<p dir="auto">I should add that I never set any tensor name to 'n' anywhere in my own code.  Plus, I see certain tests in your codebase rely on names such as 'n/_0' which indicates to me the name is being set somewhere internally in the tensorflow code.</p>
<p dir="auto">Any help you can provide would be much appreciated!</p>
<h3 dir="auto">What related GitHub issues or StackOverflow threads have you found by searching the web for your problem?</h3>
<p dir="auto">I didn't find any related issues.</p>
<h3 dir="auto">Environment info</h3>
<p dir="auto">Operating System: Ubuntu 14.04.5 LTS (running in a <a href="http://singularity.lbl.gov" rel="nofollow">singularity</a> container on a CentOS 6.7 host).</p>
<p dir="auto">Installed version of CUDA and cuDNN:<br>
I am using CUDA 8.0 with NVIDIA driver 367.48, and cuDNN v5.1 .<br>
(please attach the output of <code class="notranslate">ls -l /path/to/cuda/lib/libcud*</code>):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="libOpenCL.so
libOpenCL.so.1
libOpenCL.so.1.0
libOpenCL.so.1.0.0
libcublas.so
libcublas.so.8.0
libcublas.so.8.0.45
libcublas_device.a
libcublas_static.a
libcudadevrt.a
libcudart.so
libcudart.so.8.0
libcudart.so.8.0.44
libcudart_static.a
libcudnn.so
libcudnn.so.5
libcudnn.so.5.1.5
libcudnn_static.a
libcufft.so
libcufft.so.8.0
libcufft.so.8.0.44
libcufft_static.a
libcufftw.so
libcufftw.so.8.0
libcufftw.so.8.0.44
libcufftw_static.a
libcuinj64.so
libcuinj64.so.8.0
libcuinj64.so.8.0.44
libculibos.a
libcurand.so
libcurand.so.8.0
libcurand.so.8.0.44
libcurand_static.a
libcusolver.so
libcusolver.so.8.0
libcusolver.so.8.0.44
libcusolver_static.a
libcusparse.so
libcusparse.so.8.0
libcusparse.so.8.0.44
libcusparse_static.a
libnppc.so
libnppc.so.8.0
libnppc.so.8.0.44
libnppc_static.a
libnppi.so
libnppi.so.8.0
libnppi.so.8.0.44
libnppi_static.a
libnppial.so
libnppial.so.8.0
libnppial.so.8.0.44
libnppicc.so
libnppicc.so.8.0
libnppicc.so.8.0.44
libnppicom.so
libnppicom.so.8.0
libnppicom.so.8.0.44
libnppidei.so
libnppidei.so.8.0
libnppidei.so.8.0.44
libnppif.so
libnppif.so.8.0
libnppif.so.8.0.44
libnppig.so
libnppig.so.8.0
libnppig.so.8.0.44
libnppim.so
libnppim.so.8.0
libnppim.so.8.0.44
libnppist.so
libnppist.so.8.0
libnppist.so.8.0.44
libnppisu.so
libnppisu.so.8.0
libnppisu.so.8.0.44
libnppitc.so
libnppitc.so.8.0
libnppitc.so.8.0.44
libnpps.so
libnpps.so.8.0
libnpps.so.8.0.44
libnpps_static.a
libnvToolsExt.so
libnvToolsExt.so.1
libnvToolsExt.so.1.0.0
libnvblas.so
libnvblas.so.8.0
libnvblas.so.8.0.44
libnvgraph.so
libnvgraph.so.8.0
libnvgraph.so.8.0.44
libnvgraph_static.a
libnvrtc-builtins.so
libnvrtc-builtins.so.8.0
libnvrtc-builtins.so.8.0.44
libnvrtc.so
libnvrtc.so.8.0
libnvrtc.so.8.0.44
stubs"><pre class="notranslate"><code class="notranslate">libOpenCL.so
libOpenCL.so.1
libOpenCL.so.1.0
libOpenCL.so.1.0.0
libcublas.so
libcublas.so.8.0
libcublas.so.8.0.45
libcublas_device.a
libcublas_static.a
libcudadevrt.a
libcudart.so
libcudart.so.8.0
libcudart.so.8.0.44
libcudart_static.a
libcudnn.so
libcudnn.so.5
libcudnn.so.5.1.5
libcudnn_static.a
libcufft.so
libcufft.so.8.0
libcufft.so.8.0.44
libcufft_static.a
libcufftw.so
libcufftw.so.8.0
libcufftw.so.8.0.44
libcufftw_static.a
libcuinj64.so
libcuinj64.so.8.0
libcuinj64.so.8.0.44
libculibos.a
libcurand.so
libcurand.so.8.0
libcurand.so.8.0.44
libcurand_static.a
libcusolver.so
libcusolver.so.8.0
libcusolver.so.8.0.44
libcusolver_static.a
libcusparse.so
libcusparse.so.8.0
libcusparse.so.8.0.44
libcusparse_static.a
libnppc.so
libnppc.so.8.0
libnppc.so.8.0.44
libnppc_static.a
libnppi.so
libnppi.so.8.0
libnppi.so.8.0.44
libnppi_static.a
libnppial.so
libnppial.so.8.0
libnppial.so.8.0.44
libnppicc.so
libnppicc.so.8.0
libnppicc.so.8.0.44
libnppicom.so
libnppicom.so.8.0
libnppicom.so.8.0.44
libnppidei.so
libnppidei.so.8.0
libnppidei.so.8.0.44
libnppif.so
libnppif.so.8.0
libnppif.so.8.0.44
libnppig.so
libnppig.so.8.0
libnppig.so.8.0.44
libnppim.so
libnppim.so.8.0
libnppim.so.8.0.44
libnppist.so
libnppist.so.8.0
libnppist.so.8.0.44
libnppisu.so
libnppisu.so.8.0
libnppisu.so.8.0.44
libnppitc.so
libnppitc.so.8.0
libnppitc.so.8.0.44
libnpps.so
libnpps.so.8.0
libnpps.so.8.0.44
libnpps_static.a
libnvToolsExt.so
libnvToolsExt.so.1
libnvToolsExt.so.1.0.0
libnvblas.so
libnvblas.so.8.0
libnvblas.so.8.0.44
libnvgraph.so
libnvgraph.so.8.0
libnvgraph.so.8.0.44
libnvgraph_static.a
libnvrtc-builtins.so
libnvrtc-builtins.so.8.0
libnvrtc-builtins.so.8.0.44
libnvrtc.so
libnvrtc.so.8.0
libnvrtc.so.8.0.44
stubs
</code></pre></div>
<ol dir="auto">
<li>A link to the pip package you installed:<br>
I installed tensorflow using <code class="notranslate">pip install tensorflow-gpu==0.12.1</code></li>
<li>The output from <code class="notranslate">python -c "import tensorflow; print(tensorflow.__version__)"</code>.</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
0.12.1 "><pre class="notranslate"><code class="notranslate">I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
0.12.1 
</code></pre></div>
<h3 dir="auto">What other attempted solutions have you tried?</h3>
<p dir="auto">The single GPU case works fine.</p>
<h3 dir="auto">Logs or other output that would be helpful</h3>
<p dir="auto">Here is the dump of some of the problematic nodes.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="node {
  name: &quot;n/_0&quot;
  op: &quot;_Send&quot;
  input: &quot;__copy_TOWER0/Const_0&quot;
  attr {
    key: &quot;T&quot;
    value {
      type: DT_FLOAT
    }
  }
  attr {
    key: &quot;client_terminated&quot;
    value {
      b: false
    }
  }
  attr {
    key: &quot;recv_device&quot;
    value {
      s: &quot;/job:localhost/replica:0/task:0/gpu:0&quot;
    }
  }
  attr {
    key: &quot;send_device&quot;
    value {
      s: &quot;/job:localhost/replica:0/task:0/gpu:0&quot;
    }
  }
  attr {
    key: &quot;send_device_incarnation&quot;
    value {
      i: 0
    }
  }
  attr {
    key: &quot;tensor_name&quot;
    value {
      s: &quot;edge_545___copy_TOWER0/Const_0&quot;
    }
  }
}
node {
  name: &quot;n/_1&quot;
  op: &quot;_HostRecv&quot;
  input: &quot;^n/_0&quot;
  attr {
    key: &quot;client_terminated&quot;
    value {
      b: false
    }
  }
  attr {
    key: &quot;recv_device&quot;
    value {
      s: &quot;/job:localhost/replica:0/task:0/gpu:0&quot;
    }
  }
  attr {
    key: &quot;send_device&quot;
    value {
      s: &quot;/job:localhost/replica:0/task:0/gpu:0&quot;
    }
  }
  attr {
    key: &quot;send_device_incarnation&quot;
    value {
      i: 0
    }
  }
  attr {
    key: &quot;tensor_name&quot;
    value {
      s: &quot;edge_545___copy_TOWER0/Const_0&quot;
    }
  }
  attr {
    key: &quot;tensor_type&quot;
    value {
      type: DT_FLOAT
    }
  }
}
node {
  name: &quot;n/_2&quot;
  op: &quot;_Send&quot;
  input: &quot;__copy_TOWER0/Sub_0&quot;
  attr {
    key: &quot;T&quot;
    value {
      type: DT_FLOAT
    }
  }
  attr {
    key: &quot;client_terminated&quot;
    value {
      b: false
    }
  }
  attr {
    key: &quot;recv_device&quot;
    value {
      s: &quot;/job:localhost/replica:0/task:0/gpu:0&quot;
    }
  }
  attr {
    key: &quot;send_device&quot;
    value {
      s: &quot;/job:localhost/replica:0/task:0/gpu:0&quot;
    }
  }
  attr {
    key: &quot;send_device_incarnation&quot;
    value {
      i: 0
    }
  }
  attr {
    key: &quot;tensor_name&quot;
    value {
      s: &quot;edge_551___copy_TOWER0/Sub_0&quot;
    }
  }
}
"><pre class="notranslate"><code class="notranslate">node {
  name: "n/_0"
  op: "_Send"
  input: "__copy_TOWER0/Const_0"
  attr {
    key: "T"
    value {
      type: DT_FLOAT
    }
  }
  attr {
    key: "client_terminated"
    value {
      b: false
    }
  }
  attr {
    key: "recv_device"
    value {
      s: "/job:localhost/replica:0/task:0/gpu:0"
    }
  }
  attr {
    key: "send_device"
    value {
      s: "/job:localhost/replica:0/task:0/gpu:0"
    }
  }
  attr {
    key: "send_device_incarnation"
    value {
      i: 0
    }
  }
  attr {
    key: "tensor_name"
    value {
      s: "edge_545___copy_TOWER0/Const_0"
    }
  }
}
node {
  name: "n/_1"
  op: "_HostRecv"
  input: "^n/_0"
  attr {
    key: "client_terminated"
    value {
      b: false
    }
  }
  attr {
    key: "recv_device"
    value {
      s: "/job:localhost/replica:0/task:0/gpu:0"
    }
  }
  attr {
    key: "send_device"
    value {
      s: "/job:localhost/replica:0/task:0/gpu:0"
    }
  }
  attr {
    key: "send_device_incarnation"
    value {
      i: 0
    }
  }
  attr {
    key: "tensor_name"
    value {
      s: "edge_545___copy_TOWER0/Const_0"
    }
  }
  attr {
    key: "tensor_type"
    value {
      type: DT_FLOAT
    }
  }
}
node {
  name: "n/_2"
  op: "_Send"
  input: "__copy_TOWER0/Sub_0"
  attr {
    key: "T"
    value {
      type: DT_FLOAT
    }
  }
  attr {
    key: "client_terminated"
    value {
      b: false
    }
  }
  attr {
    key: "recv_device"
    value {
      s: "/job:localhost/replica:0/task:0/gpu:0"
    }
  }
  attr {
    key: "send_device"
    value {
      s: "/job:localhost/replica:0/task:0/gpu:0"
    }
  }
  attr {
    key: "send_device_incarnation"
    value {
      i: 0
    }
  }
  attr {
    key: "tensor_name"
    value {
      s: "edge_551___copy_TOWER0/Sub_0"
    }
  }
}

</code></pre></div>
<p dir="auto">End of backtrace at crash point</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/framework.py(419)run()                 
-&gt; run_end_resp = self.on_run_end(run_end_req)                                                                              
  /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/local_cli_wrapper.py(262)on_run_end()  
-&gt; self._dump_root, partition_graphs=partition_graphs)                                                                      
  /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/debug_data.py(407)__init__()                    
-&gt; self._load_partition_graphs(partition_graphs)                                                                            
&gt; /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/debug_data.py(493)_load_partition_graphs()      
-&gt; raise ValueError(&quot;Duplicate node name: '%s'&quot; % node.name)                                                                "><pre class="notranslate"><code class="notranslate">  /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/framework.py(419)run()                 
-&gt; run_end_resp = self.on_run_end(run_end_req)                                                                              
  /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/local_cli_wrapper.py(262)on_run_end()  
-&gt; self._dump_root, partition_graphs=partition_graphs)                                                                      
  /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/debug_data.py(407)__init__()                    
-&gt; self._load_partition_graphs(partition_graphs)                                                                            
&gt; /home/raphtown/.local/lib/python2.7/site-packages/tensorflow/python/debug/debug_data.py(493)_load_partition_graphs()      
-&gt; raise ValueError("Duplicate node name: '%s'" % node.name)                                                                
</code></pre></div>