pytorch - ✅(Solved) Fix [CI] Hardcoded jemalloc path in build.sh breaks non-Ubuntu builds [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#180963Fetched 2026-04-22 07:43:18
View on GitHub
Comments
0
Participants
1
Timeline
50
Reactions
0
Author
Participants
Timeline (top)
subscribed ×37labeled ×4mentioned ×4added_to_project_v2 ×1

The jemalloc LD_PRELOAD path in .ci/pytorch/build.sh (line 28) is hardcoded to the Ubuntu-specific location:

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

This path doesn't exist on RHEL, CentOS, Fedora, or other non-Debian distributions where jemalloc is installed at /usr/lib64/libjemalloc.so.2. When the path is wrong, the LD_PRELOAD error message pollutes cmake's CUDA version detection output, causing build failures like:

FindCUDA says CUDA version is 12.8, but the CUDA headers say the version is
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' from LD_PRELOAD
cannot be preloaded (cannot open shared object file): ignored.

This was originally added to mitigate #116289 which has since been closed.

Error Message

FindCUDA says CUDA version is 12.8, but the CUDA headers say the version is ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Root Cause

The jemalloc LD_PRELOAD path in .ci/pytorch/build.sh (line 28) is hardcoded to the Ubuntu-specific location:

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

This path doesn't exist on RHEL, CentOS, Fedora, or other non-Debian distributions where jemalloc is installed at /usr/lib64/libjemalloc.so.2. When the path is wrong, the LD_PRELOAD error message pollutes cmake's CUDA version detection output, causing build failures like:

FindCUDA says CUDA version is 12.8, but the CUDA headers say the version is
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' from LD_PRELOAD
cannot be preloaded (cannot open shared object file): ignored.

This was originally added to mitigate #116289 which has since been closed.

Fix Action

Fix / Workaround

  • Affects any non-Ubuntu CI environment (RHEL, s390x, ARM builds on non-Debian)
  • Currently requires platform-specific workarounds in downstream CI pipelines
  • The LD_PRELOAD error message corrupts cmake output parsing

PR fix notes

PR #180983: [CI] Use portable jemalloc path lookup in build.sh

Description (problem / solution / changelog)

Summary

The jemalloc LD_PRELOAD path in build.sh is hardcoded to /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 which is Ubuntu-specific. On RHEL/CentOS/Fedora, jemalloc is at /usr/lib64/libjemalloc.so.2. When the path doesn't exist, the LD_PRELOAD error message gets mixed into cmake's CUDA version detection, breaking the build:

FindCUDA says CUDA version is 12.8, but the CUDA headers say the version is
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' from LD_PRELOAD
cannot be preloaded

Replaced with a dynamic find lookup that works on any distro. Tested on RHEL 9.6 (/usr/lib64/libjemalloc.so.2) — picks up the correct path. No behavior change on Ubuntu.

Fixes #180963

Changed files

  • .ci/pytorch/build.sh (modified, +4/-1)

Code Example

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

---

FindCUDA says CUDA version is 12.8, but the CUDA headers say the version is
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' from LD_PRELOAD
cannot be preloaded (cannot open shared object file): ignored.
RAW_BUFFERClick to expand / collapse

Description

The jemalloc LD_PRELOAD path in .ci/pytorch/build.sh (line 28) is hardcoded to the Ubuntu-specific location:

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

This path doesn't exist on RHEL, CentOS, Fedora, or other non-Debian distributions where jemalloc is installed at /usr/lib64/libjemalloc.so.2. When the path is wrong, the LD_PRELOAD error message pollutes cmake's CUDA version detection output, causing build failures like:

FindCUDA says CUDA version is 12.8, but the CUDA headers say the version is
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' from LD_PRELOAD
cannot be preloaded (cannot open shared object file): ignored.

This was originally added to mitigate #116289 which has since been closed.

Impact

  • Affects any non-Ubuntu CI environment (RHEL, s390x, ARM builds on non-Debian)
  • Currently requires platform-specific workarounds in downstream CI pipelines
  • The LD_PRELOAD error message corrupts cmake output parsing

Proposal

A portable lookup would work across all Linux distributions without any platform-specific checks. Happy to raise a PR for this if the approach sounds reasonable.

cc @seemethere @malfet @pytorch/pytorch-dev-infra

extent analysis

TL;DR

Update the LD_PRELOAD path in .ci/pytorch/build.sh to use a portable lookup for the jemalloc library location.

Guidance

  • Identify the correct path to the jemalloc library on non-Debian distributions (e.g., /usr/lib64/libjemalloc.so.2 on RHEL, CentOS, Fedora) and update the LD_PRELOAD path accordingly.
  • Consider using a platform-agnostic approach to determine the jemalloc library location, such as using the ldconfig command or a similar mechanism.
  • Verify that the updated LD_PRELOAD path resolves the build failures and prevents the LD_PRELOAD error message from corrupting cmake output parsing.
  • Test the updated build.sh script on multiple Linux distributions to ensure compatibility.

Example

# Example of using ldconfig to find the jemalloc library location
export LD_PRELOAD=$(ldconfig -p | grep libjemalloc.so | awk '{print $4}')

Note: This example is hypothetical and may not work as-is, but it illustrates the idea of using a platform-agnostic approach to determine the jemalloc library location.

Notes

The proposed solution assumes that the jemalloc library is installed and available on the system. If the library is not installed, additional steps may be necessary to install it.

Recommendation

Apply a workaround by updating the LD_PRELOAD path to use a portable lookup, as this will allow the build script to work across multiple Linux distributions without requiring platform-specific checks.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix [CI] Hardcoded jemalloc path in build.sh breaks non-Ubuntu builds [1 pull requests, 1 participants]