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?