tensorflow / tensorflow/recommenders
Basic retrieval model training with `MultiWorkerMirroredStrategy` encountered `Cannot assign a device for operation` error.
Open
@maciejkula is already working on this.
Since Dec 21, 2020.
question
- Dominant language
- Python
- Stars
- 2k
- Forks
- 300
- PR merge metrics
- No merged PRs in 30d
Description
I modified the basic retrieval model to distributed training using MultiWorkerMirroredStrategy .
When using CPU, the training worked normally. But when using GPU, the following error occured
Traceback (most recent call last):
File "/mnt/tfrs/retrieval-dist-training.py", line 110, in <module>
model.fit(cached_train, steps_per_epoch=(80_000//args.batch_size), epochs=1, callbacks=[tensorboard_callback])
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 117, in _method_wrapper
mode=dc.CoordinatorMode.INDEPENDENT_WORKER)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_coordinator.py", line 860, in run_distribute_coordinator
task_id, session_config, rpc_layer)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_coordinator.py", line 360, in _run_single_worker
return worker_fn(strategy)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 115, in <lambda>
lambda _: method(self, *args, **kwargs),
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 1098, in fit
tmp_logs = train_function(iterator)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py", line 780, in __call__
result = self._call(*args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py", line 840, in _call
return self._stateless_fn(*args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 2829, in __call__
return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 1848, in _filtered_call
cancellation_manager=cancellation_manager)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 1924, in _call_flat
ctx, args, cancellation_manager=cancellation_manager))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 550, in call
ctx=ctx)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py", line 60, in quick_execute
inputs, attrs, num_outputs)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation sequential/embedding/embedding_lookup/ReadVariableOp: Could not satisfy explicit device specification '' because the node {{colocation_node sequential/embedding/embedding_lookup/ReadVariableOp}} was colocated with a group of nodes that required incompatible device '/job:worker/replica:0/task:0/device:GPU:0'. All available devices [/job:worker/replica:0/task:0/device:CPU:0, /job:worker/replica:0/task:0/device:XLA_CPU:0, /job:worker/replica:0/task:0/device:XLA_GPU:0, /job:worker/replica:0/task:0/device:GPU:0].
Colocation Debug Info:
Colocation group had the following types and supported devices:
Root Member(assigned_device_name_index_=2 requested_device_name_='/job:worker/replica:0/task:0/device:GPU:0' assigned_device_name_='/job:worker/replica:0/task:0/device:GPU:0' resource_device_name_='/job:worker/replica:0/task:0/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[]
GatherV2: GPU CPU XLA_CPU XLA_GPU
Cast: GPU CPU XLA_CPU XLA_GPU
Const: GPU CPU XLA_CPU XLA_GPU
ResourceSparseApplyAdagradV2: CPU
_Arg: GPU CPU XLA_CPU XLA_GPU
ReadVariableOp: GPU CPU XLA_CPU XLA_GPU
Colocation members, user-requested devices, and framework assigned devices, if any:
sequential_embedding_embedding_lookup_readvariableop_resource (_Arg) framework assigned device=/job:worker/replica:0/task:0/device:GPU:0
adagrad_adagrad_update_1_update_0_resourcesparseapplyadagradv2_accum (_Arg) framework assigned device=/job:worker/replica:0/task:0/device:GPU:0
sequential/embedding/embedding_lookup/ReadVariableOp (ReadVariableOp)
sequential/embedding/embedding_lookup/axis (Const)
sequential/embedding/embedding_lookup (GatherV2)
gradient_tape/sequential/embedding/embedding_lookup/Shape (Const)
gradient_tape/sequential/embedding/embedding_lookup/Cast (Cast)
Adagrad/Adagrad/update_1/update_0/ResourceSparseApplyAdagradV2 (ResourceSparseApplyAdagradV2) /job:worker/replica:0/task:0/device:GPU:0
[[{{node sequential/embedding/embedding_lookup/ReadVariableOp}}]] [Op:__inference_train_function_2217]
2020-12-16 07:27:46.265579: W tensorflow/core/common_runtime/eager/context.cc:566] Unable to destroy server_ object, so releasing instead. Servers don't support clean shutdown.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.