diff --git a/sky/backends/backend_utils.py b/sky/backends/backend_utils.py index 9986f93275a..d76c3fc80c5 100644 --- a/sky/backends/backend_utils.py +++ b/sky/backends/backend_utils.py @@ -882,6 +882,9 @@ def write_cluster_config( f'open(os.path.expanduser("{constants.SKY_REMOTE_RAY_PORT_FILE}"), "w", encoding="utf-8"))\'' ) + conda_auto_activate = ('true' if to_provision.extract_docker_image() is None + else 'false') + # Use a tmp file path to avoid incomplete YAML file being re-used in the # future. tmp_yaml_path = yaml_path + '.tmp' @@ -917,7 +920,7 @@ def write_cluster_config( # Conda setup 'conda_installation_commands': - constants.CONDA_INSTALLATION_COMMANDS, + constants.CONDA_INSTALLATION_COMMANDS(conda_auto_activate), # We should not use `.format`, as it contains '{}' as the bash # syntax. 'ray_skypilot_installation_commands': diff --git a/sky/provision/docker_utils.py b/sky/provision/docker_utils.py index e989fbc085a..7bfa1724b83 100644 --- a/sky/provision/docker_utils.py +++ b/sky/provision/docker_utils.py @@ -110,8 +110,8 @@ def docker_start_cmds( '--cap-add=SYS_ADMIN', '--device=/dev/fuse', '--security-opt=apparmor:unconfined', + '--entrypoint=/bin/bash', image, - 'bash', ] return ' '.join(docker_run) diff --git a/sky/skylet/constants.py b/sky/skylet/constants.py index 30820a3a91e..93dfd8b72ca 100644 --- a/sky/skylet/constants.py +++ b/sky/skylet/constants.py @@ -126,7 +126,9 @@ # https://github.com/ray-project/ray/issues/31606 # We use python 3.10 to be consistent with the python version of the # AWS's Deep Learning AMI's default conda environment. -CONDA_INSTALLATION_COMMANDS = ( +# Using lambda instead of str.format() since there are multiple {} in the +# installation commands and we only want to replace some of them. +CONDA_INSTALLATION_COMMANDS = lambda conda_auto_activate: ( 'which conda > /dev/null 2>&1 || ' '{ curl https://repo.anaconda.com/miniconda/Miniconda3-py310_23.11.0-2-Linux-x86_64.sh -o Miniconda3-Linux-x86_64.sh && ' # pylint: disable=line-too-long # We do not use && for installation of conda and the following init commands @@ -135,8 +137,8 @@ # true. '{ bash Miniconda3-Linux-x86_64.sh -b; ' 'eval "$(~/miniconda3/bin/conda shell.bash hook)" && conda init && ' - 'conda config --set auto_activate_base true && ' - f'conda activate base; }}; }}; ' + f'conda config --set auto_activate_base {conda_auto_activate} && ' + 'conda activate base; }; }; ' 'grep "# >>> conda initialize >>>" ~/.bashrc || ' '{ conda init && source ~/.bashrc; };' # If Python version is larger then equal to 3.12, create a new conda env @@ -145,7 +147,7 @@ # costly to create a new conda env, and venv should be a lightweight and # faster alternative when the python version satisfies the requirement. '[[ $(python3 --version | cut -d " " -f 2 | cut -d "." -f 2) -ge 12 ]] && ' - f'echo "Creating conda env with Python 3.10" && ' + 'echo "Creating conda env with Python 3.10" && ' f'conda create -y -n {SKY_REMOTE_PYTHON_ENV_NAME} python=3.10 && ' f'conda activate {SKY_REMOTE_PYTHON_ENV_NAME};' # Create a separate conda environment for SkyPilot dependencies. diff --git a/sky/skylet/providers/command_runner.py b/sky/skylet/providers/command_runner.py index 06c5d6d48af..4f66ef54383 100644 --- a/sky/skylet/providers/command_runner.py +++ b/sky/skylet/providers/command_runner.py @@ -65,8 +65,8 @@ def docker_start_cmds( '--cap-add=SYS_ADMIN', '--device=/dev/fuse', '--security-opt=apparmor:unconfined', + '--entrypoint=/bin/bash', image, - 'bash', ] return ' '.join(docker_run)