Skip to content

[BE][CD] Always build small wheels for CUDA Linux and remove CUDA 12.8/12.9 - #180612

Closed
atalman wants to merge 2 commits into
pytorch:mainfrom
atalman:be_cuda_build
Closed

atalman wants to merge 2 commits into
pytorch:mainfrom
atalman:be_cuda_build

Conversation

@atalman

@atalman atalman commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • CUDA Linux wheel builds now always use nvidia libs from pypi (small wheels) instead of conditionally bundling CUDA shared libraries into the wheel
  • Removed the PYTORCH_EXTRA_INSTALL_REQUIREMENTS check from build_cuda.sh and the entire large-wheel bundling code path (~90 lines of DEPS_LIST/DEPS_SONAME entries for cudnn, cublas, nvrtc, cupti, etc.)
  • Static linking flags (USE_STATIC_CUDNN, USE_STATIC_NCCL, ATEN_STATIC_CUDA, USE_CUDA_STATIC_LINK) default to 0; USE_CUPTI_SO defaults to 1
  • Removed CUDA 12.8 and 12.9 from the TORCH_CUDA_ARCH_LIST case statement as these versions are no longer shipped

Note: PYTORCH_EXTRA_INSTALL_REQUIREMENTS is still used in setup.py, generate_binary_build_matrix.py, binary_populate_env.sh, and workflow templates to define and propagate pip install requirements — only the build_cuda.sh branching on it is removed.

Test plan

  • Verify CUDA 12.6 manywheel build succeeds with small wheel RPATHs
  • Verify CUDA 13.0/13.2 manywheel builds succeed
  • Verify wheel installs correctly and finds nvidia pypi packages at runtime
  • Confirm CUDA 12.8/12.9 builds are not triggered in CI matrix

CUDA Linux wheel builds now always use nvidia libs from pypi (small
wheels) instead of conditionally bundling CUDA shared libraries. This
removes the PYTORCH_EXTRA_INSTALL_REQUIREMENTS check from build_cuda.sh
and the entire large-wheel bundling code path (~90 lines of DEPS_LIST
entries). Static linking flags are set to 0 by default since we no
longer need the bundling path.

Also removes CUDA 12.8 and 12.9 from the CUDA arch version case
statement as these versions are no longer shipped.

Authored with Claude.
@atalman
atalman requested a review from a team as a code owner April 16, 2026 22:14
@pytorch-bot

pytorch-bot Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/180612

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 3 Cancelled Jobs

As of commit dd654ec with merge base 5c3f8fd (image):

NEW FAILURE - The following job has failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot

pytorch-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@atalman atalman added the ciflow/binaries Trigger all binary build and upload jobs on the PR label Apr 16, 2026
if [[ $CUDA_VERSION == 13* ]]; then
export TORCH_NVCC_FLAGS="$TORCH_NVCC_FLAGS -compress-mode=size"
fi
if [[ -z "$PYTORCH_EXTRA_INSTALL_REQUIREMENTS" ]]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If one expect to always have it defined, I would probably error out, probably at the start of the script

Address review feedback: since CUDA wheels now always depend on nvidia
pypi packages, fail fast at the start of build_cuda.sh if
PYTORCH_EXTRA_INSTALL_REQUIREMENTS is not defined rather than silently
producing a wheel with missing runtime dependencies.

Authored with Claude.
@atalman

atalman commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "all looks good"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorch-bot

pytorch-bot Bot commented Apr 20, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
…8/12.9 (pytorch#180612)

 ## Summary

  - CUDA Linux wheel builds now always use nvidia libs from pypi (small wheels) instead of conditionally bundling CUDA shared libraries into the wheel
  - Removed the PYTORCH_EXTRA_INSTALL_REQUIREMENTS check from build_cuda.sh and the entire large-wheel bundling code path (~90 lines of DEPS_LIST/DEPS_SONAME entries for cudnn, cublas, nvrtc, cupti, etc.)
  - Static linking flags (USE_STATIC_CUDNN, USE_STATIC_NCCL, ATEN_STATIC_CUDA, USE_CUDA_STATIC_LINK) default to 0; USE_CUPTI_SO defaults to 1
  - Removed CUDA 12.8 and 12.9 from the TORCH_CUDA_ARCH_LIST case statement as these versions are no longer shipped

  Note: PYTORCH_EXTRA_INSTALL_REQUIREMENTS is still used in setup.py, generate_binary_build_matrix.py, binary_populate_env.sh, and workflow templates to define and propagate pip install requirements — only the build_cuda.sh branching on it is removed.

  ## Test plan

  - Verify CUDA 12.6 manywheel build succeeds with small wheel RPATHs
  - Verify CUDA 13.0/13.2 manywheel builds succeed
  - Verify wheel installs correctly and finds nvidia pypi packages at runtime
  - Confirm CUDA 12.8/12.9 builds are not triggered in CI matrix
Pull Request resolved: pytorch#180612
Approved by: https://github.com/malfet
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…8/12.9 (pytorch#180612)

 ## Summary

  - CUDA Linux wheel builds now always use nvidia libs from pypi (small wheels) instead of conditionally bundling CUDA shared libraries into the wheel
  - Removed the PYTORCH_EXTRA_INSTALL_REQUIREMENTS check from build_cuda.sh and the entire large-wheel bundling code path (~90 lines of DEPS_LIST/DEPS_SONAME entries for cudnn, cublas, nvrtc, cupti, etc.)
  - Static linking flags (USE_STATIC_CUDNN, USE_STATIC_NCCL, ATEN_STATIC_CUDA, USE_CUDA_STATIC_LINK) default to 0; USE_CUPTI_SO defaults to 1
  - Removed CUDA 12.8 and 12.9 from the TORCH_CUDA_ARCH_LIST case statement as these versions are no longer shipped

  Note: PYTORCH_EXTRA_INSTALL_REQUIREMENTS is still used in setup.py, generate_binary_build_matrix.py, binary_populate_env.sh, and workflow templates to define and propagate pip install requirements — only the build_cuda.sh branching on it is removed.

  ## Test plan

  - Verify CUDA 12.6 manywheel build succeeds with small wheel RPATHs
  - Verify CUDA 13.0/13.2 manywheel builds succeed
  - Verify wheel installs correctly and finds nvidia pypi packages at runtime
  - Confirm CUDA 12.8/12.9 builds are not triggered in CI matrix
Pull Request resolved: pytorch#180612
Approved by: https://github.com/malfet
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…8/12.9 (pytorch#180612)

 ## Summary

  - CUDA Linux wheel builds now always use nvidia libs from pypi (small wheels) instead of conditionally bundling CUDA shared libraries into the wheel
  - Removed the PYTORCH_EXTRA_INSTALL_REQUIREMENTS check from build_cuda.sh and the entire large-wheel bundling code path (~90 lines of DEPS_LIST/DEPS_SONAME entries for cudnn, cublas, nvrtc, cupti, etc.)
  - Static linking flags (USE_STATIC_CUDNN, USE_STATIC_NCCL, ATEN_STATIC_CUDA, USE_CUDA_STATIC_LINK) default to 0; USE_CUPTI_SO defaults to 1
  - Removed CUDA 12.8 and 12.9 from the TORCH_CUDA_ARCH_LIST case statement as these versions are no longer shipped

  Note: PYTORCH_EXTRA_INSTALL_REQUIREMENTS is still used in setup.py, generate_binary_build_matrix.py, binary_populate_env.sh, and workflow templates to define and propagate pip install requirements — only the build_cuda.sh branching on it is removed.

  ## Test plan

  - Verify CUDA 12.6 manywheel build succeeds with small wheel RPATHs
  - Verify CUDA 13.0/13.2 manywheel builds succeed
  - Verify wheel installs correctly and finds nvidia pypi packages at runtime
  - Confirm CUDA 12.8/12.9 builds are not triggered in CI matrix
Pull Request resolved: pytorch#180612
Approved by: https://github.com/malfet
tinglvv added a commit that referenced this pull request Jul 29, 2026
Fixes the "libnvshmem_host.so.3 => not found" regression (#183971)
in the CUDA libtorch shared-with-deps tarball.

Root cause: libtorch is now assembled by extracting torch/lib/ from the pip
wheel (#174753). The wheel is a "small wheel" (#180612): its NVIDIA runtime
deps -- libnvshmem_host.so.3, libcudart.so.13, libcublas, libcudnn, ... -- are
not in torch/lib/ but supplied at runtime by the pip nvidia-* packages via an
RPATH into site-packages/nvidia/*/lib. The libtorch tarball has no such
packages, so the extracted libtorch/lib/ shipped torch's own libtorch_nvshmem.so
(which hard-NEEDs libnvshmem_host.so.3) with nothing to satisfy it.

Fix: for linux CUDA shared-with-deps, bundle_cuda_deps() copies the required
NVIDIA runtime libraries into libtorch/lib/ before the RPATH rewrite. It
resolves NEEDED entries transitively starting from the torch libs, copying any
soname that exists under the CUDA toolkit dirs in the builder container
(/usr/local/cuda/lib64 and the CUPTI dir). Only libraries found there are
copied, so base system libs and the driver stub (libcuda.so.1) are correctly
left to the runtime environment. fix_rpath() then stamps $ORIGIN on the copied
libs so the flat lib/ is self-resolving. This restores the pre-#180612
self-contained tarball while leaving the pip wheel untouched/small.

Chose a transitive NEEDED resolver over reinstating the old hardcoded DEPS_LIST
so it auto-adapts to CUDA version and the static->dynamic linking changes, and
self-filters system libs by construction.

smoke_test_extract_libtorch.py gains check_regression_deps(): if a consumer lib
is present (libtorch_nvshmem.so / libtorch_cuda.so), its NVIDIA runtime dep
(libnvshmem_host.so* / libcudart.so*) must be bundled -- a direct guard against
this regression recurring.

Test Plan:
Local static checks (no CUDA builder / wheel available on this host):

```
python3 -m py_compile .ci/libtorch/extract_libtorch_from_wheel.py
python3 -m py_compile .ci/libtorch/smoke_test_extract_libtorch.py
```

Full validation is the libtorch-extract CI job on a CUDA config: the log should
show "Bundled CUDA dep: libnvshmem_host.so.3 ..." (plus cudart/cublas/cudnn),
the smoke test's check_regression_deps must pass, and `ldd libtorch_nvshmem.so`
on the extracted tree must not report libnvshmem_host.so.3 as not found.

Authored with assistance from an AI coding assistant (Claude).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tinglvv added a commit that referenced this pull request Jul 29, 2026
Fixes the "libnvshmem_host.so.3 => not found" regression (#183971)
in the CUDA libtorch shared-with-deps tarball.

Root cause: libtorch is now assembled by extracting torch/lib/ from the pip
wheel (#174753). The wheel is a "small wheel" (#180612): its NVIDIA runtime
deps -- libnvshmem_host.so.3, libcudart.so.13, libcublas, libcudnn, ... -- are
not in torch/lib/ but supplied at runtime by the pip nvidia-* packages via an
RPATH into site-packages/nvidia/*/lib. The libtorch tarball has no such
packages, so the extracted libtorch/lib/ shipped torch's own libtorch_nvshmem.so
(which hard-NEEDs libnvshmem_host.so.3) with nothing to satisfy it.

Fix: for linux CUDA shared-with-deps, bundle_cuda_deps() copies the required
NVIDIA runtime libraries into libtorch/lib/ before the RPATH rewrite. It
resolves NEEDED entries transitively starting from the torch libs, copying any
soname that exists under the CUDA toolkit dirs in the builder container
(/usr/local/cuda/lib64 and the CUPTI dir). Only libraries found there are
copied, so base system libs and the driver stub (libcuda.so.1) are correctly
left to the runtime environment. fix_rpath() then stamps $ORIGIN on the copied
libs so the flat lib/ is self-resolving. This restores the pre-#180612
self-contained tarball while leaving the pip wheel untouched/small.

Chose a transitive NEEDED resolver over reinstating the old hardcoded DEPS_LIST
so it auto-adapts to CUDA version and the static->dynamic linking changes, and
self-filters system libs by construction.

smoke_test_extract_libtorch.py: now that the deps are bundled, restore the full
ctypes.CDLL("libtorch.so") load in check_load() -- it resolves the entire NEEDED
chain through the $ORIGIN RPATH, so a missing or mis-rpath'd bundled lib fails
the test. This was previously removed (it failed on CUDA when deps were not
bundled); with bundling it works, and since libcuda.so.1 is dlopen'd lazily by
cudart (not a load-time NEEDED) it succeeds on a driverless builder.
check_regression_deps() is kept as a fast, explicit guard with a clear message
if a consumer lib (libtorch_nvshmem.so / libtorch_cuda.so) is present without
its bundled NVIDIA runtime dep.

Test Plan:
Local static checks (no CUDA builder / wheel available on this host):

```
python3 -m py_compile .ci/libtorch/extract_libtorch_from_wheel.py
python3 -m py_compile .ci/libtorch/smoke_test_extract_libtorch.py
```

Full validation is the libtorch-extract CI job on a CUDA config: the log should
show "Bundled CUDA dep: libnvshmem_host.so.3 ..." (plus cudart/cublas/cudnn),
and the smoke test's check_load must load libtorch.so with no "not found".

Authored with assistance from an AI coding assistant (Claude).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tinglvv added a commit that referenced this pull request Jul 29, 2026
Fixes the "libnvshmem_host.so.3 => not found" regression (#183971)
in the CUDA libtorch shared-with-deps tarball.

Root cause: libtorch is now assembled by extracting torch/lib/ from the pip
wheel (#174753). The wheel is a "small wheel" (#180612): its NVIDIA runtime
deps -- libnvshmem_host.so.3, libcudart.so.13, libcublas, libcudnn, ... -- are
not in torch/lib/ but supplied at runtime by the pip nvidia-* packages via an
RPATH into site-packages/nvidia/*/lib. The libtorch tarball has no such
packages, so the extracted libtorch/lib/ shipped torch's own libtorch_nvshmem.so
(which hard-NEEDs libnvshmem_host.so.3) with nothing to satisfy it.

Fix: for linux CUDA shared-with-deps, bundle_cuda_deps() copies the required
NVIDIA runtime libraries into libtorch/lib/ before the RPATH rewrite. It
resolves NEEDED entries transitively starting from the torch libs, copying any
soname that exists under the CUDA toolkit dirs in the builder container
(/usr/local/cuda/lib64 and the CUPTI dir). Only libraries found there are
copied, so base system libs and the driver stub (libcuda.so.1) are correctly
left to the runtime environment. fix_rpath() then stamps $ORIGIN on the copied
libs so the flat lib/ is self-resolving. This restores the pre-#180612
self-contained tarball while leaving the pip wheel untouched/small.

Chose a transitive NEEDED resolver over reinstating the old hardcoded DEPS_LIST
so it auto-adapts to CUDA version and the static->dynamic linking changes, and
self-filters system libs by construction.

smoke_test_extract_libtorch.py is a single ctypes.CDLL("libtorch.so") load: it
resolves the whole NEEDED chain through the $ORIGIN RPATH, so a missing or
mis-rpath'd bundled dep (torch or NVIDIA runtime) fails the test. Full dlopen
was previously dropped because it failed when deps were not bundled; with
bundling it works, and since libcuda.so.1 is dlopen'd lazily by cudart (not a
load-time NEEDED) it succeeds on a driverless builder.

Test Plan:
Local static checks (no CUDA builder / wheel available on this host):

```
python3 -m py_compile .ci/libtorch/extract_libtorch_from_wheel.py
python3 -m py_compile .ci/libtorch/smoke_test_extract_libtorch.py
```

Full validation is the libtorch-extract CI job on a CUDA config: the log should
show "Bundled CUDA dep: libnvshmem_host.so.3 ..." (plus cudart/cublas/cudnn),
and the smoke test must load libtorch.so with no "not found".

Authored with assistance from an AI coding assistant (Claude).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tinglvv added a commit that referenced this pull request Jul 29, 2026
Fixes the "libnvshmem_host.so.3 => not found" regression (#183971)
in the CUDA libtorch shared-with-deps tarball.

Root cause: libtorch is now assembled by extracting torch/lib/ from the pip
wheel (#174753). The wheel is a "small wheel" (#180612): its NVIDIA runtime
deps -- libnvshmem_host.so.3, libcudart.so.13, libcublas, libcudnn, ... -- are
not in torch/lib/ but supplied at runtime by the pip nvidia-* packages via an
RPATH into site-packages/nvidia/*/lib. The libtorch tarball has no such
packages, so the extracted libtorch/lib/ shipped torch's own libtorch_nvshmem.so
(which hard-NEEDs libnvshmem_host.so.3) with nothing to satisfy it.

Fix: for linux CUDA shared-with-deps, bundle_cuda_deps() copies the required
NVIDIA runtime libraries into libtorch/lib/ before the RPATH rewrite. It
resolves NEEDED entries transitively starting from the torch libs, copying any
soname that exists under the CUDA toolkit dirs in the builder container
(/usr/local/cuda/lib64 and the CUPTI dir). Only libraries found there are
copied, so base system libs and the driver stub (libcuda.so.1) are correctly
left to the runtime environment. fix_rpath() then stamps $ORIGIN on the copied
libs so the flat lib/ is self-resolving. This restores the pre-#180612
self-contained tarball while leaving the pip wheel untouched/small.

Chose a transitive NEEDED resolver over reinstating the old hardcoded DEPS_LIST
so it auto-adapts to CUDA version and the static->dynamic linking changes, and
self-filters system libs by construction.

smoke_test_extract_libtorch.py is a single ctypes.CDLL("libtorch.so") load: it
resolves the whole NEEDED chain through the $ORIGIN RPATH, so a missing or
mis-rpath'd bundled dep (torch or NVIDIA runtime) fails the test. Full dlopen
was previously dropped because it failed when deps were not bundled; with
bundling it works, and since libcuda.so.1 is dlopen'd lazily by cudart (not a
load-time NEEDED) it succeeds on a driverless builder.

Test Plan:
Local static checks (no CUDA builder / wheel available on this host):

```
python3 -m py_compile .ci/libtorch/extract_libtorch_from_wheel.py
python3 -m py_compile .ci/libtorch/smoke_test_extract_libtorch.py
```

Full validation is the libtorch-extract CI job on a CUDA config: the log should
show "Bundled CUDA dep: libnvshmem_host.so.3 ..." (plus cudart/cublas/cudnn),
and the smoke test must load libtorch.so with no "not found".

Authored with assistance from an AI coding assistant (Claude).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries Trigger all binary build and upload jobs on the PR Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants