‘RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb’ in Visualize inferences

Please provide the following information when requesting support.

• Hardware (3080ti)
• Network Type (Detectnet_v2)
• TLT Version (Please run “tlt info --verbose” and share “docker_tag” here)
• Training spec file(If have, please share here)
• How to reproduce the issue ? (This is for errors. Please share the command line and the detailed log here.)
I find a issue when I do Visualize inferences in Detectnet_v2.

# Simple grid visualizer
!pip3 install matplotlib==3.3.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
%matplotlib inline
import matplotlib.pyplot as plt
import os
from math import ceil
valid_image_ext = ['.jpg', '.png', '.jpeg', '.ppm']

def visualize_images(image_dir, num_cols=4, num_images=10):
    output_path = os.path.join(os.environ['LOCAL_EXPERIMENT_DIR'], image_dir)
    num_rows = int(ceil(float(num_images) / float(num_cols)))
    f, axarr = plt.subplots(num_rows, num_cols, figsize=[80,30])
    a = [os.path.join(output_path, image) for image in os.listdir(output_path) 
         if os.path.splitext(image)[1].lower() in valid_image_ext]
    for idx, img_path in enumerate(a[:num_images]):
        col_id = idx % num_cols
        row_id = idx // num_cols
        img = plt.imread(img_path)
        axarr[row_id, col_id].imshow(img)

The error log is:

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://pypi.ngc.nvidia.com
Collecting matplotlib==3.3.3
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d2/43/2bd63467490036697e7be71444fafc7b236923d614d4521979a200c6b559/matplotlib-3.3.3-cp36-cp36m-manylinux1_x86_64.whl (11.6 MB)
     |████████████████████████████████| 11.6 MB 227 kB/s            
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.3) (3.0.9)
Requirement already satisfied: numpy>=1.15 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.3) (1.17.5)
Requirement already satisfied: cycler>=0.10 in /home/user/.local/lib/python3.6/site-packages (from matplotlib==3.3.3) (0.11.0)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.3) (8.4.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/user/.local/lib/python3.6/site-packages (from matplotlib==3.3.3) (1.3.1)
Requirement already satisfied: python-dateutil>=2.1 in /usr/lib/python3/dist-packages (from matplotlib==3.3.3) (2.6.1)
Installing collected packages: matplotlib
Successfully installed matplotlib-3.3.3
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb

ImportError                               Traceback (most recent call last)
<ipython-input-149-d7b4bd57f5c9> in <module>
      1 # Simple grid visualizer
      2 get_ipython().system('pip3 install matplotlib==3.3.3 -i https://pypi.tuna.tsinghua.edu.cn/simple')
----> 3 get_ipython().run_line_magic('matplotlib', 'inline')
      4 import matplotlib.pyplot as plt
      5 import os

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2324                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2325             with self.builtin_trap:
-> 2326                 result = fn(*args, **kwargs)
   2327             return result

/usr/local/lib/python3.6/dist-packages/decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    189         if callable(arg):

/usr/local/lib/python3.6/dist-packages/IPython/core/magics/pylab.py in matplotlib(self, line)
     97             print("Available matplotlib backends: %s" % backends_list)
     98         else:
---> 99             gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
    100             self._show_matplotlib_backend(args.gui, backend)

/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py in enable_matplotlib(self, gui)
    600     def enable_matplotlib(self, gui=None):
--> 601         gui, backend = super(ZMQInteractiveShell, self).enable_matplotlib(gui)
    603         try:

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
   3417         """
   3418         from IPython.core import pylabtools as pt
-> 3419         gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
   3421         if gui != 'inline':

/usr/local/lib/python3.6/dist-packages/IPython/core/pylabtools.py in find_gui_and_backend(gui, gui_select)
    278     """
--> 280     import matplotlib
    282     if gui and gui != 'auto':

~/.local/lib/python3.6/site-packages/matplotlib/__init__.py in <module>
--> 174 _check_versions()

~/.local/lib/python3.6/site-packages/matplotlib/__init__.py in _check_versions()
    157     # Quickfix to ensure Microsoft Visual C++ redistributable
    158     # DLLs are loaded before importing kiwisolver
--> 159     from . import ft2font
    161     for modname, minver in [

ImportError: numpy.core.multiarray failed to import

How to fix this issue?
Thank you very much.

Did you follow the default notebook?

Yes, I add a china source.
I have solved this issue by restarting system.
Thanky you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.