【问题标题】:numba/npyufunc/omppool.cpp:5:10: fatal error: 'omp.h' file not foundnumba/npyufunc/omppool.cpp:5:10:致命错误:找不到“omp.h”文件
【发布时间】:2019-01-13 05:09:10
【问题描述】:

专家,

我正在尝试在虚拟 python 环境中使用 pip 安装 numba。我遇到以下错误:

错误日志:

cc: numba/cuda/cudadrv/_extras.c
    cc -shared -lpthread -L/usr/local/lib -fstack-protector build/temp.freebsd-12.0-RELEASE-p2-amd64-3.6/numba/cuda/cudadrv/_extras.o -L/usr/local/lib -lpython3.6m -o build/lib.freebsd-12.0-RELEASE-p2-amd64-3.6/numba/cuda/cudadrv/_extras.so
    building 'numba.npyufunc.omppool' extension
    C compiler: cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector -fno-strict-aliasing -fPIC

    compile options: '-I/home/russellb/py_devel/pyPlay/include -I/usr/local/include/python3.6m -c'
    extra options: '-fopenmp -std=c++11'
    cc: numba/npyufunc/omppool.cpp
    cc: numba/npyufunc/gufunc_scheduler.cpp
    numba/npyufunc/omppool.cpp:5:10: fatal error: 'omp.h' file not found
    #include <omp.h>
             ^~~~~~~
    1 error generated.
    numba/npyufunc/omppool.cpp:5:10: fatal error: 'omp.h' file not found
    #include <omp.h>
             ^~~~~~~
    1 error generated.
    error: Command "cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector -fno-strict-aliasing -fPIC -I/home/russellb/py_devel/pyPlay/include -I/usr/local/include/python3.6m -c numba/npyufunc/omppool.cpp -o build/temp.freebsd-12.0-RELEASE-p2-amd64-3.6/numba/npyufunc/omppool.o -fopenmp -std=c++11" failed with exit status 1
error
Cleaning up...
  Removing source in /tmp/pip-install-g3ckpog3/numba
Removed build tracker '/tmp/pip-req-tracker-21vj3szg'
Command "/home/russellb/py_devel/pyPlay/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g3ckpog3/numba/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-lf_sxfnx/install-record.txt --single-version-externally-managed --compile --install-headers /home/russellb/py_devel/pyPlay/include/site/python3.6/numba" failed with error code 1 in /tmp/pip-install-g3ckpog3/numba/
Exception information:
Traceback (most recent call last):
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 366, in run
    use_user_site=options.use_user_site,
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/req/__init__.py", line 49, in install_given_reqs
    **kwargs
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 791, in install
    spinner=spinner,
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 705, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip._internal.exceptions.InstallationError: Command "/home/russellb/py_devel/pyPlay/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g3ckpog3/numba/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-lf_sxfnx/install-record.txt --single-version-externally-managed --compile --install-headers /home/russellb/py_devel/pyPlay/include/site/python3.6/numba" failed with error code 1 in /tmp/pip-install-g3ckpog3/numba/

omp.h 存在于/usr/local/llvm70/lib/clang/7.0.1/include/omp.h 中。

非常感谢您对解决/修复此问题的任何帮助。我正在运行FreeBSD 12python3.6。我已将 llvm7 软链接为默认值,因为这样的信息会有所帮助。

我认为,makefile 在与实际位置不同的位置寻找omp.h。如果是这样,有没有办法可以在pip 安装期间将路径作为参数传递?

跟进: 按照@hoefling 的建议设置CPPFLAGS 确实可以解决上述问题。但是,下一个错误如下:

 C compiler: cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector -fno-strict-aliasing -I /usr/local/llvm70/lib/clang/7.0.1/include/ -fPIC

    compile options: '-I/home/russellb/py_devel/pyPlay/include -I/usr/local/include/python3.6m -c'
    extra options: '-fopenmp -std=c++11'
    cc: numba/npyufunc/omppool.cpp
    cc: numba/npyufunc/gufunc_scheduler.cpp
    c++ -shared -lpthread -L/usr/local/lib -fstack-protector -I /usr/local/llvm70/lib/clang/7.0.1/include/ build/temp.freebsd-12.0-RELEASE-p2-amd64-3.6/numba/npyufunc/omppool.o build/temp.freebsd-12.0-RELEASE-p2-amd64-3.6/numba/npyufunc/gufunc_scheduler.o -L/usr/local/lib -lpython3.6m -o build/lib.freebsd-12.0-RELEASE-p2-amd64-3.6/numba/npyufunc/omppool.so -fopenmp
    building 'numba.npyufunc.workqueue' extension
    C compiler: cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector -fno-strict-aliasing -I /usr/local/llvm70/lib/clang/7.0.1/include/ -fPIC

    compile options: '-I/home/russellb/py_devel/pyPlay/include -I/usr/local/include/python3.6m -c'
    cc: numba/npyufunc/workqueue.c
    cc: numba/npyufunc/gufunc_scheduler.cpp
    numba/npyufunc/workqueue.c:22:10: fatal error: 'alloca.h' file not found
    #include <alloca.h>
             ^~~~~~~~~~
    1 error generated.
    numba/npyufunc/workqueue.c:22:10: fatal error: 'alloca.h' file not found
    #include <alloca.h>
             ^~~~~~~~~~
    1 error generated.
    error: Command "cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector -fno-strict-aliasing -I /usr/local/llvm70/lib/clang/7.0.1/include/ -fPIC -I/home/russellb/py_devel/pyPlay/include -I/usr/local/include/python3.6m -c numba/npyufunc/workqueue.c -o build/temp.freebsd-12.0-RELEASE-p2-amd64-3.6/numba/npyufunc/workqueue.o" failed with exit status 1
error
Cleaning up...
  Removing source in /tmp/pip-install-fbsigyza/numba
Removed build tracker '/tmp/pip-req-tracker-0v_6_gji'
Command "/home/russellb/py_devel/pyPlay/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-fbsigyza/numba/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-pcr7ap84/install-record.txt --single-version-externally-managed --compile --install-headers /home/russellb/py_devel/pyPlay/include/site/python3.6/numba" failed with error code 1 in /tmp/pip-install-fbsigyza/numba/
Exception information:
Traceback (most recent call last):
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 366, in run
    use_user_site=options.use_user_site,
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/req/__init__.py", line 49, in install_given_reqs
    **kwargs
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 791, in install
    spinner=spinner,
  File "/home/russellb/py_devel/pyPlay/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 705, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip._internal.exceptions.InstallationError: Command "/home/russellb/py_devel/pyPlay/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-fbsigyza/numba/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-pcr7ap84/install-record.txt --single-version-externally-managed --compile --install-headers /home/russellb/py_devel/pyPlay/include/site/python3.6/numba" failed with error code 1 in /tmp/pip-install-fbsigyza/numba/

我在以下位置有两个alloca.h

/usr/src/contrib/ofed/libibverbs/alloca.h
/usr/src/cddl/compat/opensolaris/include/alloca.h

我不知道哪个是正确的。

感谢您的所有努力。

【问题讨论】:

    标签: python python-3.x pip llvm numba


    【解决方案1】:

    Linux

    omp.h 通常是gcc 编译器的一部分,例如在 Ubuntu 上安装了

    $ sudo apt install libgcc-7-dev
    

    FreeBSD

    标头由devel/openmp 提供。你可以安装它:

    $ sudo pkg install devel/openmp
    

    这会将omp.h 放入/usr/local/include,默认情况下应该包含目录。

    自定义包含

    如果您想在自定义包含目录下附加标头,请使用CPPFLAGS/CFLAGS 环境变量:

    $ CPPFLAGS="-I/usr/local/llvm70/lib/clang/7.0.1/include/" pip install numba
    

    对于第二个错误,我想numba 编写时没有考虑到 FreeBSD(也不确定 CUDA 和 FreeBSD 是否总体上运行良好)。也许open an issue?我想numba/npyufunc/workqueue.c 的补丁建议应该是

     #include <pthread.h>
     #include <unistd.h>
    +#if !defined (__FreeBSD__)
     #include <alloca.h>
    +#endif
     #define NUMBA_PTHREAD
     #endif
    

    除此之外,请尝试添加第二个 (/usr/src/cddl/compat/opensolaris/include/alloca.h)。

    【讨论】:

    • 谢谢@hoefling。我安装了gcc8,并且omp.h 位于您指定的位置。我尝试按照您的建议设置CPPFLAGS。但是,pip3 不尊重这一点,同样的错误结果。默认omp.h 位置是/usr/local/include/omp.h,这与'/usr/local/llvm70/lib/clang/7.0.1/include/omp.h` 没有什么不同(我已经区分了它们)
    • 通过将CPPFLAGS 设置为.basrc 来解决该错误。但是,还有另一个错误:我正在编辑我的问题以包含新错误。
    • 嗯,将CPPFLAGS 直接传递给pip install 命令应该与将其放入.bashrc 没有什么不同。您还可以导出 env var,以便将其应用于当前会话中的所有命令:export CPPFLAGS="-I/usr/local/llvm70/lib/clang/7.0.1/include/"export CPPFLAGS="-I/usr/local/include/",然后调用 pip install numba 应该尊重更改后的 env。
    • 至于您的第二个问题,我怀疑这是numba 中的一个问题 - 也许打开一个问题会很好(检查答案中的更新)。
    • 不走运 alloca.h 路径包含。在寻找了CUDAFreeBSD 之后,我感觉这个组合还不能使用,而且我看不到在近功能中会发生任何事情。但是,我要打开一个问题。谢谢@hoefling。感谢您的帮助。
    猜你喜欢
    • 2021-06-14
    • 2019-09-01
    • 1970-01-01
    • 2020-10-02
    • 2015-01-20
    • 2014-12-21
    • 2013-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多