Numba无法识别已安装的TBB/OMB线程层问题求助
Numba无法识别已安装的TBB/OMB线程层问题
问题描述
已在虚拟环境中安装TBB(2021.9.0)和OMB(0.1.dev0),但Numba运行时及CLI工具均无法识别这两个线程层,提示Disabled due to Unknown import problem。当前设置NUMBA_THREADING_LAYER=TBB,系统信息如下:
System info: -------------------------------------------------------------------------------- __Time Stamp__ Report started (local time) : 2023-06-03 12:51:22.078030 UTC start time : 2023-06-03 16:51:22.078037 Running time (s) : 0.936195 __Hardware Information__ Machine : x86_64 CPU Name : skylake CPU Count : 12 Number of accessible CPUs : ? List of accessible CPUs cores : ? CFS Restrictions (CPUs worth of runtime) : None CPU Features : 64bit adx aes avx avx2 bmi bmi2 clflushopt cmov crc32 cx16 cx8 f16c fma fsgsbase fxsr invpcid lzcnt mmx movbe pclmul popcnt prfchw rdrnd rdseed rtm sahf sgx sse sse2 sse3 sse4.1 sse4.2 ssse3 xsave xsavec xsaveopt xsaves Memory Total (MB) : 32768 Memory Available (MB) : 13459 __OS Information__ Platform Name : macOS-13.3.1-x86_64-i386-64bit Platform Release : 22.4.0 OS Name : Darwin OS Version : Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 OS Specific Version : 13.3.1 x86_64 Libc Version : ? __Python Information__ Python Compiler : Clang 14.0.3 (clang-1403.0.22.14.1) Python Implementation : CPython Python Version : 3.9.6 Python Locale : en_US.UTF-8 __Numba Toolchain Versions__ Numba Version : 0.57.0 llvmlite Version : 0.40.0 __LLVM Information__ LLVM Version : 14.0.6 __CUDA Information__ CUDA Device Initialized : False CUDA Driver Version : ? CUDA Runtime Version : ? CUDA NVIDIA Bindings Available : ? CUDA NVIDIA Bindings In Use : ? CUDA Minor Version Compatibility Available : ? CUDA Minor Version Compatibility Needed : ? CUDA Minor Version Compatibility In Use : ? CUDA Detect Output: None CUDA Libraries Test Output: None __NumPy Information__ NumPy Version : 1.24.3 NumPy Supported SIMD features : ('MMX', 'SSE', 'SSE2', 'SSE3', 'SSSE3', 'SSE41', 'POPCNT', 'SSE42', 'AVX', 'F16C', 'FMA3', 'AVX2') NumPy Supported SIMD dispatch : ('SSSE3', 'SSE41', 'POPCNT', 'SSE42', 'AVX', 'F16C', 'FMA3', 'AVX2', 'AVX512F', 'AVX512CD', 'AVX512_KNL', 'AVX512_SKX', 'AVX512_CLX', 'AVX512_CNL', 'AVX512_ICL') NumPy Supported SIMD baseline : ('SSE', 'SSE2', 'SSE3') NumPy AVX512_SKX support detected : False __SVML Information__ SVML State, config.USING_SVML : False SVML Library Loaded : False llvmlite Using SVML Patched LLVM : True SVML Operational : False __Threading Layer Information__ TBB Threading Layer Available : False +---> Disabled due to Unknown import problem. OpenMP Threading Layer Available : False +---> Disabled due to Unknown import problem. Workqueue Threading Layer Available : True +--->Workqueue imported successfully. __Numba Environment Variable Information__ NUMBA_THREADING_LAYER : TBB __Conda Information__ Conda not available. __Installed Packages__ Package Version -------------------------------- --------- appnope 0.1.3 asttokens 2.2.1 async-timeout 4.0.2 avro 1.11.0 azure-core 1.26.4 azure-functions 1.8.0 azure-identity 1.7.1 azure-messaging-webpubsubservice 1.0.1 azure-storage-blob 12.16.0 backcall 0.2.0 cachetools 5.3.0 certifi 2022.12.7 cffi 1.15.1 charset-normalizer 3.1.0 click 8.1.3 cloudpickle 2.2.1 comm 0.1.3 contourpy 1.0.7 cryptography 40.0.2 cycler 0.11.0 dask 2023.4.0 dataclasses-json 0.5.7 debugpy 1.6.7 decorator 5.1.1 Deprecated 1.2.13 executing 1.2.0 fonttools 4.39.3 fsspec 2023.4.0 google-api-core 2.11.0 google-auth 2.17.3 googleapis-common-protos 1.59.0 idna 3.4 importlib-metadata 6.6.0 importlib-resources 5.12.0 ipykernel 6.22.0 ipython 8.13.1 isodate 0.6.1 jedi 0.18.2 Jinja2 3.1.2 joblib 1.2.0 jupyter_client 8.2.0 jupyter_core 5.3.0 kiwisolver 1.4.4 llvmlite 0.40.0 locket 1.0.0 MarkupSafe 2.1.2 marshmallow 3.19.0 marshmallow-enum 1.5.1 matplotlib 3.7.1 matplotlib-inline 0.1.6 metakernel 0.29.4 msal 1.22.0 msal-extensions 0.3.1 msgpack 1.0.5 msrest 0.7.1 mypy-extensions 1.0.0 nest-asyncio 1.5.6 numba 0.57.0 numpy 1.24.3 oauthlib 3.2.2 oct2py 5.6.0 octave_kernel 0.35.1 OMB 0.1.dev0 opencensus 0.11.2 opencensus-context 0.1.3 opencensus-ext-azure 1.1.9 packaging 23.1 pandas 2.0.1 parso 0.8.3 partd 1.4.0 patsy 0.5.3 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.5.0 pip 23.1.2 platformdirs 3.5.0 portalocker 2.7.0 prompt-toolkit 3.0.38 protobuf 3.19.6 psutil 5.9.5 psycopg2-binary 2.9.3 ptyprocess 0.7.0 pure-eval 0.2.2 pyasn1 0.5.0 pyasn1-modules 0.3.0 pycparser 2.21 Pygments 2.15.1 PyJWT 2.6.0 pyparsing 3.0.9 python-dateutil 2.8.2 pytz 2023.3 PyYAML 6.0 pyzmq 25.0.2 redis 4.2.0 requests 2.29.0 requests-oauthlib 1.3.1 rsa 4.9 scikit-learn 1.1.0 scipy 1.10.1 setuptools 58.0.4 six 1.16.0 sortedcontainers 2.4.0 stack-data 0.6.2 statsmodels 0.13.5 stumpy 1.11.1 tbb 2021.9.0 tblib 1.7.0 threadpoolctl 3.1.0 toolz 0.12.0 tornado 6.3.1 tqdm 4.65.0 traitlets 5.9.0 typing_extensions 4.5.0 typing-inspect 0.8.0 tzdata 2023.3 urllib3 1.26.15 wcwidth 0.2.6 websockets 10.2 wrapt 1.15.0 zict 3.0.0 zipp 3.15.0 No errors reported. __Warning log__ Warning (cuda): CUDA driver library cannot be found or no CUDA enabled devices are present. Exception class: <class 'numba.cuda.cudadrv.error.CudaSupportError'> Warning: Conda not available. Error was [Errno 2] No such file or directory: 'conda' --------------------------------------------------------------------------------
解决建议
针对TBB的排查与修复
配置TBB库路径
macOS下pip安装的TBB库可能未被系统自动识别,找到虚拟环境中TBB的lib目录(如venv/lib/python3.9/site-packages/tbb/lib),将其添加到环境变量:export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/path/to/your/venv/lib/python3.9/site-packages/tbb/lib执行
numba -s重新检查TBB状态。验证版本兼容性
Numba 0.57.0建议搭配TBB 2021.x稳定版,当前安装的2021.9.0理论兼容,可尝试降级测试:pip uninstall tbb && pip install tbb==2021.5.0检查Python导入有效性
在Python交互环境中执行以下代码,确认TBB可正常导入:from tbb import tbb_thread print(tbb_thread.__file__)若导入失败,根据报错修复依赖缺失或架构不匹配问题。
针对OMB的排查
重新安装稳定版OMB
当前使用的OMB为开发版,存在适配风险,从源码重新安装:pip uninstall OMB && pip install git+https://github.com/IntelPython/omb.git验证导入:
import omb。启用OMB支持
设置环境变量显式启用OMB:export NUMBA_ENABLE_OMB=1
通用修复步骤
升级Numba与llvmlite
旧版本Numba存在线程层兼容问题,升级至最新稳定版:pip install --upgrade numba llvmlite确认架构匹配
确保虚拟环境与系统均为x86_64架构,执行以下命令验证:import platform; print(platform.machine())
内容的提问来源于stack exchange,提问作者Dave
相关产品推荐
相关产品推荐

