代码之家  ›  专栏  ›  技术社区  ›  Bussller Junior Vieira

numba/npyufunc/omppool.cpp:5:10:严重错误:找不到“omp.h”文件

  •  1
  • Bussller Junior Vieira  · 技术社区  · 6 年前

    专家,

    我尝试在虚拟的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 12 python3.6 . 我有软链接 llvm7 作为默认值,作为一个信息,这将是有帮助的。

    我想makefile在找 欧姆 与实际位置不同的位置。如果是这样,在 pip 安装?

    随访: 设置 CPPFLAGS 正如@hoefring所建议的,确实解决了上述问题。但是,下一个错误如下:

     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
    

    我不知道应该包括哪一个。

    谢谢你的努力。

    1 回复  |  直到 6 年前
        1
  •  2
  •   hoefling    6 年前

    Linux

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

    $ sudo apt install libgcc-7-dev
    

    FreeBSD

    标题由提供 devel/openmp . 安装时可以使用:

    $ sudo pkg install devel/openmp
    

    这个地方 欧姆 进入之内 /usr/local/include ,默认情况下包括dirs。

    自定义包括

    如果要在自定义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 )