Comments (12)
put fn main() {println!("cargo:rustc-link-lib=framework=Accelerate") }
into a file build.rs
at the root of your directory and add features = ["accelerate"]
to the blas-src
package in your Cargo.toml
.
from ndarray-linalg.
Hello @matthagan15 ,
I tried but it did not work because openblas is still linked. ndarray does rely on blas-src. So the problem is with openblas but not blas-src. This is how cargo.toml looks like:
ndarray = {version = "0.15", features=["rayon", "serde","blas"]}
ndarray-linalg = {version = "0.16",default-features = false}
blas-src = { version = "0.8", features = ["accelerate"] }
openblas-src = { version = "0.10", features = ["cblas", "system"] }
[features]
default = []
intel-mkl-static = ["ndarray/blas","ndarray-linalg/intel-mkl-static"]
openblas-static = ["ndarray/blas", "ndarray-linalg/openblas-static"]
openblas-system = ["ndarray/blas", "ndarray-linalg/openblas-system"]
Thank,
Jianshu
from ndarray-linalg.
With the above configuration, accelerate is actually working, but openblas is still linked, see my binary link status after using the openblas-system feature (via otool -L on macOS):
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/opt/homebrew/opt/openblas/lib/libopenblas.0.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
Thanks,
Jianshu
from ndarray-linalg.
That is the openblas-system feature in ndarray-linalg is still using openblas-src system feature. Any idea why?
Thanks,
Jianshu
from ndarray-linalg.
yes you should not be using openblas. use the feature "blas" on ndarray and use the crate "blas-src" with the feature "accelerate"
from ndarray-linalg.
Hello @matthagan15 ,
But my question how to use accelerate backend to replace openblas, I am using openblas actually. That is to say accelerate is only for blas, but not for openblas, meaning I have no way to get rid of openblas right because I need both blas and openblas feature.
Thanks,
Jianshu
from ndarray-linalg.
I also tried uninstall openblas on my system but has error with the same above configuration:
error: linking with cc
failed: exit status: 1
|
= note: LC_ALL="C" PATH="/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Users/jianshuzhao/miniconda3/condabin:/usr/local/bin:/Users/jianshuzhao/Github/bowtie2-2.5.0-macos-arm64:/opt/homebrew/bin:/Users/jianshuzhao/bin:/opt/homebrew/opt/bzip2/bin:/Users/jianshuzhao/Github/mummer-4.0.0beta5/bin:/Users/jianshuzhao/go/bin:/Users/jianshuzhao/Github/hmmer-h3-arm/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/Cellar/coreutils/9.1/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jianshuzhao/.cargo/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/go/bin:/opt/X11/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "arm64" "/var/folders/mr/8qybn91j5fgdbrcdmq7ckftw0000gn/T/rustc3rP5ZO/symbols.o" "/Users/jianshuzhao/Documents/annembed/target/release/deps/embed-958d02413793165a.embed.3c7a159a26d98867-cgu.03.rcgu.o" "-L" "/Users/jianshuzhao/Documents/annembed/target/release/deps" "-L" "/opt/homebrew/opt/openblas/lib" "-L" "/opt/homebrew/opt/libomp/lib" "-L" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-a2bfdcafe5010b58.rlib" "-framework" "Accelerate" "-lopenblas" "-liconv" "-lSystem" "-lc" "-lm" "-L" "/Users/jianshuzhao/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/jianshuzhao/Documents/annembed/target/release/deps/embed-958d02413793165a" "-Wl,-dead_strip" "-nodefaultlibs"
= note: ld: warning: directory not found for option '-L/opt/homebrew/opt/openblas/lib'
ld: library not found for -lopenblas
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: could not compile annembed
(bin "embed") due to previous error
indicating that with this configuration, cc/clang is still try to find openblas instead of accelerate. Any idea.
Thanks,
Jianshu
from ndarray-linalg.
Try this:
ndarray = {version = "0.15", features=["rayon", "serde","blas"]}
ndarray-linalg = {version = "0.16",default-features = false}
blas-src = { version = "0.8", features = ["accelerate"] }
[features]
default = []
and then add build.rs
with:
fn main() {println!("cargo:rustc-link-lib=framework=Accelerate")}
in it.
you should only be using one blas src.
from ndarray-linalg.
Hello @matthagan15 ,
Many thanks! the problem is solved!! Greatly appreciated openblas must be uninstalled first and then it is successful:
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
That is we do not specific any backend but let rust to choose and allow the accelerate in build.rs.
Thanks a again,
Jianshu
from ndarray-linalg.
I'm pretty sure you don't have to uninstall openblas, I still have it installed via home brew, but if it worked for you then good!
from ndarray-linalg.
Hello @matthagan15 ,
I have ran into another case where:
ndarray = {version = "0.15", features=["rayon", "serde","blas"]}
ndarray-linalg = {version = "0.16", default-features = false}
lapacke = {version = "0.5"}
#openblas-src = {version = "0.10", optional = true, default=false}
lapack-src = {version = "0.8", features = ["accelerate"]}
blas-src = {version = "0.8", features = ["accelerate"]}
I want to use the accelerate for lapack-src and blas-src, and as always ndarray and ndarray-linalg are all using the blas-src backend. However, I also need to use lapacke, I have the same build.rs mentioned above. I have the following error when linking (no errors if change back to openblas-src on the M1 Mac):
= note: Undefined symbols for architecture arm64:
"_LAPACKE_dggsvd3", referenced from:
graphembed::embed::atp::gsvd::GSvd$LT$F$GT$::do_gsvd::hd2a830ebb48b0ec3 in embed-11acb125d144fce5.embed.4061c9940487d9c0-cgu.09.rcgu.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It seems of the the lapacke problem but not others. I tried both clang and gcc as the compiler since lapacke is just a rust wrapper around lapacke(C).
Many thanks,
Jianshu
from ndarray-linalg.
Related Issues (20)
- SolveH uses incorrect triangle
- better error handling for LUFactorized's solve_inplace
- Switch to GitHub Release from CHANGELOG.md HOT 1
- Uninitialized memory management in lax crate
- static gfortran link HOT 1
- Deterministic testing HOT 1
- Support Veclib of MacOS HOT 5
- ARM clibs with u8 HOT 4
- Autovectorization on x86
- solve doesn't return the expected vector
- Add keyword #linear-agebra for cargo.io discovery
- LAPACK linker errors HOT 1
- Link problem with intel-mkl on Windows when using both stats + linalg in a single project HOT 1
- How to install on OSX HOT 1
- Build fails on arm64 mac running linux. HOT 1
- Unnecessary trait bound
- Eigh eigenvectors are inverted
- `error LNK2019: unresolved external symbol zgtcon_` under Windows HOT 4
- Linking on Debian: libblas instead of libcblas
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ndarray-linalg.