Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Uncaught FFI\Exception: Failed loading scope 'blas' #3

Closed
sneakyimp opened this issue Nov 30, 2022 · 1 comment
Closed

Comments

@sneakyimp
Copy link

sneakyimp commented Nov 30, 2022

I have attempted to run the sample PHP script in your README file and it encounters a fatal error:

PHP Fatal error: Uncaught FFI\Exception: Failed loading scope 'blas' in /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php:28
Stack trace:
#0 /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php(28): FFI::scope('blas')
#1 /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php(73): Np\core\blas::init()
#2 /Users/sneakyimp/np/vendor/ghostjat/np/src/linAlgb/linAlg.php(45): Np\core\blas::gemm(Object(Np\matrix), Object(Np\matrix), Object(Np\matrix))
#3 /Users/sneakyimp/np/vendor/ghostjat/np/src/linAlgb/linAlg.php(30): Np\matrix->dotMatrix(Object(Np\matrix))
#4 /Users/sneakyimp/np/foo.php(8): Np\matrix->dot(Object(Np\matrix))
#5 {main}
thrown in /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php on line 28

Fatal error: Uncaught FFI\Exception: Failed loading scope 'blas' in /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php:28
Stack trace:
#0 /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php(28): FFI::scope('blas')
#1 /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php(73): Np\core\blas::init()
#2 /Users/sneakyimp/np/vendor/ghostjat/np/src/linAlgb/linAlg.php(45): Np\core\blas::gemm(Object(Np\matrix), Object(Np\matrix), Object(Np\matrix))
#3 /Users/sneakyimp/np/vendor/ghostjat/np/src/linAlgb/linAlg.php(30): Np\matrix->dotMatrix(Object(Np\matrix))
#4 /Users/sneakyimp/np/foo.php(8): Np\matrix->dot(Object(Np\matrix))
#5 {main}
thrown in /Users/sneakyimp/np/vendor/ghostjat/np/src/core/blas.php on line 28

I have the FFI extension loaded in PHP. The FFI documentation is sorely incomplete so I'm not at all sure what this scope() call is supposed to do. The docs mention a #define statement, which you appear to have in blas.h:

#define FFI_SCOPE "blas"

EDIT: I'm running this script in PHP 8.1 on MacOs. I have the FFI extension loaded, and brew shows openblas and lapack are installed.

I have also confirmed the error with PHP 8.1 on Ubuntu 20.04 LTS.

@ghostjat ghostjat pinned this issue Dec 29, 2022
@ghostjat
Copy link
Owner

Hi, @sneakyimp
you have to update php.ini
with following settings
zend_extension=opcache.so
opcache.enable_cli = 1
ffi.enable=preload
opcache.preload=preload.php

@ghostjat ghostjat unpinned this issue Jan 8, 2023
@ghostjat ghostjat closed this as completed Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants