question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JIT TypeError: Object of type 'module' is not an instance of 'function' with Python 3.9.1

See original GitHub issue

🐛 Bug

Description

I cannot build the package on Arch Linux with PyTorch 1.7.1 and Python 3.9 (using aur , PKGBUILD)

Traceback (most recent call last):
  File "/home/trougnouf/.cache/pacaur/python-pytorch-piqa-git/src/piqa/setup.py", line 5, in <module>
    import piqa
  File "/home/trougnouf/.cache/pacaur/python-pytorch-piqa-git/src/piqa/piqa/__init__.py", line 10, in <module>
    from .tv import TV
  File "/home/trougnouf/.cache/pacaur/python-pytorch-piqa-git/src/piqa/piqa/tv.py", line 16, in <module>
    def tv(x: torch.Tensor, norm: str = 'L1') -> torch.Tensor:
  File "/usr/lib/python3.9/site-packages/torch/jit/_script.py", line 939, in script
    fn = torch._C._jit_script_compile(
TypeError: Object of type 'module' is not an instance of 'function'

This may be a bug in PyTorch JIT, incompatibility with newer Numpy, or other, but I’m reporting here since this is the only place I’ve encountered the bug so far and I haven’t seen another report.

Reproduce

On an up to date system:

git clone git@github.com:francois-rozet/piqa.git
cd piqa
python setup.py build

alternatively, with piqa succesfully built with older libraries and the system then updated, the same error is triggered with “import piqa”

Expected behavior

No error

Causes and solution

Workaround: set PIQA_JIT=0

Environment

  • PIQA version: 5994e349d4c140877e560b18c2a51307e61575fc
  • Python version: 3.9.1
  • OS: Arch Linux
  • Numpy 1.20
  • PyTorch 1.7.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
trougnoufcommented, Mar 11, 2021

It’s working with pytorch 1.8.0 and python 3.9.2 😃

I guess it’ll be best to run with PIQA_JIT=1 since #7 .

Thank you!

0reactions
francois-rozetcommented, Mar 11, 2021

Hello @trougnouf 👋 There is a new version of torch (1.8.0) that was released. Maybe it solved the problem ? Nevertheless, I see that https://github.com/pytorch/pytorch/issues/51379 is still not resolved and the last comment corresponds exactly to your situation (Python 3.9.1, Arch, torch-1.7.1, pybind11-2.6.2, …). Since the problem isn’t caused by the PIQA package, I will close this issue. I will also merge #7, as I think it is preferable to not impose JITting by default.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module is not an instance of function - fastai
If I pip install fastai from github source on Debian/Bullseye using the --no-deps option (ensuring all requirements listed in settings.ini ...
Read more >
What's New In Python 3.11 — Python 3.11.1 documentation
A TypeError is now raised instead of an AttributeError in with statements and contextlib.ExitStack.enter_context() for objects that do not support the ...
Read more >
'Module' not callable with numba's jit compiler - Stack Overflow
A TypeError: 'module' object is not callable means you're trying to use something like a function when it's not actually a function or...
Read more >
Release Notes — Numba 0.56.4+0.g288a38bbd.dirty-py3.7 ...
Version 0.56.2 (1 September, 2022) . This is a bugfix release that supports NumPy 1.23 and fixes CUDA function caching. Pull-Requests:.
Read more >
Docs - CasADi
CasADi is available for C++, Python and MATLAB/Octave with little or no difference in ... SX.sym is a (static) function which returns an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found