Skip to content

Commit 534ffa7

Browse files
authored
Unset CUDA_VISIBLE_DEVICES for worker processes (#122)
* Unset CUDA_VISIBLE_DEVICES for worker processes * Add comments
1 parent 378add5 commit 534ffa7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/sagemaker_tensorflow_container/training.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def _run_ps(env):
107107

108108

109109
def _run_worker(env):
110+
# when _run_ps is called CUDA_VISIBLE_DEVICES is set with os.environ. We need to unset it so the worker
111+
# process can use the GPUs.
112+
if os.environ.get('CUDA_VISIBLE_DEVICES'):
113+
del os.environ['CUDA_VISIBLE_DEVICES']
110114
env_vars = _env_vars_with_tf_config(env, ps_task=False)
111115
framework.entry_point.run(env.module_dir, env.user_entry_point, env.to_cmd_args(), env_vars)
112116

0 commit comments

Comments
 (0)