Skip to content

f2py spawns a huge number of threads #12087

Closed

Description

@jdemeyer

Reproducing code example:

from numpy import f2py
f2py.compile('''
      SUBROUTINE FOO()
      END
''')

Error message:

On a system with many CPUs:

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "untitled" sources
f2py options: []
f2py:> /tmp/tmpbxJPEk/src.linux-ppc64le-2.7/untitledmodule.c
creating /tmp/tmpbxJPEk/src.linux-ppc64le-2.7
Reading fortran codes...
    Reading file '/tmp/tmpZ7UZp4.f' (format:fix,strict)
Post-processing...
    Block: untitled
            Block: foo
Post-processing (stage 2)...
Building modules...
    Building module "untitled"...
        Constructing wrapper function "foo"...
          foo()
    Wrote C/API module "untitled" to file "/tmp/tmpbxJPEk/src.linux-ppc64le-2.7/untitledmodule.c"
  adding '/tmp/tmpbxJPEk/src.linux-ppc64le-2.7/fortranobject.c' to sources.
  adding '/tmp/tmpbxJPEk/src.linux-ppc64le-2.7' to include_dirs.
copying /home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpbxJPEk/src.linux-ppc64le-2.7
copying /home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpbxJPEk/src.linux-ppc64le-2.7
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
Found executable /usr/bin/ld
Found executable /usr/bin/ar
Found executable /usr/bin/ranlib
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'untitled' extension
compiling C sources
C compiler: gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -fPIC

creating /tmp/tmpbxJPEk/tmp
creating /tmp/tmpbxJPEk/tmp/tmpbxJPEk
creating /tmp/tmpbxJPEk/tmp/tmpbxJPEk/src.linux-ppc64le-2.7
compile options: '-I/tmp/tmpbxJPEk/src.linux-ppc64le-2.7 -I/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/core/include -I/home/jdemeyer/sage-git/local/
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/f2py/f2py2e.py", line 648, in main
    run_compile()
  File "/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/f2py/f2py2e.py", line 633, in run_compile
    setup(ext_modules=[ext])
  File "/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/home/jdemeyer/sage-git/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/distutils/command/build.py", line 47, in run
    old_build.run(self)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/distutils/command/build_ext.py", line 262, in run
    self.build_extensions()
  File "/home/jdemeyer/sage-git/local/lib/python2.7/distutils/command/build_ext.py", line 449, in build_extensions
    self.build_extension(ext)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/distutils/command/build_ext.py", line 380, in build_extension
    **kws)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/site-packages/numpy/distutils/ccompiler.py", line 337, in CCompiler_compile
    pool = multiprocessing.pool.ThreadPool(jobs)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/multiprocessing/pool.py", line 732, in __init__
    Pool.__init__(self, processes, initializer, initargs)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/multiprocessing/pool.py", line 161, in __init__
    self._repopulate_pool()
  File "/home/jdemeyer/sage-git/local/lib/python2.7/multiprocessing/pool.py", line 225, in _repopulate_pool
    w.start()
  File "/home/jdemeyer/sage-git/local/lib/python2.7/multiprocessing/dummy/__init__.py", line 75, in start
    threading.Thread.start(self)
  File "/home/jdemeyer/sage-git/local/lib/python2.7/threading.py", line 736, in start
    _start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

This works fine with numpy-1.14.6 but not with numpy-1.15.0

Numpy/Python version information:

1.15.2
2.7.15 (default, Aug  9 2018, 23:53:06) \n[GCC 5.4.0 20160609]'

Also relevant:

sage: from numpy.distutils.misc_util import get_num_build_jobs
sage: get_num_build_jobs()
192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions