open-cogsci / OpenSesame

Graphical experiment builder for the social sciences
http://osdoc.cogsci.nl/
GNU General Public License v3.0
234 stars 111 forks source link

'spawn' multiprocessing method crashes, need to manually revert commit #782

Open dev-jam opened 1 year ago

dev-jam commented 1 year ago

The new spawn method for multiprocessing makes opensesame on debian bullseye (python 3.9) and bookworm (python 3.10) unusable on my machines. The main window crashes but it keeps the experiment running for some time. This happens both with psychopy and expyriment as backend.

When I comment out the new method in the following commit, everything works fine again:

    # Appears more stable when running experiments on Linux, where fork is the 
    # default multiprocessing method.
    #multiprocessing.set_start_method('spawn')
    # solves a library conflict for Linux with Nvidia drivers
    # See https://forum.qt.io/topic/81328/ubuntu-qopenglshaderprogram-shader-program-is-not-linked/2

commit: https://github.com/open-cogsci/OpenSesame/commit/b42a91feeb341fe5d35e5b20ed21a9a463a327f7

Some relevant debug info:

INFO:traitlets:KernelRestarter: restarting kernel (1/5), keep random ports
  WARNING:traitlets:kernel restarted
  WARNING:traitlets:kernel died: 3.0001235008239746
  Bad file descriptor (src/epoll.cpp:145)
  Aborted (core dumped)

  /usr/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 9 leaked semaphore objects to clean up at shutdown
    warnings.warn('resource_tracker: There appear to be %d '

The last error seems like a bug in python 3.10

Machines I tested were nvidia and intel gpu machines.

smathot commented 1 year ago

Thanks. It seems that different multiprocessing methods have different issues on different systems, so I don't want to revert this commit just yet. As a hacky workaround, you can now specify the multiprocessing method on Linux by setting the OPENSESAME_MULTIPROCESSING_METHOD environment variable. In other words, running the following command in the terminal will allow you to change the method from spawn to fork:

export OPENSESAME_MULTIPROCESSING_METHOD=fork && opensesame

Let's keep this on the radar.

dev-jam commented 1 year ago

Thanks! That is an elegant and easy to maintain solution/workaround. I put a conf file with this env variable in /etc/environment.d and it works perfectly.