Issue 1:
The example

import tensorflow as tf
x = tf.Variable(1.)
A = tf.Variable(tf.ones((3,3)))
cost = tf.trace(tf.foldl(tf.matmul,tf.stack([x*A for _ in range(3)])))
tf.gradients(tf.gradients(cost, A), x)
# TypeError: Second-order gradient for while loops not supported.

illustrates that despite applying tf.foldl to a static list, the internal implementation via while loops leads to a type error. The problem disappears if the fold operation is carried out manually using a for loop. While implementing foldl using the while loop clearly makes the operation more widely applicable, it seems problematic if syntactic sugar can lead to code that has qualitative differences from a naive implementation using a static loop. I cannot help but wonder whether foldl could be more efficient in the static case as well, although that is more of a conjecture.

I think it would be nice if foldl (and other while loop derivatives) had a keyword that enabled or disabled the "dynamic mode" using while, or if, at the very least, the TypeError would occur at the foldloperation so that the error is easier to trace.

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow):

Custom code.

OS Platform and Distribution (e.g., Linux Ubuntu 16.04):

Linux Ubuntu 16.04 LTS

TensorFlow installed from (source or binary):

pip install.

TensorFlow version (use command below):

v1.4.0-rc1-11-g130a514 1.4.0

Python version:

3.5.4

Bazel version (if compiling from source):

Not applicable.

GCC/Compiler version (if compiling from source):

Not applicable.

CUDA/cuDNN version:

Did not use CUDA.

GPU model and memory:

Did not use GPU.

Exact command to reproduce:

import tensorflow as tf
x = tf.Variable(1.)
A = tf.Variable(tf.ones((3,3)))
cost = tf.trace(tf.foldl(tf.matmul,tf.stack([x*A for _ in range(3)])))
tf.gradients(tf.gradients(cost, A), x)
# TypeError: Second-order gradient for while loops not supported.

Issue 2:
System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10

TensorFlow installed from (source or binary): Binary

TensorFlow version (use command below): unknown, command fails (this is the problem)

Bazel version (if compiling from source): N/A

CUDA/cuDNN version: 8.0/5.1

GPU model and memory: GeForce GTX 970, 4 GB

Exact command to reproduce: import tensorflow as tf

Problem

This is something I've seen in a previous issue report added as a comment, but no one responded to it (except to say that you should be using cuDNN 5.1 instead of 6.0, which I am doing). I cannot even import tensorflow because it leads to the string of errors below. Someone in the linked issue suggested that this was caused by a missing MSVCP140.DLL, but this file is present in both my System32 and SysWOW64 folders (I have seen both mentioned). I have also installed the suggested Visual C++ Redistributable Update 3 with no luck.

Log

Traceback (most recent call last):

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper

return importlib.import_module(mname)

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\importlib_init_.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 986, in _gcd_import

File "", line 969, in _find_and_load

File "", line 958, in _find_and_load_unlocked

File "", line 666, in _load_unlocked

File "", line 577, in module_from_spec

File "", line 906, in create_module

File "", line 222, in _call_with_frames_removed

ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in

from tensorflow.python.pywrap_tensorflow_internal import *

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in

_pywrap_tensorflow_internal = swig_import_helper()

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper

return importlib.import_module('pywrap_tensorflow_internal')

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\importlib_init.py", line 126, in import_module

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 "", line 1, in

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow_init_.py", line 24, in

from tensorflow.python import *

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 51, in

from tensorflow.python import pywrap_tensorflow

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper

return importlib.import_module(mname)

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\importlib_init_.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 986, in _gcd_import

File "", line 969, in _find_and_load

File "", line 958, in _find_and_load_unlocked

File "", line 666, in _load_unlocked

File "", line 577, in module_from_spec

File "", line 906, in create_module

File "", line 222, in _call_with_frames_removed

ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in

from tensorflow.python.pywrap_tensorflow_internal import *

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in

_pywrap_tensorflow_internal = swig_import_helper()

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper

return importlib.import_module('pywrap_tensorflow_internal')

File "C:\Users\Elijah\AppData\Local\Programs\Python\Python35\lib\importlib_init.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

ImportError: No module named '_pywrap_tensorflow_internal'