Hi, your class is awesome, but I've been struggling for a few days with an error. I just can't find a way to solve it. I'm using vscode and it occurs because of this line:
for epoch_i in range(epochs):
start_time = time.time()
for batch_i, (source_batch, target_batch) in enumerate(batch_data(X_train, y_train, batch_size)):
_, batch_loss, batch_logits = sess.run([optimizer, loss, logits],
feed_dict = {inputs: source_batch,
outputs: target_batch[:, :-1],
targets: target_batch[:, 1:]})
accuracy = np.mean(batch_logits.argmax(axis=-1) == target_batch[:,1:])
print('Epoch {:3} Loss: {:>6.3f} Accuracy: {:>6.4f} Epoch duration: {:>6.3f}s'.format(epoch_i, batch_loss,
accuracy, time.time() - start_time))
But, of course, without that, I'm not training the model. So, can you please give me an advice to solve it, please?
The error that I get is the following:
Exception has occurred: InvalidArgumentError
Cannot assign a device for operation 'enc_embedding/read': Could not satisfy explicit device specification '' because the node was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'
Colocation Debug Info:
Colocation group had the following types and devices:
VariableV2: GPU CPU
Identity: CPU
Const: GPU CPU
GatherV2: GPU CPU
StridedSlice: GPU CPU
Unique: GPU CPU
Shape: GPU CPU
Cast: GPU CPU
UnsortedSegmentSum: GPU CPU
SparseApplyRMSProp: CPU
Colocation members and user-requested devices:
enc_embedding (VariableV2)
enc_embedding/read (Identity)
embedding_lookup/axis (Const)
embedding_lookup (GatherV2)
optimization/gradients/embedding_lookup_grad/Shape (Const)
optimization/gradients/embedding_lookup_grad/ToInt32 (Cast)
enc_embedding/RMSProp (VariableV2)
enc_embedding/RMSProp_1 (VariableV2)
optimization/RMSProp/update_enc_embedding/Unique (Unique)
optimization/RMSProp/update_enc_embedding/Shape (Shape)
optimization/RMSProp/update_enc_embedding/strided_slice/stack (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_1 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_2 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice (StridedSlice)
optimization/RMSProp/update_enc_embedding/UnsortedSegmentSum (UnsortedSegmentSum)
optimization/RMSProp/update_enc_embedding/SparseApplyRMSProp (SparseApplyRMSProp)
[[{{node enc_embedding/read}} = IdentityT=DT_FLOAT, _class=["loc:@enc_embedding"]]]
Caused by op 'enc_embedding/read', defined at:
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "c:\Users\jorge.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy_main.py", line 45, in
cli.main()
File "c:\Users\jorge.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy/..\debugpy\server\cli.py", line 429, in main
run()
File "c:\Users\jorge.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy/..\debugpy\server\cli.py", line 266, in run_file
runpy.run_path(options.target, run_name=compat.force_str("main"))
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\jorge\Documents\U\2020 1er semestre\Skrit\Práctica.py", line 111, in
input_embedding = tf.Variable(tf.random_uniform((len(char2numX), embed_size), -1.0, 1.0), name='enc_embedding')
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 145, in call
return cls._variable_call(*args, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 141, in _variable_call
aggregation=aggregation)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 120, in
previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 2441, in default_variable_creator
expected_shape=expected_shape, import_scope=import_scope)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 147, in call
return super(VariableMetaclass, cls).call(*args, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 1104, in init
constraint=constraint)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 1266, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 81, in identity
return gen_array_ops.identity(input, name=name)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 3994, in identity
"Identity", input=input, name=name)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3272, in create_op
op_def=op_def)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1768, in init
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'enc_embedding/read': Could not satisfy explicit device specification '' because the node was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'
Colocation Debug Info:
Colocation group had the following types and devices:
VariableV2: GPU CPU
Identity: CPU
Const: GPU CPU
GatherV2: GPU CPU
StridedSlice: GPU CPU
Unique: GPU CPU
Shape: GPU CPU
Cast: GPU CPU
UnsortedSegmentSum: GPU CPU
SparseApplyRMSProp: CPU
Colocation members and user-requested devices:
enc_embedding (VariableV2)
enc_embedding/read (Identity)
embedding_lookup/axis (Const)
embedding_lookup (GatherV2)
optimization/gradients/embedding_lookup_grad/Shape (Const)
optimization/gradients/embedding_lookup_grad/ToInt32 (Cast)
enc_embedding/RMSProp (VariableV2)
enc_embedding/RMSProp_1 (VariableV2)
optimization/RMSProp/update_enc_embedding/Unique (Unique)
optimization/RMSProp/update_enc_embedding/Shape (Shape)
optimization/RMSProp/update_enc_embedding/strided_slice/stack (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_1 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_2 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice (StridedSlice)
optimization/RMSProp/update_enc_embedding/UnsortedSegmentSum (UnsortedSegmentSum)
optimization/RMSProp/update_enc_embedding/SparseApplyRMSProp (SparseApplyRMSProp)
[[{{node enc_embedding/read}} = IdentityT=DT_FLOAT, _class=["loc:@enc_embedding"]]]
File "C:\Users\jorge\Documents\U\2020 1er semestre\Skrit\Práctica.py", line 148, in
targets: target_batch[:, 1:]})