<h3 dir="auto">System information</h3>
<ul dir="auto">
<li>Have I written custom code: no</li>
<li>OS Platform and Distribution: Windows 7, 64-bit</li>
<li>Tensorflow installed from: Anaconda 5.0.1 via pip 9.0.1<br>
(conda create -p C:\temp\tensorflow-gpu; pip install tensorflow-gpu)</li>
<li>Python 3.5.2</li>
<li>TensorFlow 1.5.0</li>
<li>CUDA 9.0</li>
<li>cuDNN 7.0</li>
<li>Bazel: N/A</li>
<li>GPU model and memory: NVIDIA Quadro K620, 2GB</li>
</ul>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">Commands to reproduce:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="conda create -p C:\temp\tensorflow-gpu
activate C:\temp\tensorflow-gpu
pip install tensorflow-gpu
python
&gt; import tensorflow"><pre class="notranslate"><code class="notranslate">conda create -p C:\temp\tensorflow-gpu
activate C:\temp\tensorflow-gpu
pip install tensorflow-gpu
python
&gt; import tensorflow
</code></pre></div>
<p dir="auto">After installing all dependencies, tensorflow fails to import. Exactly the same error occurs with other Tf/CUDA/cuDNN versions (tried TF 1.4.0 + CUDA 7.0 + cuDNN 5.1 and TF 1.4.0 + CUDA 8.0 + cuDNN 6.0).</p>
<p dir="auto">While searching, I discovered a similar bug, but it contains a different error message: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="192386484" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/5949" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/5949/hovercard" href="https://github.com/tensorflow/tensorflow/issues/5949">#5949</a></p>
<h3 dir="auto">Source code / logs</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(C:\temp\tensorflow-gpu) C:\temp&gt;python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  5 2016, 11:41:13) [MSC v
.1900 64 bit (AMD64)] on win32
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import tensorflow
Traceback (most recent call last):
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py&quot;, line 18, in swig_import_helper
    return importlib.import_module(mname)
  File &quot;C:\temp\tensorflow-gpu\lib\importlib\__init__.py&quot;, line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 986, in _gcd_import
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 969, in _find_and_load
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 958, in _find_and_load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 666, in _load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 577, in module_from_spec
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 906, in create_module
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 222, in _call_with_frames_removed
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow.py&quot;, line 58, in &lt;module&gt;
    from tensorflow.python.pywrap_tensorflow_internal import *
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py&quot;, line 21, in &lt;module&gt;
    _pywrap_tensorflow_internal = swig_import_helper()
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py&quot;, line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File &quot;C:\temp\tensorflow-gpu\lib\importlib\__init__.py&quot;, line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py&quot;, line 2
4, in &lt;module&gt;
    from tensorflow.python import *
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\__init__.py&quot;,
 line 49, in &lt;module&gt;
    from tensorflow.python import pywrap_tensorflow
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow.py&quot;, line 74, in &lt;module&gt;
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py&quot;, line 18, in swig_import_helper
    return importlib.import_module(mname)
  File &quot;C:\temp\tensorflow-gpu\lib\importlib\__init__.py&quot;, line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 986, in _gcd_import
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 969, in _find_and_load
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 958, in _find_and_load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 666, in _load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 577, in module_from_spec
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 906, in create_module
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 222, in _call_with_frames_removed
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow.py&quot;, line 58, in &lt;module&gt;
    from tensorflow.python.pywrap_tensorflow_internal import *
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py&quot;, line 21, in &lt;module&gt;
    _pywrap_tensorflow_internal = swig_import_helper()
  File &quot;C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py&quot;, line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File &quot;C:\temp\tensorflow-gpu\lib\importlib\__init__.py&quot;, line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
&gt;&gt;&gt;"><pre class="notranslate"><code class="notranslate">(C:\temp\tensorflow-gpu) C:\temp&gt;python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  5 2016, 11:41:13) [MSC v
.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import tensorflow
Traceback (most recent call last):
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\temp\tensorflow-gpu\lib\importlib\__init__.py", line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "&lt;frozen importlib._bootstrap&gt;", line 986, in _gcd_import
  File "&lt;frozen importlib._bootstrap&gt;", line 969, in _find_and_load
  File "&lt;frozen importlib._bootstrap&gt;", line 958, in _find_and_load_unlocked
  File "&lt;frozen importlib._bootstrap&gt;", line 666, in _load_unlocked
  File "&lt;frozen importlib._bootstrap&gt;", line 577, in module_from_spec
  File "&lt;frozen importlib._bootstrap_external&gt;", line 906, in create_module
  File "&lt;frozen importlib._bootstrap&gt;", line 222, in _call_with_frames_removed
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow.py", line 58, in &lt;module&gt;
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py", line 21, in &lt;module&gt;
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\temp\tensorflow-gpu\lib\importlib\__init__.py", line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py", line 2
4, in &lt;module&gt;
    from tensorflow.python import *
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\__init__.py",
 line 49, in &lt;module&gt;
    from tensorflow.python import pywrap_tensorflow
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow.py", line 74, in &lt;module&gt;
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\temp\tensorflow-gpu\lib\importlib\__init__.py", line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "&lt;frozen importlib._bootstrap&gt;", line 986, in _gcd_import
  File "&lt;frozen importlib._bootstrap&gt;", line 969, in _find_and_load
  File "&lt;frozen importlib._bootstrap&gt;", line 958, in _find_and_load_unlocked
  File "&lt;frozen importlib._bootstrap&gt;", line 666, in _load_unlocked
  File "&lt;frozen importlib._bootstrap&gt;", line 577, in module_from_spec
  File "&lt;frozen importlib._bootstrap_external&gt;", line 906, in create_module
  File "&lt;frozen importlib._bootstrap&gt;", line 222, in _call_with_frames_removed
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow.py", line 58, in &lt;module&gt;
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py", line 21, in &lt;module&gt;
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\temp\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensor
flow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\temp\tensorflow-gpu\lib\importlib\__init__.py", line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
&gt;&gt;&gt;
</code></pre></div>
<p dir="auto">When doing "import tensorflow", these dlls are loaded:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="23:09:18,4934154	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\python.exe	SUCCESS	Image Base: 0x1ce20000, Image Size: 0xd000
23:09:18,4935443	python.exe	4848	Load Image	C:\Windows\System32\ntdll.dll	SUCCESS	Image Base: 0x77190000, Image Size: 0x1aa000
23:09:18,4940523	python.exe	4848	Load Image	C:\Windows\System32\kernel32.dll	SUCCESS	Image Base: 0x77070000, Image Size: 0x11f000
23:09:18,4942051	python.exe	4848	Load Image	C:\Windows\System32\KernelBase.dll	SUCCESS	Image Base: 0x7fefd010000, Image Size: 0x6a000
23:09:18,4954354	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\python35.dll	SUCCESS	Image Base: 0x60840000, Image Size: 0x3e4000
23:09:18,4962254	python.exe	4848	Load Image	C:\Windows\System32\ws2_32.dll	SUCCESS	Image Base: 0x7fefe860000, Image Size: 0x4d000
23:09:18,4963049	python.exe	4848	Load Image	C:\Windows\System32\msvcrt.dll	SUCCESS	Image Base: 0x7fefec80000, Image Size: 0x9f000
23:09:18,4965005	python.exe	4848	Load Image	C:\Windows\System32\rpcrt4.dll	SUCCESS	Image Base: 0x7fefe560000, Image Size: 0x12d000
23:09:18,4967902	python.exe	4848	Load Image	C:\Windows\System32\nsi.dll	SUCCESS	Image Base: 0x7fefed20000, Image Size: 0x8000
23:09:18,4969281	python.exe	4848	Load Image	C:\Windows\System32\advapi32.dll	SUCCESS	Image Base: 0x7fefed30000, Image Size: 0xdb000
23:09:18,4975579	python.exe	4848	Load Image	C:\Windows\System32\sechost.dll	SUCCESS	Image Base: 0x7fefefc0000, Image Size: 0x1f000
23:09:18,4980934	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\vcruntime140.dll	SUCCESS	Image Base: 0x7fef9f20000, Image Size: 0x17000
23:09:18,4985102	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-runtime-l1-1-0.dll	SUCCESS	Image Base: 0x7fefae30000, Image Size: 0x4000
23:09:18,4990202	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\ucrtbase.dll	SUCCESS	Image Base: 0x7fef1980000, Image Size: 0xf6000
23:09:18,4993831	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-localization-l1-2-0.dll	SUCCESS	Image Base: 0x7fef9f10000, Image Size: 0x3000
23:09:18,4997199	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-processthreads-l1-1-1.dll	SUCCESS	Image Base: 0x7fef9f00000, Image Size: 0x3000
23:09:18,5000873	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-file-l1-2-0.dll	SUCCESS	Image Base: 0x7fef9c80000, Image Size: 0x3000
23:09:18,5004132	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-timezone-l1-1-0.dll	SUCCESS	Image Base: 0x7fef9c50000, Image Size: 0x3000
23:09:18,5007251	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-file-l2-1-0.dll	SUCCESS	Image Base: 0x7fef78f0000, Image Size: 0x3000
23:09:18,5010347	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-synch-l1-2-0.dll	SUCCESS	Image Base: 0x7fef78e0000, Image Size: 0x3000
23:09:18,5013723	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-string-l1-1-0.dll	SUCCESS	Image Base: 0x7fef7290000, Image Size: 0x4000
23:09:18,5017053	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-heap-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5b80000, Image Size: 0x3000
23:09:18,5020326	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-stdio-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5b20000, Image Size: 0x4000
23:09:18,5023556	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-convert-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5a00000, Image Size: 0x4000
23:09:18,5027163	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-math-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5680000, Image Size: 0x5000
23:09:18,5030972	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-locale-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5670000, Image Size: 0x3000
23:09:18,5035867	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-time-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5660000, Image Size: 0x3000
23:09:18,5040232	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-environment-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5650000, Image Size: 0x3000
23:09:18,5043476	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-process-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5640000, Image Size: 0x3000
23:09:18,5049748	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-conio-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5630000, Image Size: 0x3000
23:09:18,5053460	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-filesystem-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5620000, Image Size: 0x3000
23:09:18,5100964	python.exe	4848	Load Image	C:\Windows\System32\cryptsp.dll	SUCCESS	Image Base: 0x7fefc6b0000, Image Size: 0x18000
23:09:18,5144867	python.exe	4848	Load Image	C:\Windows\System32\rsaenh.dll	SUCCESS	Image Base: 0x7fefc3b0000, Image Size: 0x47000
23:09:18,5156094	python.exe	4848	Load Image	C:\Windows\System32\cryptbase.dll	SUCCESS	Image Base: 0x7fefccc0000, Image Size: 0xf000
23:09:22,2812159	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_ctypes.pyd	SUCCESS	Image Base: 0x6dae0000, Image Size: 0x23000
23:09:22,2818451	python.exe	4848	Load Image	C:\Windows\System32\ole32.dll	SUCCESS	Image Base: 0x7fefe1b0000, Image Size: 0x1fc000
23:09:22,2819936	python.exe	4848	Load Image	C:\Windows\System32\gdi32.dll	SUCCESS	Image Base: 0x7fefee10000, Image Size: 0x67000
23:09:22,2821573	python.exe	4848	Load Image	C:\Windows\System32\user32.dll	SUCCESS	Image Base: 0x76f70000, Image Size: 0xfa000
23:09:22,2823988	python.exe	4848	Load Image	C:\Windows\System32\lpk.dll	SUCCESS	Image Base: 0x7fefef90000, Image Size: 0xe000
23:09:22,2825875	python.exe	4848	Load Image	C:\Windows\System32\usp10.dll	SUCCESS	Image Base: 0x7fefe3b0000, Image Size: 0xcb000
23:09:22,2828244	python.exe	4848	Load Image	C:\Windows\System32\oleaut32.dll	SUCCESS	Image Base: 0x7fefe480000, Image Size: 0xda000
23:09:22,2852213	python.exe	4848	Load Image	C:\Windows\System32\imm32.dll	SUCCESS	Image Base: 0x7fefe7d0000, Image Size: 0x2e000
23:09:22,2854622	python.exe	4848	Load Image	C:\Windows\System32\msctf.dll	SUCCESS	Image Base: 0x7fefee80000, Image Size: 0x109000
23:09:22,2873239	python.exe	4848	Load Image	C:\Windows\System32\psapi.dll	SUCCESS	Image Base: 0x77350000, Image Size: 0x7000
23:09:22,3305458	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\core\multiarray.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fee9230000, Image Size: 0x1a6000
23:09:22,3403641	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\.libs\libopenblas.BNVRK7633HSX7YVO2TADGR4A5KEKXJAW.gfortran-win_amd64.dll	SUCCESS	Image Base: 0x65600000, Image Size: 0x2457000
23:09:22,3413041	python.exe	4848	Load Image	C:\Windows\System32\api-ms-win-crt-utility-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5310000, Image Size: 0x3000
23:09:22,3504746	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\core\umath.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef1500000, Image Size: 0xcb000
23:09:22,4512966	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_bz2.pyd	SUCCESS	Image Base: 0x6da10000, Image Size: 0x1a000
23:09:22,4549442	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_lzma.pyd	SUCCESS	Image Base: 0x7fef43d0000, Image Size: 0x29000
23:09:22,4646128	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_hashlib.pyd	SUCCESS	Image Base: 0x7fee9c80000, Image Size: 0x167000
23:09:22,4963274	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\linalg\lapack_lite.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef4670000, Image Size: 0xb000
23:09:22,4978504	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\linalg\_umath_linalg.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef41a0000, Image Size: 0x21000
23:09:22,5099393	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_decimal.pyd	SUCCESS	Image Base: 0x6d930000, Image Size: 0x52000
23:09:22,5235329	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\fft\fftpack_lite.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef4620000, Image Size: 0x18000
23:09:22,5429263	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\random\mtrand.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7feef130000, Image Size: 0xaa000
23:09:22,5610733	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\msvcp140.dll	SUCCESS	Image Base: 0x7fef1460000, Image Size: 0x9e000
23:09:22,5617687	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-multibyte-l1-1-0.dll	SUCCESS	Image Base: 0x7fef4660000, Image Size: 0x5000
23:09:22,5628030	python.exe	4848	Load Image	C:\Windows\System32\nvcuda.dll	SUCCESS	Image Base: 0x7fed7080000, Image Size: 0xd4c000
23:09:22,5629974	python.exe	4848	Load Image	C:\Windows\System32\setupapi.dll	SUCCESS	Image Base: 0x7fefdfd0000, Image Size: 0x1d7000
23:09:22,5631437	python.exe	4848	Load Image	C:\Windows\System32\cfgmgr32.dll	SUCCESS	Image Base: 0x7fefcfc0000, Image Size: 0x36000
23:09:22,5633367	python.exe	4848	Load Image	C:\Windows\System32\devobj.dll	SUCCESS	Image Base: 0x7fefd210000, Image Size: 0x1a000
23:09:22,5634824	python.exe	4848	Load Image	C:\Windows\System32\shell32.dll	SUCCESS	Image Base: 0x7fefd240000, Image Size: 0xd8a000
23:09:22,5636238	python.exe	4848	Load Image	C:\Windows\System32\shlwapi.dll	SUCCESS	Image Base: 0x7fefeb80000, Image Size: 0x71000
23:09:22,5670519	python.exe	4848	Load Image	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\cudart64_90.dll	SUCCESS	Image Base: 0x7fef3320000, Image Size: 0x61000
23:09:22,5767031	python.exe	4848	Load Image	C:\temp\cudnn\cuda\bin\cudnn64_7.dll	SUCCESS	Image Base: 0x7fec4ba0000, Image Size: 0x111e9000
23:09:22,5836291	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\tensorflow\python\_pywrap_tensorflow_internal.pyd	SUCCESS	Image Base: 0x7feb5630000, Image Size: 0xf564000
23:09:22,5848467	python.exe	4848	Load Image	C:\Windows\System32\wsock32.dll	SUCCESS	Image Base: 0x7fef89d0000, Image Size: 0x9000"><pre class="notranslate"><code class="notranslate">23:09:18,4934154	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\python.exe	SUCCESS	Image Base: 0x1ce20000, Image Size: 0xd000
23:09:18,4935443	python.exe	4848	Load Image	C:\Windows\System32\ntdll.dll	SUCCESS	Image Base: 0x77190000, Image Size: 0x1aa000
23:09:18,4940523	python.exe	4848	Load Image	C:\Windows\System32\kernel32.dll	SUCCESS	Image Base: 0x77070000, Image Size: 0x11f000
23:09:18,4942051	python.exe	4848	Load Image	C:\Windows\System32\KernelBase.dll	SUCCESS	Image Base: 0x7fefd010000, Image Size: 0x6a000
23:09:18,4954354	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\python35.dll	SUCCESS	Image Base: 0x60840000, Image Size: 0x3e4000
23:09:18,4962254	python.exe	4848	Load Image	C:\Windows\System32\ws2_32.dll	SUCCESS	Image Base: 0x7fefe860000, Image Size: 0x4d000
23:09:18,4963049	python.exe	4848	Load Image	C:\Windows\System32\msvcrt.dll	SUCCESS	Image Base: 0x7fefec80000, Image Size: 0x9f000
23:09:18,4965005	python.exe	4848	Load Image	C:\Windows\System32\rpcrt4.dll	SUCCESS	Image Base: 0x7fefe560000, Image Size: 0x12d000
23:09:18,4967902	python.exe	4848	Load Image	C:\Windows\System32\nsi.dll	SUCCESS	Image Base: 0x7fefed20000, Image Size: 0x8000
23:09:18,4969281	python.exe	4848	Load Image	C:\Windows\System32\advapi32.dll	SUCCESS	Image Base: 0x7fefed30000, Image Size: 0xdb000
23:09:18,4975579	python.exe	4848	Load Image	C:\Windows\System32\sechost.dll	SUCCESS	Image Base: 0x7fefefc0000, Image Size: 0x1f000
23:09:18,4980934	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\vcruntime140.dll	SUCCESS	Image Base: 0x7fef9f20000, Image Size: 0x17000
23:09:18,4985102	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-runtime-l1-1-0.dll	SUCCESS	Image Base: 0x7fefae30000, Image Size: 0x4000
23:09:18,4990202	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\ucrtbase.dll	SUCCESS	Image Base: 0x7fef1980000, Image Size: 0xf6000
23:09:18,4993831	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-localization-l1-2-0.dll	SUCCESS	Image Base: 0x7fef9f10000, Image Size: 0x3000
23:09:18,4997199	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-processthreads-l1-1-1.dll	SUCCESS	Image Base: 0x7fef9f00000, Image Size: 0x3000
23:09:18,5000873	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-file-l1-2-0.dll	SUCCESS	Image Base: 0x7fef9c80000, Image Size: 0x3000
23:09:18,5004132	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-timezone-l1-1-0.dll	SUCCESS	Image Base: 0x7fef9c50000, Image Size: 0x3000
23:09:18,5007251	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-file-l2-1-0.dll	SUCCESS	Image Base: 0x7fef78f0000, Image Size: 0x3000
23:09:18,5010347	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-core-synch-l1-2-0.dll	SUCCESS	Image Base: 0x7fef78e0000, Image Size: 0x3000
23:09:18,5013723	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-string-l1-1-0.dll	SUCCESS	Image Base: 0x7fef7290000, Image Size: 0x4000
23:09:18,5017053	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-heap-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5b80000, Image Size: 0x3000
23:09:18,5020326	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-stdio-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5b20000, Image Size: 0x4000
23:09:18,5023556	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-convert-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5a00000, Image Size: 0x4000
23:09:18,5027163	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-math-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5680000, Image Size: 0x5000
23:09:18,5030972	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-locale-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5670000, Image Size: 0x3000
23:09:18,5035867	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-time-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5660000, Image Size: 0x3000
23:09:18,5040232	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-environment-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5650000, Image Size: 0x3000
23:09:18,5043476	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-process-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5640000, Image Size: 0x3000
23:09:18,5049748	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-conio-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5630000, Image Size: 0x3000
23:09:18,5053460	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-filesystem-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5620000, Image Size: 0x3000
23:09:18,5100964	python.exe	4848	Load Image	C:\Windows\System32\cryptsp.dll	SUCCESS	Image Base: 0x7fefc6b0000, Image Size: 0x18000
23:09:18,5144867	python.exe	4848	Load Image	C:\Windows\System32\rsaenh.dll	SUCCESS	Image Base: 0x7fefc3b0000, Image Size: 0x47000
23:09:18,5156094	python.exe	4848	Load Image	C:\Windows\System32\cryptbase.dll	SUCCESS	Image Base: 0x7fefccc0000, Image Size: 0xf000
23:09:22,2812159	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_ctypes.pyd	SUCCESS	Image Base: 0x6dae0000, Image Size: 0x23000
23:09:22,2818451	python.exe	4848	Load Image	C:\Windows\System32\ole32.dll	SUCCESS	Image Base: 0x7fefe1b0000, Image Size: 0x1fc000
23:09:22,2819936	python.exe	4848	Load Image	C:\Windows\System32\gdi32.dll	SUCCESS	Image Base: 0x7fefee10000, Image Size: 0x67000
23:09:22,2821573	python.exe	4848	Load Image	C:\Windows\System32\user32.dll	SUCCESS	Image Base: 0x76f70000, Image Size: 0xfa000
23:09:22,2823988	python.exe	4848	Load Image	C:\Windows\System32\lpk.dll	SUCCESS	Image Base: 0x7fefef90000, Image Size: 0xe000
23:09:22,2825875	python.exe	4848	Load Image	C:\Windows\System32\usp10.dll	SUCCESS	Image Base: 0x7fefe3b0000, Image Size: 0xcb000
23:09:22,2828244	python.exe	4848	Load Image	C:\Windows\System32\oleaut32.dll	SUCCESS	Image Base: 0x7fefe480000, Image Size: 0xda000
23:09:22,2852213	python.exe	4848	Load Image	C:\Windows\System32\imm32.dll	SUCCESS	Image Base: 0x7fefe7d0000, Image Size: 0x2e000
23:09:22,2854622	python.exe	4848	Load Image	C:\Windows\System32\msctf.dll	SUCCESS	Image Base: 0x7fefee80000, Image Size: 0x109000
23:09:22,2873239	python.exe	4848	Load Image	C:\Windows\System32\psapi.dll	SUCCESS	Image Base: 0x77350000, Image Size: 0x7000
23:09:22,3305458	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\core\multiarray.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fee9230000, Image Size: 0x1a6000
23:09:22,3403641	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\.libs\libopenblas.BNVRK7633HSX7YVO2TADGR4A5KEKXJAW.gfortran-win_amd64.dll	SUCCESS	Image Base: 0x65600000, Image Size: 0x2457000
23:09:22,3413041	python.exe	4848	Load Image	C:\Windows\System32\api-ms-win-crt-utility-l1-1-0.dll	SUCCESS	Image Base: 0x7fef5310000, Image Size: 0x3000
23:09:22,3504746	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\core\umath.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef1500000, Image Size: 0xcb000
23:09:22,4512966	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_bz2.pyd	SUCCESS	Image Base: 0x6da10000, Image Size: 0x1a000
23:09:22,4549442	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_lzma.pyd	SUCCESS	Image Base: 0x7fef43d0000, Image Size: 0x29000
23:09:22,4646128	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_hashlib.pyd	SUCCESS	Image Base: 0x7fee9c80000, Image Size: 0x167000
23:09:22,4963274	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\linalg\lapack_lite.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef4670000, Image Size: 0xb000
23:09:22,4978504	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\linalg\_umath_linalg.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef41a0000, Image Size: 0x21000
23:09:22,5099393	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\DLLs\_decimal.pyd	SUCCESS	Image Base: 0x6d930000, Image Size: 0x52000
23:09:22,5235329	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\fft\fftpack_lite.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7fef4620000, Image Size: 0x18000
23:09:22,5429263	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\numpy\random\mtrand.cp35-win_amd64.pyd	SUCCESS	Image Base: 0x7feef130000, Image Size: 0xaa000
23:09:22,5610733	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\msvcp140.dll	SUCCESS	Image Base: 0x7fef1460000, Image Size: 0x9e000
23:09:22,5617687	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\api-ms-win-crt-multibyte-l1-1-0.dll	SUCCESS	Image Base: 0x7fef4660000, Image Size: 0x5000
23:09:22,5628030	python.exe	4848	Load Image	C:\Windows\System32\nvcuda.dll	SUCCESS	Image Base: 0x7fed7080000, Image Size: 0xd4c000
23:09:22,5629974	python.exe	4848	Load Image	C:\Windows\System32\setupapi.dll	SUCCESS	Image Base: 0x7fefdfd0000, Image Size: 0x1d7000
23:09:22,5631437	python.exe	4848	Load Image	C:\Windows\System32\cfgmgr32.dll	SUCCESS	Image Base: 0x7fefcfc0000, Image Size: 0x36000
23:09:22,5633367	python.exe	4848	Load Image	C:\Windows\System32\devobj.dll	SUCCESS	Image Base: 0x7fefd210000, Image Size: 0x1a000
23:09:22,5634824	python.exe	4848	Load Image	C:\Windows\System32\shell32.dll	SUCCESS	Image Base: 0x7fefd240000, Image Size: 0xd8a000
23:09:22,5636238	python.exe	4848	Load Image	C:\Windows\System32\shlwapi.dll	SUCCESS	Image Base: 0x7fefeb80000, Image Size: 0x71000
23:09:22,5670519	python.exe	4848	Load Image	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\cudart64_90.dll	SUCCESS	Image Base: 0x7fef3320000, Image Size: 0x61000
23:09:22,5767031	python.exe	4848	Load Image	C:\temp\cudnn\cuda\bin\cudnn64_7.dll	SUCCESS	Image Base: 0x7fec4ba0000, Image Size: 0x111e9000
23:09:22,5836291	python.exe	4848	Load Image	C:\temp\tensorflow-gpu\Lib\site-packages\tensorflow\python\_pywrap_tensorflow_internal.pyd	SUCCESS	Image Base: 0x7feb5630000, Image Size: 0xf564000
23:09:22,5848467	python.exe	4848	Load Image	C:\Windows\System32\wsock32.dll	SUCCESS	Image Base: 0x7fef89d0000, Image Size: 0x9000
</code></pre></div>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>: NO</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>: Ubuntu 16.04</li>
<li><strong>TensorFlow installed from (source or binary)</strong>:  pip install</li>
<li><strong>TensorFlow version (use command below)</strong>: v1.9.0-rc0-35-g17d6639b55 1.9.0-rc1</li>
<li><strong>Python version</strong>:  3.6</li>
<li><strong>CUDA/cuDNN version</strong>:  CUDA 9.0 / cuDNN 7</li>
<li><strong>GPU model and memory</strong>: GTX 1080</li>
<li><strong>Exact command to reproduce</strong>:</li>
</ul>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import tensorflow as tf

def conv_block(inputs, filters, kernel_size, strides, scope):
  '''Create a simple Conv --&gt; BN --&gt; ReLU6 block'''

  with tf.variable_scope(scope):
    x = tf.keras.layers.Conv2D(filters, kernel_size, strides, name='conv2d')(inputs)
    x = tf.keras.layers.BatchNormalization(name='BN')(x)
    x = tf.keras.layers.Activation(tf.nn.relu6)(x)
    return x

def reproduce_keras_variable_scope_error():

  # Construct a simple model
  inputs = tf.keras.Input(shape=[224, 224, 3], batch_size=1, name='inputs')
  hidden = conv_block(inputs, 32, 3, 2, scope='block_1')
  outputs = conv_block(hidden, 64, 3, 2, scope='block_2')
  
  # This is fine, the tensor scopes are matched as expected
  for v in tf.trainable_variables():
    print('{:20} {}'.format(v.name, v.shape))

  # Problem happens here. Please consult the error output below.
  model = tf.keras.Model(inputs, outputs)
  model.summary()

if __name__ =='__main__':
  reproduce_keras_variable_scope_error()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">tensorflow</span> <span class="pl-k">as</span> <span class="pl-s1">tf</span>

<span class="pl-k">def</span> <span class="pl-en">conv_block</span>(<span class="pl-s1">inputs</span>, <span class="pl-s1">filters</span>, <span class="pl-s1">kernel_size</span>, <span class="pl-s1">strides</span>, <span class="pl-s1">scope</span>):
  <span class="pl-s">'''Create a simple Conv --&gt; BN --&gt; ReLU6 block'''</span>

  <span class="pl-k">with</span> <span class="pl-s1">tf</span>.<span class="pl-en">variable_scope</span>(<span class="pl-s1">scope</span>):
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Conv2D</span>(<span class="pl-s1">filters</span>, <span class="pl-s1">kernel_size</span>, <span class="pl-s1">strides</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">'conv2d'</span>)(<span class="pl-s1">inputs</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>(<span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">'BN'</span>)(<span class="pl-s1">x</span>)
    <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-s1">layers</span>.<span class="pl-v">Activation</span>(<span class="pl-s1">tf</span>.<span class="pl-s1">nn</span>.<span class="pl-s1">relu6</span>)(<span class="pl-s1">x</span>)
    <span class="pl-k">return</span> <span class="pl-s1">x</span>

<span class="pl-k">def</span> <span class="pl-en">reproduce_keras_variable_scope_error</span>():

  <span class="pl-c"># Construct a simple model</span>
  <span class="pl-s1">inputs</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-v">Input</span>(<span class="pl-s1">shape</span><span class="pl-c1">=</span>[<span class="pl-c1">224</span>, <span class="pl-c1">224</span>, <span class="pl-c1">3</span>], <span class="pl-s1">batch_size</span><span class="pl-c1">=</span><span class="pl-c1">1</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">'inputs'</span>)
  <span class="pl-s1">hidden</span> <span class="pl-c1">=</span> <span class="pl-en">conv_block</span>(<span class="pl-s1">inputs</span>, <span class="pl-c1">32</span>, <span class="pl-c1">3</span>, <span class="pl-c1">2</span>, <span class="pl-s1">scope</span><span class="pl-c1">=</span><span class="pl-s">'block_1'</span>)
  <span class="pl-s1">outputs</span> <span class="pl-c1">=</span> <span class="pl-en">conv_block</span>(<span class="pl-s1">hidden</span>, <span class="pl-c1">64</span>, <span class="pl-c1">3</span>, <span class="pl-c1">2</span>, <span class="pl-s1">scope</span><span class="pl-c1">=</span><span class="pl-s">'block_2'</span>)
  
  <span class="pl-c"># This is fine, the tensor scopes are matched as expected</span>
  <span class="pl-k">for</span> <span class="pl-s1">v</span> <span class="pl-c1">in</span> <span class="pl-s1">tf</span>.<span class="pl-en">trainable_variables</span>():
    <span class="pl-en">print</span>(<span class="pl-s">'{:20} {}'</span>.<span class="pl-en">format</span>(<span class="pl-s1">v</span>.<span class="pl-s1">name</span>, <span class="pl-s1">v</span>.<span class="pl-s1">shape</span>))

  <span class="pl-c"># Problem happens here. Please consult the error output below.</span>
  <span class="pl-s1">model</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-v">Model</span>(<span class="pl-s1">inputs</span>, <span class="pl-s1">outputs</span>)
  <span class="pl-s1">model</span>.<span class="pl-en">summary</span>()

<span class="pl-k">if</span> <span class="pl-s1">__name__</span> <span class="pl-c1">==</span><span class="pl-s">'__main__'</span>:
  <span class="pl-en">reproduce_keras_variable_scope_error</span>()</pre></div>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">The problem is Keras layers do not probably name its variables according the <code class="notranslate">variable_scope</code> . Therefore, I cannot call <code class="notranslate">conv_block</code> multiple times.</p>
<ul dir="auto">
<li>This problem occurs when calling <code class="notranslate">tf.layers</code> as well.</li>
<li>I would like to use <code class="notranslate">tf.keras.Model</code> because I might convert to <code class="notranslate">Estimator</code> later.</li>
</ul>
<h3 dir="auto">Source code / logs</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="block_1/conv2d/kernel:0 (3, 3, 3, 32)
block_1/conv2d/bias:0 (32,)
block_1/BN/gamma:0   (32,)
block_1/BN/beta:0    (32,)
block_2/conv2d/kernel:0 (3, 3, 32, 64)
block_2/conv2d/bias:0 (64,)
block_2/BN/gamma:0   (64,)
block_2/BN/beta:0    (64,)
Traceback (most recent call last):
  File &quot;tf_keras_layer.py&quot;, line 24, in &lt;module&gt;
    reproduce_variable_scope_error()
  File &quot;tf_keras_layer.py&quot;, line 20, in reproduce_variable_scope_error
    model = tf.keras.Model(inputs, outputs)
  File &quot;/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py&quot;, line 112, in __init__
    super(Model, self).__init__(*args, **kwargs)
  File &quot;/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py&quot;, line 78, in __init__
    self._init_graph_network(*args, **kwargs)
  File &quot;/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py&quot;, line 244, in _init_graph_network
    self.inputs, self.outputs)
  File &quot;/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py&quot;, line 1689, in _map_graph_network
    str(all_names.count(name)) + ' times in the model. '
ValueError: The name &quot;conv2d&quot; is used 2 times in the model. All layer names should be unique."><pre class="notranslate">block_1/conv2d/kernel:0 (3, 3, 3, 32)
block_1/conv2d/bias:0 (32,)
block_1/BN/gamma:0   (32,)
block_1/BN/beta:0    (32,)
block_2/conv2d/kernel:0 (3, 3, 32, 64)
block_2/conv2d/bias:0 (64,)
block_2/BN/gamma:0   (64,)
block_2/BN/beta:0    (64,)
Traceback (most recent call last):
  File <span class="pl-s"><span class="pl-pds">"</span>tf_keras_layer.py<span class="pl-pds">"</span></span>, line 24, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
    <span class="pl-en">reproduce_variable_scope_error</span>()
  File <span class="pl-s"><span class="pl-pds">"</span>tf_keras_layer.py<span class="pl-pds">"</span></span>, line 20, <span class="pl-k">in</span> reproduce_variable_scope_error
    model = tf.keras.Model(inputs, outputs)
  File <span class="pl-s"><span class="pl-pds">"</span>/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py<span class="pl-pds">"</span></span>, line 112, <span class="pl-k">in</span> __init__
    super(Model, self).__init__(<span class="pl-k">*</span>args, <span class="pl-k">**</span>kwargs)
  File <span class="pl-s"><span class="pl-pds">"</span>/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py<span class="pl-pds">"</span></span>, line 78, <span class="pl-k">in</span> __init__
    self._init_graph_network(<span class="pl-k">*</span>args, <span class="pl-k">**</span>kwargs)
  File <span class="pl-s"><span class="pl-pds">"</span>/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py<span class="pl-pds">"</span></span>, line 244, <span class="pl-k">in</span> _init_graph_network
    self.inputs, self.outputs)
  File <span class="pl-s"><span class="pl-pds">"</span>/home/dat/miniconda2/envs/portrait/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py<span class="pl-pds">"</span></span>, line 1689, <span class="pl-k">in</span> _map_graph_network
    str(all_names.count(name)) + <span class="pl-s"><span class="pl-pds">'</span> times in the model. <span class="pl-pds">'</span></span>
ValueError: The name <span class="pl-s"><span class="pl-pds">"</span>conv2d<span class="pl-pds">"</span></span> is used 2 <span class="pl-c1">times</span> <span class="pl-k">in</span> the model. All layer names should be unique.</pre></div>