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

InvalidArgumentError (see above for traceback): CPU BiasOp only supports NHWC #15

Open
ch3njust1n opened this issue Jan 27, 2017 · 2 comments

Comments

@ch3njust1n
Copy link

Got an InvalidArgumentError after 26 minutes of training. I upgraded to the most recent TensorFlow as suggested and did $ pip install -U 'gym[all]' tqdm scipy. I ran this on a TitanX and Ubuntu 16.10.

$ time python main.py --network_header_type=nips --env_name=Breakout-v0 --use_gpu=True --display=True
[2017-01-26 23:58:40,289] DEPRECATION WARNING: env.spec.timestep_limit has been deprecated. Replace any calls to `register(timestep_limit=200)` with `register(tags={'wrapper_config.TimeLimit.max_episode_steps': 200)}`, . This change was made 12/28/2016 and is included in gym version 0.7.0. If you are getting many of these warnings, you may need to update universe past version 0.21.1
[2017-01-26 23:58:40,289] DEPRECATION WARNING: env.spec.timestep_limit has been deprecated. Replace any calls to `register(timestep_limit=200)` with `register(tags={'wrapper_config.TimeLimit.max_episode_steps': 200)}`, . This change was made 12/28/2016 and is included in gym version 0.7.0. If you are getting many of these warnings, you may need to update universe past version 0.21.1
[2017-01-26 23:58:40,289] DEPRECATION WARNING: env.spec.timestep_limit has been deprecated. Replace any calls to `register(timestep_limit=200)` with `register(tags={'wrapper_config.TimeLimit.max_episode_steps': 200)}`, . This change was made 12/28/2016 and is included in gym version 0.7.0. If you are getting many of these warnings, you may need to update universe past version 0.21.1
[2017-01-26 23:58:40,289] DEPRECATION WARNING: env.spec.timestep_limit has been deprecated. Replace any calls to `register(timestep_limit=200)` with `register(tags={'wrapper_config.TimeLimit.max_episode_steps': 200)}`, . This change was made 12/28/2016 and is included in gym version 0.7.0. If you are getting many of these warnings, you may need to update universe past version 0.21.1
{'agent_type': 'DQN',
 'batch_size': 32,
 'beta': 0.01,
 'data_format': 'NCHW',
 'decay': 0.99,
 'discount_r': 0.99,
 'display': True,
 'double_q': False,
 'env_name': 'Breakout-v0',
 'ep_end': 0.01,
 'ep_start': 1.0,
 'gamma': 0.99,
 'gpu_fraction': '1/1',
 'history_length': 4,
 'is_train': True,
 'learning_rate': 0.00025,
 'learning_rate_decay': 0.96,
 'learning_rate_decay_step': 50000,
 'learning_rate_minimum': 0.00025,
 'log_level': 'INFO',
 'max_delta': None,
 'max_grad_norm': None,
 'max_r': 1,
 'max_random_start': 30,
 'memory_size': 1000000,
 'min_delta': None,
 'min_r': -1,
 'momentum': 0.0,
 'n_action_repeat': 4,
 'network_header_type': 'nips',
 'network_output_type': 'normal',
 'observation_dims': [80, 80],
 'random_seed': 123,
 'random_start': True,
 'scale': 10000,
 't_ep_end': 1000000,
 't_learn_start': 50000,
 't_target_q_update_freq': 10000,
 't_test': 10000,
 't_train_freq': 4,
 't_train_max': 50000000,
 'tag': '',
 'unrolled_lstm': False,
 'use_cumulated_reward': False,
 'use_gpu': True}
 [*] GPU : 1.0000
[2017-01-26 23:58:40,330] Making new env: Breakout-v0
[2017-01-26 23:58:40,352] Using 6 actions : NOOP, FIRE, RIGHT, LEFT, RIGHTFIRE, LEFTFIRE
INFO:tensorflow:Summary name episode/max reward is illegal; using episode/max_reward instead.
[2017-01-26 23:58:40,938] Summary name episode/max reward is illegal; using episode/max_reward instead.
INFO:tensorflow:Summary name episode/min reward is illegal; using episode/min_reward instead.
[2017-01-26 23:58:40,940] Summary name episode/min reward is illegal; using episode/min_reward instead.
INFO:tensorflow:Summary name episode/avg reward is illegal; using episode/avg_reward instead.
[2017-01-26 23:58:40,941] Summary name episode/avg reward is illegal; using episode/avg_reward instead.
INFO:tensorflow:Summary name episode/num of game is illegal; using episode/num_of_game instead.
[2017-01-26 23:58:40,943] Summary name episode/num of game is illegal; using episode/num_of_game instead.
WARNING:tensorflow:From /media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/agents/agent.py:61 in train.: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use `tf.global_variables_initializer` instead.
[2017-01-26 23:58:41,273] From /media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/agents/agent.py:61 in train.: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use `tf.global_variables_initializer` instead.
 [!] Load FAILED: checkpoints/Breakout-v0/env_name=Breakout-v0/agent_type=DQN/batch_size=32/beta=0.01/data_format=NCHW/decay=0.99/discount_r=0.99/double_q=False/ep_end=0.01/ep_start=1.0/gamma=0.99/history_length=4/learning_rate=0.00025/learning_rate_decay=0.96/learning_rate_decay_step=50000/learning_rate_minimum=0.00025/max_delta=None/max_grad_norm=None/max_r=1/min_delta=None/min_r=-1/momentum=0.0/n_action_repeat=4/network_header_type=nips/network_output_type=normal/observation_dims=80,80/random_start=True/t_ep_end=1000000/t_learn_start=50000/t_target_q_update_freq=10000/t_test=10000/t_train_freq=4/t_train_max=50000000/unrolled_lstm=False/use_cumulated_reward=False/
  0%|                                    | 0/50000000 [00:00<?, ?it/s]/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py:2889: RuntimeWarning: Mean of empty slice.
  out=out, **kwargs)
/usr/local/lib/python2.7/dist-packages/numpy/core/_methods.py:80: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
  0%|                    | 50002/50000000 [25:59<436:00:27, 31.82it/s]E tensorflow/core/common_runtime/executor.cc:390] Executor failed to create kernel. Invalid argument: CPU BiasOp only supports NHWC.
	 [[Node: target_network/l1_conv/BiasAdd = BiasAdd[T=DT_FLOAT, data_format="NCHW", _device="/job:localhost/replica:0/task:0/cpu:0"](target_network/l1_conv/Conv2D, target_network/l1_conv/b/read)]]
Traceback (most recent call last):
  File "main.py", line 168, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 43, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "main.py", line 163, in main
    agent.train(conf.t_train_max)
  File "/media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/agents/agent.py", line 82, in train
    q, loss, is_update = self.observe(observation, reward, action, terminal)
  File "/media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/agents/deep_q.py", line 61, in observe
    result = self.q_learning_minibatch()
  File "/media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/agents/deep_q.py", line 84, in q_learning_minibatch
    max_q_t_plus_1 = self.target_network.calc_max_outputs(s_t_plus_1)
  File "/media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/networks/network.py", line 87, in calc_max_outputs
    return self.max_outputs.eval({self.inputs: observation}, session=self.sess)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 575, in eval
    return _eval_using_default_session(self, feed_dict, self.graph, session)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3633, in _eval_using_default_session
    return session.run(tensors, feed_dict)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 766, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 964, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1014, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1034, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: CPU BiasOp only supports NHWC.
	 [[Node: target_network/l1_conv/BiasAdd = BiasAdd[T=DT_FLOAT, data_format="NCHW", _device="/job:localhost/replica:0/task:0/cpu:0"](target_network/l1_conv/Conv2D, target_network/l1_conv/b/read)]]

Caused by op u'target_network/l1_conv/BiasAdd', defined at:
  File "main.py", line 168, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 43, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "main.py", line 140, in main
    name='target_network', trainable=False)
  File "/media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/networks/cnn.py", line 55, in __init__
    hidden_activation_fn, data_format, name='l1_conv')
  File "/media/ch3njus/Seagate4TB/research/ab/deep-rl-tensorflow/networks/layers.py", line 30, in conv2d
    out = tf.nn.bias_add(conv, b, data_format)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1172, in bias_add
    return gen_nn_ops._bias_add(value, bias, data_format=data_format, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 281, in _bias_add
    data_format=data_format, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): CPU BiasOp only supports NHWC.
	 [[Node: target_network/l1_conv/BiasAdd = BiasAdd[T=DT_FLOAT, data_format="NCHW", _device="/job:localhost/replica:0/task:0/cpu:0"](target_network/l1_conv/Conv2D, target_network/l1_conv/b/read)]]


real	26m4.536s
user	10m27.848s
sys	7m41.136s
@nanxintin
Copy link

Hi @ch3njust1n ,
I came across the same error when running DQN for vizdoom.
Have you solved the problem?

@seungilyou
Copy link

Your tensorflow doesn't support GPU. Upgrade your TF to

pip install --upgrade tensorflow-gpu

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

3 participants