clear_cache('cython')
WARNING Cannot use Cython, a test compilation failed: [Errno 35] Resource deadlock avoided (OSError) [brian2.codegen.runtime.cython_rt.cython_rt.failed_compile_test]
INFO Cannot use compiled code, falling back to the numpy code generation target. Note that this will likely be slower than using compiled code. Set the code generation to numpy manually to avoid this message:
prefs.codegen.target = "numpy" [brian2.devices.device.codegen_fallback]
codegen.runtime.cython.cache_dir = '/home/wilhelm/projects/test_1'
AttributeError: module 'brian2.codegen.runtime' has no attribute 'cython'
Hi Wilhelm,
thanks for your input. The error I get when the processes go to sleep is
WARNING Cannot use Cython, a test compilation failed: [Errno 35] Resource deadlock avoided (OSError) [brian2.codegen.runtime.cython_rt.cython_rt.failed_compile_test]
INFO Cannot use compiled code, falling back to the numpy code generation target. Note that this will likely be slower than using compiled code. Set the code generation to numpy manually to avoid this message:
prefs.codegen.target = "numpy" [brian2.devices.device.codegen_fallback]
Interesting. The deadlock occurs not when compiling the code of
your actual model but when compiling the test file used to
determine whether Cython is available. You can avoid this
compilation by setting
prefs.codegen.target = 'cython'
explicitly (by default, it is "auto"). But there might be
something wrong with our implementation of the locking mechanism
in general, I'm thinking of replacing it by a somewhat more
sophisticated version:
https://github.com/benediktschmitt/py-filelock
I tried to make the cython cache use a different output directory, using the command you mention directly in the python simulation script, after importing brian2. I then get this error:
codegen.runtime.cython.cache_dir = '/home/wilhelm/projects/test_1'
AttributeError: module 'brian2.codegen.runtime' has no attribute 'cython'
codegen.runtime.cython.cache_dir is a preference, you'll therefore have to do:
prefs.codegen.runtime.cython.cache_dir = ...
or
prefs['codegen.runtime.cython.cache_dir'] = ...
Best,
Marcel
INFO Lock 139655436729872 acquired on /home/wilhelm/.cython/brian_extensions/_cython_magic_ffbd4e816d2c35fa3fa6d87e8b22f05d.lock [brian2.utils.filelock]
INFO Lock 139655436729872 released on /home/wilhelm/.cython/brian_extensions/_cython_magic_ffbd4e816d2c35fa3fa6d87e8b22f05d.lock [brian2.utils.filelock]
logging.console_log_level = 'CRITICAL'
prefs.codegen.target = 'numpy'
Thanks for this suggestion, I did another install of brian2 using your link in a new virtual env and it worked. As a small detail, now get a lot of these messages:
INFO Lock 139655436729872 acquired on /home/wilhelm/.cython/brian_extensions/_cython_magic_ffbd4e816d2c35fa3fa6d87e8b22f05d.lock [brian2.utils.filelock]
INFO Lock 139655436729872 released on /home/wilhelm/.cython/brian_extensions/_cython_magic_ffbd4e816d2c35fa3fa6d87e8b22f05d.lock [brian2.utils.filelock]
Oh, we definitely don't want this. Filelock puts these messages at the info level which we display by default, I'll downgrade them to debug instead.
Are you confident that the new version fixes all your deadlock issues (i.e., could you reliably trigger them before?) or do you need to test for a longer time?
Best,
Marcel