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

Error during run #10

Open
ElenSmi opened this issue Mar 6, 2018 · 2 comments
Open

Error during run #10

ElenSmi opened this issue Mar 6, 2018 · 2 comments

Comments

@ElenSmi
Copy link

ElenSmi commented Mar 6, 2018

I can't seem to understand the error I am getting while running the main.py

Use tf.global_variables_initializer instead.
Traceback (most recent call last):
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1139, in _do_call
return fn(*args)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1121, in _run_fn
status, run_metadata)
File "D:\anaconda3\lib\contextlib.py", line 88, in exit
next(self.gen)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\smyrniou\dcgan-master\tensorlayer\layers.py", line 235, in initialize_global_variables
sess.run(tf.global_variables_initializer())
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 789, in run
run_metadata_ptr)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

Caused by op 'generator/g/h4/decon2d/b_deconv2d/Adam_1', defined at:
File "C:/Users/smyrniou/dcgan-master/main.py", line 145, in
tf.app.run()
File "D:\anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "C:/Users/smyrniou/dcgan-master/main.py", line 82, in main
.minimize(g_loss, var_list=g_vars)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 325, in minimize
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 446, in apply_gradients
self._create_slots([_get_variable_for(v) for v in var_list])
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\adam.py", line 129, in _create_slots
self._zeros_slot(v, "v", self._name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 766, in _zeros_slot
named_slots[_var_key(var)] = slot_creator.create_zeros_slot(var, op_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 174, in create_zeros_slot
colocate_with_primary=colocate_with_primary)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 146, in create_slot_with_initializer
dtype)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 66, in _create_slot_var
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1065, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 962, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 367, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 352, in _true_getter
use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 725, in _get_single_variable
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 200, in init
expected_shape=expected_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 284, in _init_from_args
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\state_ops.py", line 128, in variable_op_v2
shared_name=shared_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 684, in _variable_v2
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
original_op=self._default_original_op, op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1139, in _do_call
return fn(*args)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1121, in _run_fn
status, run_metadata)
File "D:\anaconda3\lib\contextlib.py", line 88, in exit
next(self.gen)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/smyrniou/dcgan-master/main.py", line 145, in
tf.app.run()
File "D:\anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "C:/Users/smyrniou/dcgan-master/main.py", line 85, in main
tl.layers.initialize_global_variables(sess)
File "C:\Users\smyrniou\dcgan-master\tensorlayer\layers.py", line 237, in initialize_global_variables
sess.run(tf.initialize_all_variables())
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 789, in run
run_metadata_ptr)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "D:\anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

Caused by op 'generator/g/h4/decon2d/b_deconv2d/Adam_1', defined at:
File "C:/Users/smyrniou/dcgan-master/main.py", line 145, in
tf.app.run()
File "D:\anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "C:/Users/smyrniou/dcgan-master/main.py", line 82, in main
.minimize(g_loss, var_list=g_vars)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 325, in minimize
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 446, in apply_gradients
self._create_slots([_get_variable_for(v) for v in var_list])
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\adam.py", line 129, in _create_slots
self._zeros_slot(v, "v", self._name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 766, in _zeros_slot
named_slots[_var_key(var)] = slot_creator.create_zeros_slot(var, op_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 174, in create_zeros_slot
colocate_with_primary=colocate_with_primary)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 146, in create_slot_with_initializer
dtype)
File "D:\anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 66, in _create_slot_var
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1065, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 962, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 367, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 352, in _true_getter
use_resource=use_resource)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 725, in _get_single_variable
validate_shape=validate_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 200, in init
expected_shape=expected_shape)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 284, in _init_from_args
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\state_ops.py", line 128, in variable_op_v2
shared_name=shared_name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 684, in _variable_v2
name=name)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
original_op=self._default_original_op, op_def=op_def)
File "D:\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'generator/g/h4/decon2d/b_deconv2d/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device.
[[Node: generator/g/h4/decon2d/b_deconv2d/Adam_1 = VariableV2_class=["loc:@generator/g/h4/decon2d/b_deconv2d"], container="", dtype=DT_FLOAT, shape=[3], shared_name="", _device="/device:GPU:0"]]

@wagamamaz
Copy link

What is your TensorFlow and TensorLayer version?

@jkraybill
Copy link

I had this error; I was using a non-GPU build of Tensorflow. Make sure you install tensorflow-gpu or use a build with GPU support.

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