Skip to content

Multiprocessing issues on macOS #4

@adamjstewart

Description

@adamjstewart

Tried running this on macOS but have infinite error messages like:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from multiprocessing.spawn import spawn_main; spawn_main(tracker_fd=7, pipe_handle=30)
                                                  ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/spawn.py", line 122, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/spawn.py", line 131, in _main
    prepare(preparation_data)
    ~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/spawn.py", line 246, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/spawn.py", line 297, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
                                  run_name="__mp_main__")
  File "<frozen runpy>", line 287, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/py-contrib-0.3.0-act6k3p2yb2cjwb2ppnsgz6j5ao3l5a6/bin/contrib", line 10, in <module>
    contrib.main.main()
    ~~~~~~~~~~~~~~~~~^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/py-contrib-0.3.0-act6k3p2yb2cjwb2ppnsgz6j5ao3l5a6/lib/python3.13/site-packages/contrib/main.py", line 546, in main
    index = build_index(history, config.parts)
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/py-contrib-0.3.0-act6k3p2yb2cjwb2ppnsgz6j5ao3l5a6/lib/python3.13/site-packages/contrib/main.py", line 341, in build_index
    blame_pool = multiprocessing.Pool(blame_jobs)
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
                context=self.get_context())
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/pool.py", line 215, in __init__
    self._repopulate_pool()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/pool.py", line 306, in _repopulate_pool
    return self._repopulate_pool_static(self._ctx, self.Process,
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
                                        self._processes,
                                        ^^^^^^^^^^^^^^^^
    ...<3 lines>...
                                        self._maxtasksperchild,
                                        ^^^^^^^^^^^^^^^^^^^^^^^
                                        self._wrap_exception)
                                        ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/pool.py", line 329, in _repopulate_pool_static
    w.start()
    ~~~~~~~^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
                  ~~~~~~~~~~~^^^^^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/context.py", line 289, in _Popen
    return Popen(process_obj)
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/popen_fork.py", line 20, in __init__
    self._launch(process_obj)
    ~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/spawn.py", line 164, in get_preparation_data
    _check_not_importing_main()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/python-3.13.0-dv2el2okjhvmjukkjdbadqhyvgy5ynhg/lib/python3.13/multiprocessing/spawn.py", line 140, in _check_not_importing_main
    raise RuntimeError('''
    ...<16 lines>...
    ''')
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

        To fix this issue, refer to the "Safe importing of main module"
        section in https://docs.python.org/3/library/multiprocessing.html

contrib.yaml looks like:

contrib:
  repo: .
  parts:
    datasets:
      - ^torchgeo/datasets

Repo is https://github.com/microsoft/torchgeo, command is simply contrib.

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