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

could not import: cblas_ddot #38

Closed
sieste opened this issue Mar 14, 2021 · 5 comments
Closed

could not import: cblas_ddot #38

sieste opened this issue Mar 14, 2021 · 5 comments

Comments

@sieste
Copy link

sieste commented Mar 14, 2021

The following works fine

import neo
var v1 = randomVector(5)
echo v1

but the following throws an error

import neo
var v1 = randomVector(5)
var v2 = randomVector(5)
echo v1 * v2

could not import: cblas_ddot

Similar when echo 2.0 * v1 I get could not import: cblas_dcopy. On the other hand echo min(v1) works.

Any ideas?

stefan ~/folders/nim [0] > nimble dump neo
name: "neo"
version: "0.3.1"
author: "Andrea Ferretti"
desc: "Linear Algebra for Nim"
license: "Apache2"
skipDirs: "tests, benchmarks, htmldocs"
skipFiles: "_config.yml"
skipExt: ""
installDirs: "neo"
installFiles: "neo.nim"
installExt: ""
requires: "nim >= 0.18.0, nimblas >= 0.2.0, nimcuda >= 0.1.6, nimlapack >= 0.1.1"
bin: ""
binDir: ""
srcDir: ""
backend: "c"

stefan ~/folders/nim [0] > nim -v
Nim Compiler Version 1.4.4 [Linux: amd64]
Compiled at 2021-03-09
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release -d:nativeStackTrace

stefan ~/folders/nim [0] > pacman -Ql openblas
openblas /usr/
openblas /usr/include/
openblas /usr/include/f77blas.h
openblas /usr/include/openblas_config.h
openblas /usr/lib/
openblas /usr/lib/cmake/
openblas /usr/lib/cmake/openblas/
openblas /usr/lib/cmake/openblas/OpenBLASConfig.cmake
openblas /usr/lib/cmake/openblas/OpenBLASConfigVersion.cmake
openblas /usr/lib/libblas.so
openblas /usr/lib/libblas.so.3
openblas /usr/lib/libopenblas.so
openblas /usr/lib/libopenblas.so.3
openblas /usr/lib/libopenblasp-r0.3.13.so
openblas /usr/lib/pkgconfig/
openblas /usr/lib/pkgconfig/blas.pc
openblas /usr/lib/pkgconfig/openblas.pc
openblas /usr/share/
openblas /usr/share/licenses/
openblas /usr/share/licenses/openblas/
openblas /usr/share/licenses/openblas/LICENSE

stefan ~/folders/nim [0] > pacman -Ql cblas
cblas /usr/
cblas /usr/include/
cblas /usr/include/cblas.h
cblas /usr/include/cblas_f77.h
cblas /usr/include/cblas_mangling.h
cblas /usr/include/cblas_test.h
cblas /usr/lib/
cblas /usr/lib/cmake/
cblas /usr/lib/cmake/cblas-3.9.0/
cblas /usr/lib/cmake/cblas-3.9.0/cblas-config-version.cmake
cblas /usr/lib/cmake/cblas-3.9.0/cblas-config.cmake
cblas /usr/lib/cmake/cblas-3.9.0/cblas-targets-release.cmake
cblas /usr/lib/cmake/cblas-3.9.0/cblas-targets.cmake
cblas /usr/lib/libcblas.so
cblas /usr/lib/libcblas.so.3
cblas /usr/lib/libcblas.so.3.9.0
cblas /usr/lib/pkgconfig/
cblas /usr/lib/pkgconfig/cblas.pc
@sieste
Copy link
Author

sieste commented Mar 14, 2021

Compiling with -d:blas=cblas solves the issue. Not sure why, though.

Hat tip: SciNim/nimblas#3 (comment)

@andreaferretti
Copy link
Owner

Some functions are pure nim, for instance min(v1), so there will be no problem running them.

Most of the functionality, though, comes from BLAS, which is dinamically linked. Getting the right library on all platforms is a little tricky, which is why you may have to pass the CBLAS (I use the C API) library name explicitly

@sieste
Copy link
Author

sieste commented Mar 15, 2021

Thank you, that makes sense. Is -d:blas=cblas the recommended way to specify the correct library name? Is there any way to specify it in the source file rather than having to use --define?

@andreaferretti
Copy link
Owner

andreaferretti commented Mar 15, 2021

It depends on the libraries installed in your system. Assuming you are on Linux, the library could be called libblas.so, libcblas.so, libopenblas.so... Similarly on other platforms. It really depends, there are many implementations of BLAS, and the --define flag is used to select one.

To answer your second question, no, you cannot specify this in the source code, it is an external flag.

@sieste
Copy link
Author

sieste commented Mar 15, 2021

Thank you, -d:blas=cblas it is then. I have cblas and openblas installed, but only -d:blas=cblas works, whereas -d:blas=openblas generates the same error could not import: cblas_ddot.

@sieste sieste closed this as completed Mar 15, 2021
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