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

numba.core.errors.ConstantInferenceError: Failed in nopython mode pipeline #38

Closed
jonnew opened this issue Aug 20, 2020 · 7 comments
Closed

Comments

@jonnew
Copy link

jonnew commented Aug 20, 2020

Describe the bug

(anipose) anipose[0]$  anipose calibrate
Calibrating...
/home/jon/data/2020-08_large-3d-maze/2020-08-19_3d-camera-calibration/anipose/dlc-hand
/home/jon/data/2020-08_large-3d-maze/2020-08-19_3d-camera-calibration/anipose/calibration/calibration.toml
/home/jon/data/2020-08_large-3d-maze/2020-08-19_3d-camera-calibration/anipose/calibration/cam-0_2020-08-20T15_56_14.avi
100%|█████████████████████████████| 9471/9471 [05:07<00:00, 30.80it/s]
6930 boards detected
/home/jon/data/2020-08_large-3d-maze/2020-08-19_3d-camera-calibration/anipose/calibration/cam-1_2020-08-20T15_56_14.avi
100%|█████████████████████████████| 9471/9471 [05:14<00:00, 30.11it/s]
6996 boards detected
/home/jon/data/2020-08_large-3d-maze/2020-08-19_3d-camera-calibration/anipose/calibration/cam-2_2020-08-20T15_56_14.avi
100%|█████████████████████████████| 9470/9470 [05:29<00:00, 28.72it/s]
7090 boards detected
/home/jon/data/2020-08_large-3d-maze/2020-08-19_3d-camera-calibration/anipose/calibration/cam-3_2020-08-20T15_56_14.avi
100%|█████████████████████████████| 9471/9471 [05:33<00:00, 28.38it/s]
7392 boards detected
/home/jon/data/2020-08_large-3d-maze/2020-08-19_3d-camera-calibration/anipose/calibration/cam-4_2020-08-20T15_56_14.avi
100%|█████████████████████████████| 9470/9470 [05:49<00:00, 27.09it/s]
8372 boards detected
defaultdict(<class 'int'>,
            {('0', '1'): 5885,
             ('0', '2'): 5681,
             ('0', '3'): 6490,
             ('0', '4'): 6768,
             ('1', '0'): 5885,
             ('1', '2'): 6042,
             ('1', '3'): 6255,
             ('1', '4'): 6854,
             ('2', '0'): 5681,
             ('2', '1'): 6042,
             ('2', '3'): 6257,
             ('2', '4'): 6976,
             ('3', '0'): 6490,
             ('3', '1'): 6255,
             ('3', '2'): 6257,
             ('3', '4'): 7315,
             ('4', '0'): 6768,
             ('4', '1'): 6854,
             ('4', '2'): 6976,
             ('4', '3'): 7315})
Traceback (most recent call last):
  File "/home/jon/anaconda3/envs/anipose/bin/anipose", line 33, in <module>
    sys.exit(load_entry_point('anipose', 'console_scripts', 'anipose')())
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/anipose.py", line 115, in calibrate
    calibrate_all(config)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/common.py", line 168, in fun
    return process_all(config, process_session, **args)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/common.py", line 153, in process_all
    output[past_folders] = process_session(config, path, **args)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/calibrate.py", line 187, in process_session
    verbose=True)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/cameras.py", line 1564, in calibrate_rows
    error = self.bundle_adjust_iter(imgp, extra, verbose=verbose, **kwargs)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/cameras.py", line 681, in bundle_adjust_iter
    error = self.average_error(p2ds, median=True)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/cameras.py", line 1528, in average_error
    errors = self.reprojection_error(p3ds, p2ds, mean=True)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/numba/core/dispatcher.py", line 427, in _compile_for_args
    error_rewrite(e, 'constant_inference')
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/numba/core/dispatcher.py", line 358, in error_rewrite
    reraise(type(e), e, None)
  File "/home/jon/anaconda3/envs/anipose/lib/python3.7/site-packages/numba/core/utils.py", line 80, in reraise
    raise value.with_traceback(tb)
numba.core.errors.ConstantInferenceError: Failed in nopython mode pipeline (step: nopython rewrites)
Constant inference not possible for: getattr(value=$const92.1, attr=format)

File "../../../../anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/cameras.py", line 632:
    def reprojection_error(self, p3ds, p2ds, mean=False):
        <source elided>
            "shapes of 2D and 3D points are not consistent: " \
            "2D={}, 3D={}".format(p2ds.shape, p3ds.shape)
            ^


File "../../../../anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/cameras.py", line 632:
    def reprojection_error(self, p3ds, p2ds, mean=False):
        <source elided>
            "shapes of 2D and 3D points are not consistent: " \
            "2D={}, 3D={}".format(p2ds.shape, p3ds.shape)

Seems to be another issue with numba (or use of numba), like my last submitted issue.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04
@jonnew
Copy link
Author

jonnew commented Aug 20, 2020

As I just comment out more and more numba function attributes, everything runs further and further. I'm beginning to suspect this is is a numba versioning issue.

@lambdaloop
Copy link
Owner

I'm guessing this is a similar issue to your other issue #37

Which version of numba are you using?

I checked in my environment and I haven't had any issues with numba 0.50.1 . I wonder at what point it breaks.

@jonnew
Copy link
Author

jonnew commented Sep 4, 2020

I'm using 0.51, so this does seem like a potential explanation. I think the point still stands though. Some of the numba function attributes used seem to clash with one another:

https://gitter.im/numba/numba?at=5eafceefb6dd230697a45990

It might be possible they have gotten more strict with acceptable attribute combinations? I will downgrade to 0.50.1 in the meantime.

@jonnew
Copy link
Author

jonnew commented Sep 8, 2020

I actually have a difficult time understanding how to downgrade my numba package since it seems to be specified as a dependency of anipose. For now, Im just commenting out @jit function attributes in camera.py

@lambdaloop
Copy link
Owner

I know this is not the solution to this, but I've updated the dependency to point to numba 0.50.1 for now, until I have to look into the issue more deeply.

@lambdaloop
Copy link
Owner

If anyone runs into this, try upgrading aniposelib using pip install --upgrade aniposelib, or if you don't want to upgrade, you can also just downgrade numba with pip install numba==0.50.1

@lambdaloop
Copy link
Owner

I finally just removed the "nopython" statements in the relevant functions.
As of 0.4.2, aniposelib should work with the latest numba version (I tested numba 0.54.0).

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

2 participants