常见问题#

Git 和 GitHub#

如何在任务的setup命令中克隆私有的GitHub仓库?#

这是可能的,前提是你已经设置了SSH代理转发。 例如,在你的笔记本电脑上运行以下命令:

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

然后,从这台机器启动的任何SkyPilot集群都将能够克隆私有的GitHub仓库。例如:

# your_task.yaml
setup: |
  git clone [email protected]:your-proj/your-repo.git

注意:目前,在run命令中克隆私有仓库还不被支持。

如何确保我的工作目录的 .git 在托管点作业中同步?#

目前,根据使用的命令,.git 是否同步存在差异:

  • 对于常规的sky launch,工作目录的.git默认是同步的。

  • 对于托管作业 sky jobs launch,工作目录的 .git 默认被排除。

在第二种情况下,为了确保工作目录的 .git 对于托管点作业是同步的,你可以显式地添加一个文件挂载来同步它:

workdir: .
file_mounts:
  ~/sky_workdir/.git: .git

如果你的工作使用某些依赖于.git目录来跟踪代码更改的实验跟踪工具,这可能会有用。

文件挂载 (file_mounts)#

如何让SkyPilot集群使用我的Weights & Biases凭证?#

在您的笔记本电脑上安装wandb库,并通过wandb login登录到您的账户。 然后,在您的任务yaml文件中添加以下行:

file_mounts:
  ~/.netrc: ~/.netrc

如何将附加文件挂载到克隆的仓库中?#

如果你想将额外的文件挂载到一个将被git clone的路径中(无论是在setup还是run中),克隆将会失败并抱怨目标路径不为空:

file_mounts:
  ~/code-repo/tmp.txt: ~/tmp.txt
setup: |
  # Fail! Git will complain the target dir is not empty:
  #    fatal: destination path 'code-repo' already exists and is not an empty directory.
  # This is because file_mounts are processed before `setup`.
  git clone [email protected]:your-id/your-repo.git ~/code-repo/

为了解决这个问题,将文件挂载到不同的路径,然后创建符号链接。例如:

file_mounts:
  /tmp/tmp.txt: ~/tmp.txt
setup: |
  git clone [email protected]:your-id/your-repo.git ~/code-repo/
  ln -s /tmp/tmp.txt ~/code-repo/

如何在不重新运行setup的情况下更新现有集群的file_mounts#

如果您已经编辑了file_mounts部分(例如,通过添加一些文件),并希望它反映在现有的集群上,运行sky launch -c ..会起作用,但它会重新运行setup命令。

为了避免重新运行setup命令,可以向sky launch传递--no-setup标志。

区域设置#

如何仅在部分区域(例如仅在欧洲)启动虚拟机?#

在定义任务时,您可以使用resources.any_of字段来指定您希望启动虚拟机的区域集合。

例如,为了仅在欧洲启动虚拟机(这有助于符合GDPR合规性),您可以使用以下任务定义:

resources:
  # SkyPilot will perform cost optimization among the specified regions.
  any_of:
    # AWS:
    - region: eu-central-1
    - region: eu-west-1
    - region: eu-west-2
    - region: eu-west-3
    - region: eu-north-1
    # GCP:
    - region: europe-central2
    - region: europe-north1
    - region: europe-southwest1
    - region: europe-west1
    - region: europe-west10
    - region: europe-west12
    - region: europe-west2
    - region: europe-west3
    - region: europe-west4
    - region: europe-west6
    - region: europe-west8
    - region: europe-west9
    # Or put in other clouds' Europe regions.

查看有关 resources.any_of 字段的更多详细信息 这里

(高级) 如何让SkyPilot使用所有全球区域?#

默认情况下,SkyPilot 支持 AWS 上的大多数全球区域,并且仅支持 GCP 和 Azure 上的美国区域。如果您想利用所有全球区域,请运行以下命令:

version=$(python -c 'import sky; print(sky.clouds.service_catalog.constants.CATALOG_SCHEMA_VERSION)')
mkdir -p ~/.sky/catalogs/${version}
cd ~/.sky/catalogs/${version}
# GCP
pip install lxml
# Fetch U.S. regions for GCP
python -m sky.clouds.service_catalog.data_fetchers.fetch_gcp
# Fetch the specified zones for GCP
python -m sky.clouds.service_catalog.data_fetchers.fetch_gcp --zones northamerica-northeast1-a us-east1-b us-east1-c
# Fetch U.S. zones for GCP, excluding the specified zones
python -m sky.clouds.service_catalog.data_fetchers.fetch_gcp --exclude us-east1-a us-east1-b
# Fetch all regions for GCP
python -m sky.clouds.service_catalog.data_fetchers.fetch_gcp --all-regions
# Run in single-threaded mode. This is useful when multiple processes don't work well with the GCP client due to SSL issues.
python -m sky.clouds.service_catalog.data_fetchers.fetch_gcp --single-threaded

# Azure
# Fetch U.S. regions for Azure
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure
# Fetch all regions for Azure
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure --all-regions
# Run in single-threaded mode. This is useful when multiple processes don't work well with the Azure client due to SSL issues.
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure --single-threaded
# Fetch the specified regions for Azure
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure --regions japaneast australiaeast uksouth
# Fetch U.S. regions for Azure, excluding the specified regions
python -m sky.clouds.service_catalog.data_fetchers.fetch_azure --exclude centralus eastus

为了使您的托管点作业可能使用所有全球区域,请使用ssh sky-spot-controller-登录到点控制器 (完整名称可以在sky status中找到),并运行上述命令。

(高级) 如何编辑或更新SkyPilot使用的区域或定价信息?#

SkyPilot 将不同云资源类型的区域和定价信息存储在称为 “服务目录”的CSV文件中。 这些目录被缓存在 ~/.sky/catalogs// 目录中。 通过运行以下命令检查您的架构版本:

python -c "from sky.clouds import service_catalog; print(service_catalog.CATALOG_SCHEMA_VERSION)"

您可以根据需要自定义目录文件。 例如,如果您可以访问GCP的特殊区域,请将数据添加到~/.sky/catalogs//gcp.csv。 此外,您可以通过删除CSV文件来更新特定云的目录(例如,rm ~/.sky/catalogs//gcp.csv)。 SkyPilot将在下次运行时自动下载最新的目录。

包安装#

无法在SkyPilot任务中导入PyTorch。#

对于PyTorch的安装,如果您使用的是默认的SkyPilot镜像(没有传入–image-id),pip install torch应该可以正常工作。

但如果你使用自己的镜像,该镜像具有较旧的NVIDIA驱动程序(535.161.08或更低),并且你安装了默认的PyTorch,你可能会遇到以下错误:

ImportError: /home/azureuser/miniconda3/lib/python3.10/site-packages/torch/lib/../../nvidia/cusparse/lib/libcusparse.so.12: undefined symbol: __nvJitLinkComplete_12_4, version libnvJitLink.so.12

你需要安装一个与你的NVIDIA驱动程序兼容的PyTorch版本,例如 pip install torch --index-url https://download.pytorch.org/whl/cu121

杂项#

如何使用SkyPilot任务定义启动VS Code隧道?#

要使用SkyPilot任务定义启动VS Code隧道,您可以使用以下任务定义:

setup: |
  sudo snap install --classic code
  # if `snap` is not available, you can try the following commands instead:
  # wget https://go.microsoft.com/fwlink/?LinkID=760868 -O vscode.deb
  # sudo apt install ./vscode.deb -y
  # rm vscode.deb
run: |
  code tunnel --accept-server-license-terms

请注意,您将被提示使用您的GitHub账户进行身份验证以启动VS Code隧道。