I've run into an issue using PerlMagick under a restricted user account where this error occurs:
libgomp: Thread creation failed: Resource temporarily unavailable
I discovered that this can be fixed using either the general environmental variable setting export OMP_NUM_THREADS=1 or the ImageMagick specific one export MAGICK_THREAD_LIMIT=1. However, I'd like to integrate the correction into Perl itself, either by passing a configuration directly to PerlMagick (that seems like the "correct" fix) or by setting the environmental variable in the script.
I tried setting $ENV{'OMP_NUM_THREADS'} which did not solve the issue, even though setting that variable before running the script does work. Likewise, trying to run the export command from within the script had no effect.
Is there a better way to correct this?
I would set it in my login script, e.g.
~/.bash_profile, or in the system-wide login script for all users, e.g./etc/profile:Another option might be to edit the system-wide ImageMagick
resources.xml. You can find this using:and it will be in the same directory as
policy.xml.Extra ideas here and here.
The hardest option would be to rebuild ImageMagick from source. In that case, you'd need: