transformers-php icon indicating copy to clipboard operation
transformers-php copied to clipboard

OpenMP error on PHP 8.2

Open timwhitlock opened this issue 1 year ago • 8 comments

System Info

Running on my Mac Mini (M2 chip) macOS Sonoma (14.6.1).

This occurs in PHP 8.2, but PHP 8.3 seems unaffected.

PHP Version

8.2.19

Environment/Platform

  • [X] Command-line application
  • [ ] Web application
  • [ ] Serverless
  • [ ] Other (please specify)

Description

OMP: Error #15: Initializing libomp.dylib, but found libomp.dylib already initialized.

OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://openmp.llvm.org/

Abort trap: 6

Reproduction

$e = Codewithkyrian\Transformers\Pipelines\pipeline (
    task: Codewithkyrian\Transformers\Pipelines\Task::Embeddings,
    modelName: 'Xenova/all-MiniLM-L6-v2',
);
$e( 'Hello World', normalize: true, pooling: 'mean');

timwhitlock avatar Aug 28 '24 12:08 timwhitlock

Which version of the package are you running with?

CodeWithKyrian avatar Aug 29 '24 04:08 CodeWithKyrian

Sorry, I should have said. I'm currently on 0.5.1, but I noticed it when upgrading from 0.4.4 (which seems unaffected) to 0.5.0 Also happens on current main branch.

It's possible there's some problem with the FFI extension in my PHP 8.2 setup, but I just recompiled and upgraded to PHP 8.2.22. Same problem.

As mentioned, there's no problem under my PHP 8.3 setup, so the issue will go away for me. I thought it was worth reporting anyway.

timwhitlock avatar Aug 29 '24 09:08 timwhitlock

I had the same problem but with php 8.3. After some tests I found that disabling imagick extension fixed the problem.

cappuc avatar Sep 02 '24 15:09 cappuc

I can confirm that my PHP 8.2 environment has imagick installed, but my 8.3 env does not!

timwhitlock avatar Sep 02 '24 15:09 timwhitlock

I have tried for a couple of days now to reproduce the problem on my device and I haven't been able to. I have imagick installed and enabled for both PHP 8.2 and 8.3 on my MacBook Air M1 and I still haven't been able to hit the error.

Is there any more relevant information you could give me to experiment further on my end like how you installed PHP and imagick?

CodeWithKyrian avatar Sep 04 '24 21:09 CodeWithKyrian

I installed the extension from https://github.com/shivammathur/homebrew-extensions not with pecl

cappuc avatar Sep 05 '24 07:09 cappuc

I installed the imagemagick library via Homebrew (7.1.1-38). I compiled the imagick PHP extension (3.7.0) from source (downloaded from PECL). These are all the latest versions.

I'm out of my depth here, but happy to provide any info you need, or try things / recompile things.

timwhitlock avatar Sep 05 '24 09:09 timwhitlock

I can reproduce that as well. Also using https://github.com/shivammathur/homebrew-extensions. libomp is apparently a dependency of imagick. For PHP 8.3 for example, you can run brew deps shivammathur/extensions/[email protected] to see the dependencies and there, libomp is part of the list 😊

Toflar avatar Aug 20 '25 20:08 Toflar