You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

mgcv::bam()多线程运行时DGEMM报错-3的原因是什么?

使用mgcv::bam()并行运行复杂混合模型时出现BLAS/LAPACK错误

我在PC端(RStudio)及公司Linux高性能计算系统上,使用mgcv::bam()运行混合模型时,最复杂的模型触发了如下错误。经排查,问题与并行计算设置直接相关——移除nthreads = 12参数后模型可正常运行,但耗时极久。

错误信息

Error in `pqr2()`:
! BLAS/LAPACK routine 'DGEMM ' gave error code -3
Backtrace:
 1. mgcv::bam(...)
 2. mgcv:::bam.fit(...)
 3. mgcv:::qr_update(...)
 4. mgcv:::pqr2(Xn, nt)

注:无法制作最小可复现示例(MWE),因为仅在最复杂的模型中出现该问题。

可正常运行的模型(带多线程)

# working model 8
F1.F.wigan.gamm8 <- bam(F2 ~
                  s(percent, k=4)  + #difference in height of traj
                  s(percent, by=age_ord, k=4) +
                  s(percent, by=sex_ord, k=4) +
                  s(percent, by=fol_ord, k = 4) +
                  s(percent, by=style_med, k=4) +
                  ti(percent, dur) + #interaction between shape and duration
                  s(percent, ID, bs="fs", xt="cr",m=1,k=4) + #random smooth
                  # s(percent, traj, bs="fs", xt="cr",m=1,k=4) #random smooth
                  s(percent, word, bs="fs", xt="cr",m=1,k=4) #random smooth
               , data=data_F_wigan,method="fREML", nthreads = 12)

可正常运行的模型(无多线程)

# working model 9 no parallel
F1.F.wigan.gamm8 <- bam(F2 ~
                  s(percent, k=4)  + #difference in height of traj
                  s(percent, by=age_ord, k=4) +
                  s(percent, by=sex_ord, k=4) +
                  s(percent, by=fol_ord, k = 4) +
                  s(percent, by=style_med, k=4) +
                  ti(percent, dur) + #interaction between shape and duration
                  s(percent, ID, bs="fs", xt="cr",m=1,k=4) + #random smooth
                  s(percent, traj, bs="fs", xt="cr",m=1,k=4) + #random smooth
                  s(percent, word, bs="fs", xt="cr",m=1,k=4) #random smooth
               , data=data_F_wigan,method="fREML")

报错的模型(带多线程)

# model causing error
F1.F.wigan.gamm8 <- bam(F2 ~
                  s(percent, k=4)  + #difference in height of traj
                  s(percent, by=age_ord, k=4) +
                  s(percent, by=sex_ord, k=4) +
                  s(percent, by=fol_ord, k = 4) +
                  s(percent, by=style_med, k=4) +
                  ti(percent, dur) + #interaction between shape and duration
                  s(percent, ID, bs="fs", xt="cr",m=1,k=4) + #random smooth
                  s(percent, traj, bs="fs", xt="cr",m=1,k=4) + #random smooth
                  s(percent, word, bs="fs", xt="cr",m=1,k=4) #random smooth
               , data=data_F_wigan,method="fREML", nthreads = 12)

补充尝试

根据@Roland的建议,为报错模型添加了主效应,但仍出现相同错误:

F1.F.wigan.gamm9 <- bam(F2 ~
                  age_ord +
                  sex_ord +
                  fol_ord +
                  style_med +
                  s(percent, k=4)  + #difference in height of traj
                  s(percent, by=age_ord, k=4) +
                  s(percent, by=sex_ord, k=4) +
                  s(percent, by=fol_ord, k = 4) +
                  s(percent, by=style_med, k=4) +
                  ti(percent, dur) + #interaction between shape and duration
                  s(percent, ID, bs="fs", xt="cr",m=1,k=4) + #random smooth
                  s(percent, traj, bs="fs", xt="cr",m=1,k=4) + #random smooth
                  s(percent, word, bs="fs", xt="cr",m=1,k=4) #random smooth
               , data=data_F_wigan,method="fREML", nthreads = all_cores)

内容的提问来源于stack exchange,提问作者Caitlin H

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 11:21:01