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

[Setup] unset CUDA_VISIBLE_DEVICES for detach setup #1404

Merged
merged 6 commits into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/env_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ workdir: .
setup: |
echo "here"
echo "export TEST_VAR=test" >> ~/.bashrc
[[ -v CUDA_VISIBLE_DEVICES ]] && exit 1 || exit 0

run: |
if [[ -z "${TEST_VAR}" ]]; then
Expand Down
4 changes: 4 additions & 0 deletions sky/backends/cloud_vm_ray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ def add_prologue(self,
self._code += [
textwrap.dedent(f"""\
_SETUP_CPUS = 0.0001
# Unset CUDA_VISIBLE_DEVICES (set by ray), since the setup command
# may need to detect the number of GPUs on the machine.
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
setup_cmd = 'unset CUDA_VISIBLE_DEVICES; ' + setup_cmd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if user does something like

setup: |
  export CUDA_VISIBLE_DEVICES=1
  python setup_gpu.py

and run sky launch --detach-setup?

It seems like this will unset user's intent.

Copy link
Collaborator Author

@Michaelvll Michaelvll Nov 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it should not, since the unset will happens before the setup script is run, so any command inside the setup script will override it.

Copy link
Collaborator Author

@Michaelvll Michaelvll Nov 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the setting for setting the CUDA_VISIBLE_DEVICES to the test.

Tested:

  • sky launch -c env-check ./examples/env_check.yaml

job_lib.set_status({job_id!r}, job_lib.JobStatus.SETTING_UP)
print({_CTRL_C_TIP_MESSAGE!r}, file=sys.stderr, flush=True)
total_num_nodes = len(ray.nodes())
Expand Down Expand Up @@ -2041,6 +2044,7 @@ def _setup(self, handle: ResourceHandle, task: task_lib.Task,
f.write(setup_script)
f.flush()
setup_sh_path = f.name
print(setup_sh_path)
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
setup_file = os.path.basename(setup_sh_path)
# Sync the setup script up and run it.
ip_list = backend_utils.get_node_ips(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def test_env_check():
test = Test(
'env_check',
[
f'sky launch -y -c {name} examples/env_check.yaml',
f'sky launch -y -c {name} --detach-setup examples/env_check.yaml',
f'sky logs {name} 1 --status', # Ensure the job succeeded.
],
f'sky down -y {name}',
Expand Down