genforce / idinvert

[ECCV 2020] In-Domain GAN Inversion for Real Image Editing
https://genforce.github.io/idinvert/
MIT License
461 stars 65 forks source link

Error occurs when running invert.py #38

Closed hadzica closed 3 years ago

hadzica commented 3 years ago

Hi everyone,

When running invert.py according to your instructions I get the following error at line 157:

Traceback (most recent call last): File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call return fn(*args) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.UnimplementedError: Depthwise convolution on CPU is only supported for NHWC format [[{{node G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise}} = DepthwiseConv2dNative[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"](G_synthesis_2/8x8/Conv0_up/Conv2D, G_synthesis_2/8x8/Conv0_up/Blur2D/filter)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run run_metadata) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.UnimplementedError: Depthwise convolution on CPU is only supported for NHWC format [[node G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise (defined at :47) = DepthwiseConv2dNative[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"](G_synthesis_2/8x8/Conv0_up/Conv2D, G_synthesis_2/8x8/Conv0_up/Blur2D/filter)]]

Caused by op 'G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise', defined at: File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 2141, in main() File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 2132, in main globals = debugger.run(setup['file'], None, None, is_module) File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 1441, in run return self._exec(is_module, entry_point_fn, module_name, file, globals, locals) File "/home/amir/.pycharm_helpers/pydev/pydevd.py", line 1448, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/home/amir/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/amir/idinvert/invert.py", line 191, in main() File "/home/amir/idinvert/invert.py", line 90, in main x_rec = Gs.components.synthesis.get_output_for(wp, randomize_noise=False) File "/home/amir/idinvert/dnnlib/tflib/network.py", line 222, in get_output_for out_expr = self._build_func(*final_inputs, *build_kwargs) File "", line 562, in G_synthesis File "", line 557, in grow File "", line 526, in block File "", line 473, in blur File "", line 106, in blur2d File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/custom_gradient.py", line 111, in decorated return _graph_mode_decorator(f, args, kwargs) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/custom_gradient.py", line 132, in _graph_mode_decorator result, grad_fn = f(args) File "", line 100, in func File "", line 47, in _blur2d File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_impl.py", line 461, in depthwise_conv2d op=op) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 364, in with_space_to_batch return new_op(input, None) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 520, in call return self.call(inp, filter) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nnops.py", line 354, in return lambda inp, : op(inp, num_spatial_dims, padding) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/nn_impl.py", line 453, in op name=name) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 2112, in depthwise_conv2d_native name=name) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func return func(args, kwargs) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op op_def=op_def) File "/home/amir/.conda/envs/dl_p/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1770, in init self._traceback = tf_stack.extract_stack()

UnimplementedError (see above for traceback): Depthwise convolution on CPU is only supported for NHWC format [[node G_synthesis_2/8x8/Conv0_up/Blur2D/depthwise (defined at :47) = DepthwiseConv2dNative[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"](G_synthesis_2/8x8/Conv0_up/Conv2D, G_synthesis_2/8x8/Conv0_up/Blur2D/filter)]]

It seems that it tries to do the networks operations on cpu. I have access to a gpu with id 0. I don't know where the right device is set. Could you maybe explain that error.

Regards

zhujiapeng commented 3 years ago

Make sure that you have installed TensorFlow on GPU.