Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Unable to generate a simple plot when compiled with Intel #28762

Closed as not planned
@DavidHuber-NOAA

Description

@DavidHuber-NOAA

Bug summary

When numpy is compiled with Intel classic compilers (v2021.5.0) on Rocky 8.8 Linux, matplotlib v3.8.4 (also compiled with Intel) is unable to generate a basic plot.

Code for reproduction

simple_plot.py

Actual outcome

$ python simple_plot.py
Traceback (most recent call last):
  File "/scratch1/NCEPDEV/global/David.Huber/simple_plot.py", line 23, in <module>
    fig.savefig("test.png")
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/figure.py", line 3390, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 2187, in print_figure
    result = print_method(
             ^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 2043, in <lambda>
    print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
                                                                 ^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py", line 497, in print_png
    self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py", line 445, in _print_pil
    FigureCanvasAgg.draw(self)
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py", line 388, in draw
    self.figure.draw(self.renderer)
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/artist.py", line 95, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/figure.py", line 3154, in draw
    mimage._draw_list_compositing_images(
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/axes/_base.py", line 3034, in draw
    self._update_title_position(renderer)
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/axes/_base.py", line 2978, in _update_title_position
    ax.yaxis.get_tightbbox(renderer)  # update offsetText
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/axis.py", line 1334, in get_tightbbox
    ticks_to_draw = self._update_ticks()
                    ^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/axis.py", line 1275, in _update_ticks
    major_locs = self.get_majorticklocs()
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/axis.py", line 1495, in get_majorticklocs
    return self.major.locator()
           ^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/ticker.py", line 2142, in __call__
    return self.tick_values(vmin, vmax)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/ticker.py", line 2150, in tick_values
    locs = self._raw_ticks(vmin, vmax)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/ticker.py", line 2088, in _raw_ticks
    nbins = np.clip(self.axis.get_tick_space(),
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch1/NCEPDEV/global/David.Huber/SPACK/ss_matplotlib/envs/matplotlib_intel/install/intel/2021.5.0/py-matplotlib-3.8.0-rnemqcl/lib/python3.11/site-packages/matplotlib/axis.py", line 2764, in get_tick_space
    return int(np.floor(length / size))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot convert float NaN to integer

Expected outcome

image

Additional information

This build is accomplished via spack stack (jcsda/spack-stack), but is likely reproducible via spack. Attached is the output of spack concretize.
concretize.log
And here is the spack.yaml used to build the environment:

spack:
  concretizer:
    unify: when_possible

  view: false
  include:
  - site
  - common

  definitions:
  - compilers: ['%intel']
  - packages:
    - [email protected]
    - [email protected]
  specs:
  - matrix:
    - [$packages]
    - [$compilers]
  packages:
    all:
      prefer: ['%intel']

The version of numpy that builds with this is 1.25.2.

This particular build was with matplotlib v3.8.0, but I have encountered the same issue with v3.8.4.
I have not tried v3.9.x or v3.10.x.

The issue is resolved if numpy v1.25.2 is installed via pip. After building this environment, lmod modules are generated. After loading the py-matplotlib and py-pip modules and unloading py-numpy, running the following generates the plot successfully:

#!/usr/bin/bash
python -m venv venv
source venv/bin/activate
pip install numpy=1.25.2
...
python simple_plot.py

Operating system

Rocky 8.8

Matplotlib Version

3.8.0-4

Matplotlib Backend

agg

Python version

3.11.7

Jupyter version

N/A

Installation

from source (.tar.gz)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions