Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conda build with pre-cxx11 ABI #102

Open
yaoyic opened this issue Mar 24, 2023 · 5 comments
Open

Conda build with pre-cxx11 ABI #102

yaoyic opened this issue Mar 24, 2023 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@yaoyic
Copy link
Contributor

yaoyic commented Mar 24, 2023

When installing the openmm-torch plugin with the conda-forge packages, I met with the issue of ABI incompatibility:

Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import openmmtorch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "${CONDA_PREFIX}/lib/python3.9/site-packages/openmmtorch.py", line 15, in <module>
    import _openmmtorch
ImportError: ${CONDA_PREFIX}/lib/python3.9/site-packages/../../libOpenMMTorch.so: undefined symbol: _ZN5torch3jit4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3c108optionalINS9_6DeviceEEE

For the tested setup pytorch v1.12, I checked the wheels from two sources: the official pip wheel and pytorch conda channel, inside which the pre-cxx11 name mangling was used:

$ readelf -sW libtorch_python.so | grep torch3jit4load
  3501: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZN5torch3jit4loadERKSsN3c108optionalINS3_6DeviceEEE
 33881: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZN5torch3jit4loadERKSsN3c108optionalINS3_6DeviceEEE

I don't know how you guys usually install pytorch, but in all my existing conda environments the pytorch uses pre-cxx11 name mangling. (Even though on pytorch's official website, libtorch is offered in both ABI forms, the python wheels seem to have only pre-cxx11 symbol names.) For the convenience of non-power users, I would suggest either of the following changes:

  1. In README.md, show how the user should install a compatible version of pytorch, (for example, a recipe for setting up a new conda environment from scratch that works out-of-the-box).
  2. Ship wheels/conda packages that is built against pre-cxx11 libtorch ABIs
@peastman
Copy link
Member

You need to install pytorch from conda-forge. It's designed to be a compatible ecosystem where every package is built in the same way.

@zijieli-Jlee
Copy link

Also got this error when using PyTorch 1.12.1 installed from Conda. Is there any workaround for this?

@peastman
Copy link
Member

Can you post the output of conda list? If everything comes from conda-forge, they should all use the same ABI.

@yaoyic
Copy link
Contributor Author

yaoyic commented Jun 14, 2023

What later worked for me was to install pytorch (presumably with CUDA support) from conda-forge instead of following the recommended ways written on pytorch's website, to which these released wheels were built against. Otherwise you can also build it from source locally (which has not been easy for me)

@zijieli-Jlee
Copy link

This is my previous conda list (clamped to show only relevant packages ):

openmm                    8.0.0            py39h7d85326_1    conda-forge
openmm-torch              1.0             cuda112py39h440defe_1    conda-forge
openmmtools               0.23.0             pyhd8ed1ab_0    conda-forge
python                    3.9.16          h2782a2a_0_cpython    conda-forge
python_abi                3.9                      3_cp39    conda-forge
pytorch                   1.12.1          py3.9_cuda11.6_cudnn8.3.2_0    pytorch
torchaudio                0.12.1               py39_cu116    pytorch
torchvision               0.13.1               py39_cu116    pytorch

I followed @yaoyic 's suggestion and installed pytorch from channel -c conda-forge instead of channel -c pytorch, and now everything works. I think the reason is exactly what @yaoyic has said, the instruction on Pytorch's website lead to packages that are actually not from the conda-forge.

@raimis raimis added the help wanted Extra attention is needed label Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants