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

[Bug] ImportError: cannot import name '_mul_broadcast_shape' from 'gpytorch.utils.broadcasting' #1370

Closed
harupy opened this issue Aug 31, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@harupy
Copy link

harupy commented Aug 31, 2022

🐛 Bug

To reproduce

** Code snippet to reproduce **

docker run --rm python:3.8 bash -c "pip install botorch && python -c 'import botorch'"

** Stack trace/error message **

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/botorch/__init__.py", line 7, in <module>
    from botorch import (
  File "/usr/local/lib/python3.8/site-packages/botorch/acquisition/__init__.py", line 7, in <module>
    from botorch.acquisition.acquisition import (
  File "/usr/local/lib/python3.8/site-packages/botorch/acquisition/acquisition.py", line 16, in <module>
    from botorch.models.model import Model
  File "/usr/local/lib/python3.8/site-packages/botorch/models/__init__.py", line 7, in <module>
    from botorch.models.approximate_gp import (
  File "/usr/local/lib/python3.8/site-packages/botorch/models/approximate_gp.py", line 35, in <module>
    from botorch.models.gpytorch import GPyTorchModel
  File "/usr/local/lib/python3.8/site-packages/botorch/models/gpytorch.py", line 23, in <module>
    from botorch.acquisition.objective import PosteriorTransform
  File "/usr/local/lib/python3.8/site-packages/botorch/acquisition/objective.py", line 18, in <module>
    from botorch.models.model import Model
  File "/usr/local/lib/python3.8/site-packages/botorch/models/model.py", line 24, in <module>
    from botorch.models.utils.assorted import fantasize as fantasize_flag
  File "/usr/local/lib/python3.8/site-packages/botorch/models/utils/__init__.py", line 7, in <module>
    from botorch.models.utils.assorted import (
  File "/usr/local/lib/python3.8/site-packages/botorch/models/utils/assorted.py", line 21, in <module>
    from gpytorch.utils.broadcasting import _mul_broadcast_shape
ImportError: cannot import name '_mul_broadcast_shape' from 'gpytorch.utils.broadcasting' (/usr/local/lib/python3.8/site-packages/gpytorch/utils/broadcasting.py)

Expected Behavior

import botorch should succeed.

System information

Please complete the following information:

  • 0.6.6
  • 1.10
  • 1.9.0
  • Debian GNU/Linux

Additional context

Add any other context about the problem here.

pip installation log

Collecting botorch
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /packages/12/29/4e382ca14a4e5b759615fc8834bdd1345bfba2a176bf432aa473991243a4/botorch-0.6.6-py3-none-any.whl
  Downloading botorch-0.6.6-py3-none-any.whl (387 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 387.4/387.4 KB 9.6 MB/s eta 0:00:00
Collecting torch>=1.10
  Downloading torch-1.12.1-cp38-cp38-manylinux1_x86_64.whl (776.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 776.3/776.3 MB 3.9 MB/s eta 0:00:00
Collecting gpytorch>=1.8.1
  Downloading gpytorch-1.9.0-py3-none-any.whl (245 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 245.8/245.8 KB 6.0 MB/s eta 0:00:00
Collecting multipledispatch
  Downloading multipledispatch-0.6.0-py3-none-any.whl (11 kB)
Collecting pyro-ppl>=1.8.0
  Downloading pyro_ppl-1.8.1-py3-none-any.whl (718 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 718.2/718.2 KB 9.8 MB/s eta 0:00:00
Collecting scipy
  Downloading scipy-1.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.4/43.4 MB 10.5 MB/s eta 0:00:00
Collecting scikit-learn
  Downloading scikit_learn-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (31.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 31.2/31.2 MB 10.3 MB/s eta 0:00:00
Collecting linear-operator>=0.1.1
  Downloading linear_operator-0.1.1-py3-none-any.whl (145 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 145.9/145.9 KB 10.3 MB/s eta 0:00:00
Collecting opt-einsum>=2.3.2
  Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.5/65.5 KB 9.3 MB/s eta 0:00:00
Collecting pyro-api>=0.1.1
  Downloading pyro_api-0.1.2-py3-none-any.whl (11 kB)
Collecting tqdm>=4.36
  Downloading tqdm-4.64.0-py2.py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.4/78.4 KB 8.5 MB/s eta 0:00:00
Collecting numpy>=1.7
  Downloading numpy-1.23.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.1/17.1 MB 8.2 MB/s eta 0:00:00
Collecting typing-extensions
  Downloading typing_extensions-4.3.0-py3-none-any.whl (25 kB)
Collecting six
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting joblib>=1.0.0
  Downloading joblib-1.1.0-py2.py3-none-any.whl (306 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 307.0/307.0 KB 8.7 MB/s eta 0:00:00
Collecting threadpoolctl>=2.0.0
  Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)
Installing collected packages: pyro-api, typing-extensions, tqdm, threadpoolctl, six, numpy, joblib, torch, scipy, opt-einsum, multipledispatch, scikit-learn, pyro-ppl, linear-operator, gpytorch, botorch
Successfully installed botorch-0.6.6 gpytorch-1.9.0 joblib-1.1.0 linear-operator-0.1.1 multipledispatch-0.6.0 numpy-1.23.2 opt-einsum-3.3.0 pyro-api-0.1.2 pyro-ppl-1.8.1 scikit-learn-1.1.2 scipy-1.9.1 six-1.16.0 threadpoolctl-3.1.0 torch-1.12.1 tqdm-4.64.0 typing-extensions-4.3.0
@harupy harupy added the bug Something isn't working label Aug 31, 2022
@harupy
Copy link
Author

harupy commented Aug 31, 2022

cornellius-gp/gpytorch#2027 removed _mul_broadcast_shape.

@Balandat
Copy link
Contributor

Apologies for this issue. This applies to the latest release only, on the main branch the GPyTorch version has been pinned.

Two options for you in the short term:

  1. Install GPyTorch 1.8.1 before installing the latest BoTorch release.
  2. install BoTorch from the main branch.

The changes to adjust for the GPyTorch ones have been made in #1363; my plan is to merge this in early next week.

@harupy
Copy link
Author

harupy commented Sep 1, 2022

@Balandat Thanks for the comment! I'll add gpytorch<1.9.0 in my requirements file to avoid using gpytorch 1.9.0. Thanks, feel free to close the issue :)

@Balandat
Copy link
Contributor

Balandat commented Sep 1, 2022

I'll leave this open for visibility until a new version has been released.

@Balandat
Copy link
Contributor

Balandat commented Sep 7, 2022

New release is out: https://github.com/pytorch/botorch/releases/tag/v0.7.0

@classner
Copy link

Hi @Balandat !

Still running into this issue when trying to use AX in hydra. :( Would it be possible to update the version pins there?

Best,
Christoph

@Balandat
Copy link
Contributor

@classner The version pins in Hydra you mean? FWIW, the Ax Hydra plugin is something that was not done by us (and we haven't been maintaining it), so not surprised that this may have issues. But if you have a repro for how this fails, I'm happy to take a look and see what I can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants