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

Implicitly building with mismatching pytorch version #9

Open
liyanc opened this issue Apr 5, 2022 · 0 comments
Open

Implicitly building with mismatching pytorch version #9

liyanc opened this issue Apr 5, 2022 · 0 comments

Comments

@liyanc
Copy link

liyanc commented Apr 5, 2022

Hello,

I had the same issue as #8 part (2) when installing with not-latest PyTorch versions (1.8.1, 1.9.1, etc).

Test environments: Ubuntu 20.04 + 18.04, python 3.7 + 3.8, GCC 7.5 + 9.4, PyTorch 1.8.1 + 1.9.1.

After some digging, I found it's
'ImportError: .../lib/python3.7/site-packages/torch_discounted_cumsum_cpu.cpython-37m-x86_64-linux-gnu.so' suppressed by the try-catch statement which redirecting extension loading to nonexisting sources, hence errors.

A little more digging reveals the ImportError complaining undefined symbol is caused by building the extension against a mismatching PyTorch version (latest release 1.11 as of the time of writing).

When turning on --verbose with pip, the head of logs shows the following:

Collecting torch-discounted-cumsum
Downloading torch_discounted_cumsum-1.1.0.tar.gz (185 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 185.4/185.4 KB 2.0 MB/s eta 0:00:00
Running command pip subprocess to install build dependencies
Collecting setuptools>=38.2.5
Using cached setuptools-62.0.0-py3-none-any.whl (1.1 MB)
Collecting wheel
Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Collecting torch>=1.5
Using cached torch-1.11.0-cp37-cp37m-manylinux1_x86_64.whl (750.6 MB)
...

It shows pip is using a freshly pulled PyTorch as opposed to the existing PyTorch installation, therefore incurring the undefined symbol issue when importing the so module.

I'd suggest removing the step to automatically pull the latest PyTorch during installation.

A temporary solution: adding the --no-build-isolation flag (and --no-cache-dir if you've failed once) can prevent pip from pulling a new PyTorch package to build against, assuming you already have all requirements properly installed.

(which coincides with what #8 did in part 1 🤣)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant