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

cblas.h not found when installing on ubuntu 20.04.1 #1602

Closed
TeaWolf opened this issue Dec 2, 2021 · 16 comments
Closed

cblas.h not found when installing on ubuntu 20.04.1 #1602

TeaWolf opened this issue Dec 2, 2021 · 16 comments
Assignees

Comments

@TeaWolf
Copy link

TeaWolf commented Dec 2, 2021

I've had no problem installing amici on my OSX laptop, but no go on my Ubuntu desktop
Using the following commands as per the documentation.

sudo apt install libatlas-base-dev swig
sudo apt install libhdf5-serial-dev
pip install amici 

I get the following inclusion error.

 amici/src/cblas.cpp:16:13: fatal error: cblas.h: No such file or directory
     16 |    #include <cblas.h>
        |             ^~~~~~~~~
  compilation terminated.
  error: command '/home/llamagod/miniconda3/envs/rjmcmc_thesis/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for amici

I see that there's an issue open talking about making this more flexible.

Is there some kind of fix that I could apply at the moment however?

@TeaWolf TeaWolf added the new Newly created label Dec 2, 2021
@dweindl
Copy link
Member

dweindl commented Dec 2, 2021

Hi @TeaWolf, I am surprised AMICI doesn't find your cblas header files on Ubuntu.

Could you please post the output of locate /usr/*cblas*.h?

If there is no /usr/include/x86_64-linux-gnu/cblas.h but only /usr/include/x86_64-linux-gnu/cblas-atlas.h, you can create the missing symlink manually with sudo ln -s /usr/include/x86_64-linux-gnu/cblas-atlas.h /usr/include/x86_64-linux-gnu/cblas.h. This normally should have happened during the installation of libatlas-base-dev. After that, AMICI installation should succeed. Let me know if not.

@TeaWolf
Copy link
Author

TeaWolf commented Dec 2, 2021

I'm unfamiliar with locate so I used find

find /usr -name '*blas*.h'
/usr/include/x86_64-linux-gnu/cblas.h
/usr/include/x86_64-linux-gnu/cblas-atlas.h
/usr/include/x86_64-linux-gnu/f77blas.h
/usr/include/x86_64-linux-gnu/cblas-openblas.h
/usr/include/x86_64-linux-gnu/openblas_config.h
/usr/include/x86_64-linux-gnu/openblas-pthread/cblas.h
/usr/include/x86_64-linux-gnu/openblas-pthread/f77blas.h
/usr/include/x86_64-linux-gnu/openblas-pthread/openblas_config.h

The file you mention does seem to be there though

@dweindl
Copy link
Member

dweindl commented Dec 2, 2021

The file you mention does seem to be there though

That's funny. Could you please post the full output of pip install -v amici?

@dweindl
Copy link
Member

dweindl commented Dec 2, 2021

Ah. I think the issue is that you are installing AMICI inside a conda environment. This does not use the regular include directories, and therefore, does not find /usr/include/x86_64-linux-gnu/cblas.h.

Does AMICI installation succeed after conda install -c anaconda openblas?

@dweindl
Copy link
Member

dweindl commented Dec 2, 2021

Does AMICI installation succeed after conda install -c anaconda openblas?

You will probably have to set some additional environment variable during AMICI installation and when importing models:
export BLAS_LIBS=-lopenblas.

@TeaWolf
Copy link
Author

TeaWolf commented Dec 3, 2021

Yes sorry it is a conda environment, forgot to mention it.

The combination of

conda install -c conda-forge openblas
export BLAS_LIBS=-lopenblas
pip install amici

Does the trick.

However my conda environment seemed to have an openblas in it before

# Present before conda install -c conda-forge openblas
libopenblas               0.3.18          pthreads_h8fe5266_0    conda-forge
# Present after conda install -c conda-forge openblas
openblas                  0.3.18          pthreads_h4748800_0    conda-forge

Not sure why the other one wasn't doing it.

@dweindl
Copy link
Member

dweindl commented Dec 3, 2021

Does the trick.

Great.

Not sure why the other one wasn't doing it.

The issue was only the missing BLAS_LIBS=-lopenblas then. We will add that to the documentation.
Keep in mind, that you will have to have that set also when import any models.

@TeaWolf
Copy link
Author

TeaWolf commented Dec 3, 2021

well I actually tried BLAS_LIBS=-lopenblas before installing the openblas from conda forge just to see if it would work, but it failed with the same error.

@dweindl
Copy link
Member

dweindl commented Dec 3, 2021

Ah, yes, it seems libopenblas only contains the library, but not the header files.

@TeaWolf
Copy link
Author

TeaWolf commented Dec 3, 2021

ah so that's it then!

dweindl added a commit that referenced this issue Dec 3, 2021
@dweindl dweindl removed the new Newly created label Dec 3, 2021
@dweindl dweindl self-assigned this Dec 5, 2021
@winkmal
Copy link

winkmal commented Jan 26, 2023

Sorry to reopen this again, but I got the same error message during installation with pip:
amici/src/cblas.cpp:16:13: fatal error: cblas.h: No such file or directory

It's an Alma Linux 8.7 system, and blas is installed. (I only have user access, no root privileges.)

$ yum list installed | grep blas
blas.x86_64                                       3.8.0-8.el8                              @appstream
blas-devel.x86_64                                 3.8.0-8.el8                              @powertools
openblas-openmp.x86_64                            0.3.15-4.el8                             @powertools
openblas-srpm-macros.noarch                       2-2.el8                                  @appstream

The output of the commands you mentioned give:

$ locate  /usr/*cblas*.h
$ find /usr -name '*blas*.h'
find: ‘/usr/share/polkit-1/rules.d’: No permission
find: ‘/usr/share/selinux/targeted/default/active’: No permission
/usr/include/cblas/cblas.h
/usr/include/cblas/cblas_f77.h
/usr/include/cblas/cblas_mangling.h
/usr/include/cblas/cblas_test.h
find: ‘/usr/libexec/initscripts/legacy-actions/auditd’: No permission
find: ‘/usr/libexec/warewulf/cgi-bin’: No permission

Any idea what else I could try?

@dweindl
Copy link
Member

dweindl commented Jan 26, 2023

Hi @winkmal, does

BLAS_CFLAGS="$(pkg-config --cflags blas)" BLAS_LIBS="$(pkg-config --libs blas)" pip install amici 

work?

@winkmal
Copy link

winkmal commented Jan 26, 2023

Hi @winkmal, does

BLAS_CFLAGS="$(pkg-config --cflags blas)" BLAS_LIBS="$(pkg-config --libs blas)" pip install amici 

work?

Unfortunately not, I still get the same error message. As far as I understand, this writes the output of the commands in braces into two environment variables, which are then read by pip!?
The individual commands give the following output:

$ pkg-config --cflags blas

$ pkg-config --libs blas
-lblas

@dweindl
Copy link
Member

dweindl commented Jan 26, 2023

Okay, according to that,

BLAS_CFLAGS="-I/usr/include/cblas/" BLAS_LIBS="-lblas" pip install amici 

might work.

Does locate /usr/*cblas.a show anything? If so, change the BLAS_LIBS part according to that:
e.g.

$ locate /usr/*cblas.a
/usr/lib/x86_64-linux-gnu/libcblas.a

->

BLAS_CFLAGS="-I/usr/include/cblas/" BLAS_LIBS="-L/usr/lib/x86_64-linux-gnu/ -lcblas" pip install amici 

@winkmal
Copy link

winkmal commented Jan 26, 2023

Does locate /usr/*cblas.a show anything?

No, nothing.

I tried:

BLAS_CFLAGS="-I/usr/include/cblas/" BLAS_LIBS="-lblas" pip3 install --user amici --upgrade

Now, I get a different error message:

amici/amici_wrap.cxx:174:11: fatal error:  Python.h: No such file or directory
# include <Python.h>
             ^~~~~~~~~~

As a sidenote, I could get AMICI to install and work on an Ubuntu 22.04 based Linux system (Python 3.10.6 via apt). The missing library error(s) are specific to this Alma Linux system.

@dweindl
Copy link
Member

dweindl commented Jan 26, 2023

amici/amici_wrap.cxx:174:11: fatal error: Python.h: No such file or directory

It looks like python header files are not installed by default on your system (or at least not in a default location). On Ubuntu, they come in the python3-dev package, on CentOS python-devel. Are you able to install that?

If you can't use yum to install that, it's somewhat inconvient: You'll have to download that manually, unpack it, and set environment variable LDFLAGS to -L${absolute_path_to_directory_containing_Python.h}.

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

3 participants