Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 1 addition & 28 deletions .ci/docker/common/install_pytorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,7 @@ install_domains() {
}

install_pytorch_and_domains() {
git clone https://github.com/pytorch/pytorch.git

# Fetch the target commit
pushd pytorch || true
git checkout "${TORCH_VERSION}"
git submodule update --init --recursive

chown -R ci-user .

export _GLIBCXX_USE_CXX11_ABI=1
# Then build and install PyTorch
conda_run python setup.py bdist_wheel
pip_install "$(echo dist/*.whl)"

# Grab the pinned audio and vision commits from PyTorch
TORCHAUDIO_VERSION=release/2.9
export TORCHAUDIO_VERSION
TORCHVISION_VERSION=release/0.24
export TORCHVISION_VERSION

install_domains

popd || true
# Clean up the cloned PyTorch repo to reduce the Docker image size
rm -rf pytorch

# Print sccache stats for debugging
as_ci_user sccache --show-stats
pip_install torch==2.9.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/test/cpu
}

install_pytorch_and_domains
62 changes: 1 addition & 61 deletions .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,67 +51,7 @@ install_domains() {
}

install_pytorch_and_domains() {
pushd .ci/docker || return
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
popd || return

git clone https://github.com/pytorch/pytorch.git

# Fetch the target commit
pushd pytorch || return
git checkout "${TORCH_VERSION}"

local system_name=$(uname)
if [[ "${system_name}" == "Darwin" ]]; then
local platform=$(python -c 'import sysconfig; import platform; v=platform.mac_ver()[0].split(".")[0]; platform=sysconfig.get_platform().split("-"); platform[1]=f"{v}_0"; print("_".join(platform))')
fi
local python_version=$(python -c 'import platform; v=platform.python_version_tuple(); print(f"{v[0]}{v[1]}")')
local torch_release=$(cat version.txt)
local torch_short_hash=${TORCH_VERSION:0:7}
local torch_wheel_path="cached_artifacts/pytorch/executorch/pytorch_wheels/${system_name}/${python_version}"
local torch_wheel_name="torch-${torch_release}%2Bgit${torch_short_hash}-cp${python_version}-cp${python_version}-${platform:-}.whl"

local cached_torch_wheel="https://gha-artifacts.s3.us-east-1.amazonaws.com/${torch_wheel_path}/${torch_wheel_name}"
# Cache PyTorch wheel is only needed on MacOS, Linux CI already has this as part
# of the Docker image
local torch_wheel_not_found=0
if [[ "${system_name}" == "Darwin" ]]; then
pip install "${cached_torch_wheel}" || torch_wheel_not_found=1
else
torch_wheel_not_found=1
fi

# Found no such wheel, we will build it from source then
if [[ "${torch_wheel_not_found}" == "1" ]]; then
echo "No cached wheel found, continue with building PyTorch at ${TORCH_VERSION}"

git submodule update --init --recursive
USE_DISTRIBUTED=1 python setup.py bdist_wheel
pip install "$(echo dist/*.whl)"

# Only AWS runners have access to S3
if command -v aws && [[ -z "${GITHUB_RUNNER:-}" ]]; then
for wheel_path in dist/*.whl; do
local wheel_name=$(basename "${wheel_path}")
echo "Caching ${wheel_name}"
aws s3 cp "${wheel_path}" "s3://gha-artifacts/${torch_wheel_path}/${wheel_name}"
done
fi
else
echo "Use cached wheel at ${cached_torch_wheel}"
fi

# Grab the pinned audio and vision commits from PyTorch
TORCHAUDIO_VERSION=$(cat .github/ci_commit_pins/audio.txt)
export TORCHAUDIO_VERSION
TORCHVISION_VERSION=$(cat .github/ci_commit_pins/vision.txt)
export TORCHVISION_VERSION

install_domains

popd || return
# Print sccache stats for debugging
sccache --show-stats || true
pip install torch==2.9.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/test/cpu
}

build_executorch_runner_buck2() {
Expand Down
Loading