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.

Error while importing tfimm library

See original GitHub issue

Problem:

When I try to install and import tfimm packages:

!pip install tfimm import tfimm

This error occurs:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_42/1172421075.py in <module>
      3 get_ipython().system('pip install timm')
      4 import timm
----> 5 import tfimm

/opt/conda/lib/python3.7/site-packages/tfimm/__init__.py in <module>
----> 1 from . import architectures  # noqa: F401
      2 from .models.factory import create_model, create_preprocessing  # noqa: F401
      3 from .models.registry import list_models  # noqa: F401
      4 from .utils import (  # noqa: F401
      5     cached_model_path,

/opt/conda/lib/python3.7/site-packages/tfimm/architectures/__init__.py in <module>
----> 1 from .cait import *  # noqa: F401
      2 from .convmixer import *  # noqa: F401
      3 from .convnext import *  # noqa: F401
      4 from .mlp_mixer import *  # noqa: F401
      5 from .pit import *  # noqa: F401

/opt/conda/lib/python3.7/site-packages/tfimm/architectures/cait.py in <module>
     15 from typing import List, Tuple
     16 
---> 17 import tensorflow as tf
     18 
     19 from tfimm.layers import (

/opt/conda/lib/python3.7/site-packages/tensorflow/__init__.py in <module>
     35 import typing as _typing
     36 
---> 37 from tensorflow.python.tools import module_util as _module_util
     38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
     39 

/opt/conda/lib/python3.7/site-packages/tensorflow/python/__init__.py in <module>
     35 
     36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
---> 37 from tensorflow.python.eager import context
     38 
     39 # pylint: enable=wildcard-import

/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/context.py in <module>
     33 from tensorflow.python import pywrap_tfe
     34 from tensorflow.python import tf2
---> 35 from tensorflow.python.client import pywrap_tf_session
     36 from tensorflow.python.eager import executor
     37 from tensorflow.python.eager import monitoring

/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/pywrap_tf_session.py in <module>
     17 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
     18 from tensorflow.python import pywrap_tensorflow
---> 19 from tensorflow.python.client._pywrap_tf_session import *
     20 from tensorflow.python.client._pywrap_tf_session import _TF_SetTarget
     21 from tensorflow.python.client._pywrap_tf_session import _TF_SetConfig

ImportError: SystemError: <built-in method __contains__ of dict object at 0x7f9744ee7280> returned a result with an error set

Desktop Environment:

  • OS: Xubuntu 20.04
  • Browser: Mozilla Firefox
  • Device: Cloud VMs Kaggle = TPU v3-8 Core
  • TF Latest Version with CUDA Latest Version
  • NumPy == 1.21.5

Question

In other repositories I have found that upgrading NumPy solves the problem. But my NumPy has the latest version. Can anyone please help me to solve this error?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
martinsbruveriscommented, Feb 16, 2022

I understand that you are using the latest version of TensorFlow. I am just wondering how the issue you are encountering could have been caused by tfimm. Hence the question whether you can execute import tensorflow without error messages? Because, if you can’t then this would suggest that the problem lies with the python environment rather than tfimm.

1reaction
martinsbruveriscommented, Feb 15, 2022

Interesting. Definitely shouldn’t happen. Could you post the output of pip list?

Read more comments on GitHub >

github_iconTop Results From Across the Web

tfimm · PyPI
For this to work, the tfimm library needs to be imported before the model is loaded, since during the import process, tfimm is...
Read more >
Error while import tensorflow module - Stack Overflow
My setup working with Win10 64 and the Nvidia GTX780M: Be sure you have the lib MSVCP140.DLL by checking your system/path - if...
Read more >
tensorflow is installed but theres an error while importing
I'm new at python (version of python 3.7.7) and I'm trying to run a finished project, I imported everything but tensorflow is not...
Read more >
TensorFlow Image Models (tfimm) — tfimm 0.1 documentation
TensorFlow Image Models ( tfimm ) is a collection of image models with pretrained weights, obtained by porting architectures from timm to TensorFlow....
Read more >
ArcFace_EfficientNetV2 Training | Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from multiple data sources.
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