Skip to content

Invalid RPATH for _C.so for in tree installation: assuption fail "$ORIGIN/../.." -> site-packages #141837

@XuehaiPan

Description

@XuehaiPan

🐛 Describe the bug

For in-tree installation, there is a pytorch-xxx.pth which contains:

pytorch/tools/nightly.py

Lines 762 to 771 in 5deca07

@timed("Writing pytorch-nightly.pth")
def write_pth(venv: Venv) -> None:
"""Writes Python path file for this dir."""
(venv.site_packages() / "pytorch-nightly.pth").write_text(
"# This file was autogenerated by PyTorch's tools/nightly.py\n"
"# Please delete this file if you no longer need the following development\n"
"# version of PyTorch to be importable\n"
f"{REPO_ROOT}\n",
encoding="utf-8",
)

points to the git repository.

The torch package is not installed in the site-packages directory.

$ make setup-env-cuda PYTHON="/home/linuxbrew/.linuxbrew/bin/python3.12"
$ source venv/bin/activate
$ patchelf --print-rpath torch/_C.*.so | tr ':' '\n'
$ORIGIN/../../nvidia/cublas/lib
$ORIGIN/../../nvidia/cuda_cupti/lib
$ORIGIN/../../nvidia/cuda_nvrtc/lib
$ORIGIN/../../nvidia/cuda_runtime/lib
$ORIGIN/../../nvidia/cudnn/lib
$ORIGIN/../../nvidia/cufft/lib
$ORIGIN/../../nvidia/curand/lib
$ORIGIN/../../nvidia/cusolver/lib
$ORIGIN/../../nvidia/cusparse/lib
$ORIGIN/../../cusparselt/lib
$ORIGIN/../../nvidia/nccl/lib
$ORIGIN/../../nvidia/nvtx/lib
$ORIGIN
$ORIGIN/lib

For CUDA builds, the PyPI wheels require the torch package to be installed in the site-packages directory:

$ python3 -c 'import torch'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/PanXuehai/Projects/pytorch/torch/__init__.py", line 378, in <module>
    from torch._C import *  # noqa: F403
    ^^^^^^^^^^^^^^^^^^^^^^
ImportError: libcudnn.so.9: cannot open shared object file: No such file or directory

echo "Using nvidia libs from pypi."
CUDA_RPATHS=(
'$ORIGIN/../../nvidia/cublas/lib'
'$ORIGIN/../../nvidia/cuda_cupti/lib'
'$ORIGIN/../../nvidia/cuda_nvrtc/lib'
'$ORIGIN/../../nvidia/cuda_runtime/lib'
'$ORIGIN/../../nvidia/cudnn/lib'
'$ORIGIN/../../nvidia/cufft/lib'
'$ORIGIN/../../nvidia/curand/lib'
'$ORIGIN/../../nvidia/cusolver/lib'
'$ORIGIN/../../nvidia/cusparse/lib'
'$ORIGIN/../../cusparselt/lib'
'$ORIGIN/../../nvidia/nccl/lib'
'$ORIGIN/../../nvidia/nvtx/lib'
)
CUDA_RPATHS=$(IFS=: ; echo "${CUDA_RPATHS[*]}")
export C_SO_RPATH=$CUDA_RPATHS':$ORIGIN:$ORIGIN/lib'
export LIB_SO_RPATH=$CUDA_RPATHS':$ORIGIN'

echo "Using xpu runtime libs from pypi."
XPU_RPATHS=(
'$ORIGIN/../../../..'
)
XPU_RPATHS=$(IFS=: ; echo "${XPU_RPATHS[*]}")
export C_SO_RPATH=$XPU_RPATHS':$ORIGIN:$ORIGIN/lib'

Maybe related:

Versions

nightly

cc @seemethere @malfet @osalpekar @atalman

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: binariesAnything related to official binaries that we release to userstopic: binariestopic: buildtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions