Skip to content
Closed
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
11 changes: 10 additions & 1 deletion build_tools/github_actions/write_torch_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os
import glob
import platform
from packaging.version import parse
from github_actions_utils import *


Expand Down Expand Up @@ -89,7 +90,15 @@ def get_all_wheel_versions(
elif os.lower() == "windows":
_log("Did not find apex (that's okay, is not currently built on Windows)")
else:
raise FileNotFoundError("Did not find apex wheel")
# Apex is only built for torch >= 2.10 and disabled otherwise until #3413 is resolved
torch_version_parsed = parse(torch_version)
is_torch_less_than_2_10 = torch_version_parsed.release[:2] < (2, 10)
if is_torch_less_than_2_10:
_log(
"Did not find apex (that's okay, apex is not built for torch versions < 2.10 on linux)"
)
else:
raise FileNotFoundError("Did not find apex wheel")

return all_versions

Expand Down
22 changes: 22 additions & 0 deletions external-builds/pytorch/build_prod_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,28 @@ def do_build(args: argparse.Namespace):
print("--- Not build pytorch-vision (no --pytorch-vision-dir)")

# Build apex.
# Changed default behavior:
# Only build apex for torch 2.10 and disable otherwise until #3413 is resolved
# changes were also needed in: build_tools/github_actions/write_torch_versions.py
if args.build_apex is None and apex_dir:
if pytorch_dir:
# < this is just copied from do_build_pytorch() >
# Compute version.
pytorch_build_version = (pytorch_dir / "version.txt").read_text().strip()
pytorch_build_version += args.version_suffix
pytorch_build_vers_parsed = parse(pytorch_build_version)

is_pytorch_2_10_or_later = pytorch_build_vers_parsed.release[:2] >= (2, 10)

args.build_apex = False
if is_pytorch_2_10_or_later:
args.build_apex = True
else:
print(
f"""WARNING: Cannot determine whether to build apex without pytorch_dir.
Defaulting to building apex."""
)
# remove above if #3413 is resolved
if args.build_apex or (args.build_apex is None and apex_dir):
assert apex_dir, "Must specify --apex-dir if --build-apex"
do_build_apex(args, apex_dir, dict(env))
Expand Down
Loading