Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TensorFlow doesn't support NCHW #3

Closed
hao-zi opened this issue Dec 30, 2017 · 6 comments
Closed

TensorFlow doesn't support NCHW #3

hao-zi opened this issue Dec 30, 2017 · 6 comments

Comments

@hao-zi
Copy link

hao-zi commented Dec 30, 2017

`UnimplementedError (see above for traceback):  Generic conv implementation only supports NHWC tensor format for now.
	 [[Node: Generator.1.1/conv1d/Conv2D = Conv2D[T=DT_FLOAT, data_format="NCHW", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](Generator.1.1/conv1d/ExpandDims, Generator.1.1/conv1d/ExpandDims_1)]]`

my tensorflow is 1.4.0
python is 2.7

@hao-zi
Copy link
Author

hao-zi commented Dec 30, 2017

when i change NCHW to NHWC in tflib/ops/conv1d.py, i get errors:

Traceback (most recent call last):
  File "sample.py", line 79, in <module>
    fake_inputs = models.Generator(args.batch_size, args.seq_length, args.layer_dim, len(charmap))
  File "/home/tf/passgam/PassGAN-master/models.py", line 19, in Generator
    output = ResBlock('Generator.1', output, layer_dim)
  File "/home/tf/passgam/PassGAN-master/models.py", line 9, in ResBlock
    output = lib.ops.conv1d.Conv1D(name+'.1', dim, dim, 5, output)
  File "/home/tf/passgam/PassGAN-master/tflib/ops/conv1d.py", line 93, in Conv1D
    data_format='NHWC'
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 2204, in conv1d
    data_format=data_format)
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 631, in conv2d
    data_format=data_format, name=name)
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2958, in create_op
    set_shapes_for_outputs(ret)
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn
    require_shape_fn)
  File "/home/tf/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimensions must be equal, but are 10 and 128 for 'Generator.1.1/conv1d/Conv2D' (op: 'Conv2D') with input shapes: [1024,1,128,10], [1,5,128,128].

@brannondorsey
Copy link
Owner

It looks like you are running this on a CPU. If I remember correctly, I've run into this issue with Tensorflow CNNs run on CPUs before. I've only tested this code on CUDA supported GPU devices. I don't have the bandwidth to dig into CPU support right now, especially given how slow the performance will likely be, but likely others have posted on this or a similar issue w/ tensorflow conv2D before.

Good luck!

@mikeryan
Copy link

mikeryan commented Jan 3, 2018

I'm having the same problem. How do you get the code to run on a GPU? I installed tensorflow using pip and my system has several nVidia 1080 GPUs, but the code does not appear to use them.

@brannondorsey
Copy link
Owner

@mikeryan, this should do the trick:

pip Install tensorflow-gpu

I'll add that to the requirements.txt file and upload it tonight.

@mikeryan
Copy link

mikeryan commented Jan 3, 2018 via email

@iBM88
Copy link

iBM88 commented Aug 18, 2018

I have the same problem. The packages mikeryan mentioned are already installed on my machine with version 7.5. I installed cuDNN too but it didn't help. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants