无法为PYMC模型编译设置-fbracket-深度参数

问题描述 投票:0回答:1

我正在尝试在 Mac 上训练 pymc 模型(版本 4.4.0)。 我的模型相当复杂,似乎当前的复杂程度导致编译器出现一些问题,因为我收到了此错误

Traceback (most recent call last):
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/vm.py", line 1246, in make_all
    node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/op.py", line 131, in make_thunk
    return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/op.py", line 96, in make_c_thunk
    outputs = cl.make_thunk(
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1202, in make_thunk
    cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1122, in __compile__
    thunk, module = self.cthunk_factory(
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1647, in cthunk_factory
    module = cache.module_from_key(key=key, lnk=self)
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/cmodule.py", line 1229, in module_from_key
    module = lnk.compile_cmodule(location)
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1546, in compile_cmodule
    module = c_compiler.compile_str(
  File "/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/cmodule.py", line 2640, in compile_str
    raise CompileError(
aesara.link.c.exceptions.CompileError: Compilation failed (return status=1):
/usr/bin/clang++ -dynamiclib -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -Wno-c++11-narrowing -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC -undefined dynamic_lookup -I/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/numpy/core/include -I/opt/miniconda3/envs/ic_labor/include/python3.9 -I/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/c_code -L/opt/miniconda3/envs/ic_labor/lib -fvisibility=hidden -o /Users/jisom/.aesara/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.9.19-64/tmpen3swcx7/m0a2528786de976e08afd4eedf68e78061251bf4ba46bb89dfee1a310f6da39eb.so /Users/jisom/.aesara/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.9.19-64/tmpen3swcx7/mod.cpp
/Users/jisom/.aesara/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.9.19-64/tmpen3swcx7/mod.cpp:31954:32: fatal error: bracket nesting level exceeded maximum of 256
        if (!PyErr_Occurred()) {
                               ^
/Users/jisom/.aesara/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.9.19-64/tmpen3swcx7/mod.cpp:31954:32: note: use -fbracket-depth=N to increase maximum nesting level
1 error generated.

该错误建议我“使用-fbracket-深度 = N 来增加最大嵌套级别”。 我尝试通过多种方式将该标志添加到我的代码中。 我尝试过添加

export CFLAGS="-fbracket-depth=1024"
export CXXFLAGS="-fbracket-depth=1024"

到我的.zshrc。 我尝试过添加这个

os.environ['CFLAGS'] = "-fbracket-depth=1024"
os.environ['CXXFLAGS'] = "-fbracket-depth=1024"

在编译模型之前查看我的 python 代码。 我什至尝试过在 python 代码中以这种方式添加它:

aesara.config.cxx = "/usr/bin/clang++ -fbracket-depth=1024"

当我尝试使用环境变量(前两种方式)添加它时,它似乎根本没有被识别,并且我得到了与以前相同的错误。 当我将其添加到

aesara.config.cxx
时,我收到此错误:

Problem occurred during compilation with the command line below:
/usr/bin/clang++ -fbracket-depth=1024 -dynamiclib -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -Wno-c++11-narrowing -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC -undefined dynamic_lookup -I/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/numpy/core/include -I/opt/miniconda3/envs/ic_labor/include/python3.9 -I/opt/miniconda3/envs/ic_labor/lib/python3.9/site-packages/aesara/link/c/c_code -L/opt/miniconda3/envs/ic_labor/lib -fvisibility=hidden -o /Users/jisom/.aesara/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.9.19-64/tmptuxtqjuk/mba10987274f369529454d4a60996746c3927712a0b1b3928446a3c275151e2ee.so /Users/jisom/.aesara/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.9.19-64/tmptuxtqjuk/mod.cpp 

无论如何,我需要找到一种方法在模型编译期间实际修改此参数。 我怎样才能做到这一点?

compilation clang++ pymc compiler-flags
1个回答
0
投票

尝试像这样添加它:

aesara.config.gcc__cxxflags = f"-fbracket-depth={fbracket_depth}"
aesara.config.cxx = "/usr/bin/clang++"

这有效吗?

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.