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

data.table无法检测OpenMP支持问题及解决(自定义安装目录所致)

data.table无法启用多线程问题及解决办法

编辑: 问题已解决。使用自定义工作目录安装data.table是导致问题的原因。

问题现象

在R中加载data.table时出现OpenMP支持未检测到的警告,导致只能单线程运行,手动修改线程数也无效。该功能之前正常可用,仅在系统更新后出现此问题。

加载data.table时的输出:

> library(data.table)
data.table 1.14.6 using 1 threads (see ?getDTthreads).  Latest news: r-datatable.com
**********
This installation of data.table has not detected OpenMP support. It should still work but in single-threaded mode.
This is Linux. This warning should not normally occur on Windows or Linux where OpenMP is turned on by data.table's configure script by passing -fopenmp to the compiler. If you see this warning on Windows or Linux, please file a GitHub issue.
**********

当前R环境信息:

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: openSUSE Tumbleweed

Matrix products: default
BLAS:   /usr/lib64/R/lib/libRblas.so
LAPACK: /usr/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
 [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8   
 [7] LC_PAPER=en_US.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base      

other attached packages:
[1] data.table_1.14.6

loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2    tcltk_4.2.2

尝试的解决操作

执行源码安装data.table的命令,安装过程中出现编译器参数错误,导致OpenMP支持未被启用:

> install.packages("data.table", type = "source",
+     repos = "https://Rdatatable.gitlab.io/data.table")
Installing package into ‘/***personal***/R/x86_64-suse-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://Rdatatable.gitlab.io/data.table/src/contrib/data.table_1.14.7.tar.gz'
Content type 'application/gzip' length 5336596 bytes (5.1 MB)
==================================================
downloaded 5.1 MB

* installing *source* package ‘data.table’ ...
** using staged installation
gcc 12.2.1
zlib 1.2.13 is available ok
cc1: error: argument to ‘-O’ should be a non-negative integer, ‘g’, ‘s’, ‘z’ or ‘fast’
*** OpenMP not supported! data.table uses OpenMP to automatically
***   parallelize operations like sorting, grouping, file reading, etc.
*** Continuing installation without OpenMP support...
** libs
gcc -I"/usr/lib64/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g  -c assign.c -o assign.o
gcc -I"/usr/lib64/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g  -c between.c -o between.o
between.c: In function ‘between’:
between.c:67: warning: ignoring ‘#pragma omp parallel’ [-Wunknown-pragmas]
   67 |       #pragma omp parallel for num_threads(getDTthreads(longest, true))
      | 

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 18:50:42