Data.table: 加载 data.table 导致 mclapply() 在 MacOS 上挂起

创建于 2017-10-13  ·  39评论  ·  资料来源: Rdatatable/data.table

这个问题https://github.com/Bioconductor/BiocParallel/issues/67似乎导致

library(parallel)
library(data.table)
mclapply(1:2, sqrt)

悬挂,与

> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] data.table_1.10.4-2

loaded via a namespace (and not attached):
[1] compiler_3.4.2
openmp

最有用的评论

@davidgohel :请参阅本指南以获取本地安装的 R LLVM 工具链。 http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/

或者,我建议在R.home("etc/Makeconf")处编辑文件并删除您在其中看到的任何-fopenmp实例,这样编译就不会尝试将 OpenMP 与 Apple 系统工具链一起使用。

所有39条评论

感谢您的报告。

1.10.4-1 新闻中的第 4 项:

在 data.table 与 OpenMP 并行执行后,当包“并行”分叉时,尝试在 Mac 上使用 Intel 的 OpenMP 进行改进。 该 OpenMP 实现似乎让线程在并行区域完成后继续运行。 如果此修复仍然无效,请在已报告修复问题的 library(data.table) 之后立即调用 setDTthreads(1)。

在开发中,我改进了相同的项目,但忽略了将新闻项目更改为 CRAN 补丁的反向移植。 来自开发新闻文件

当也使用并行包(分叉)时,尝试在 Mac-only 上进行改进,#2137。 与 GNU libgomp 不同,英特尔的 OpenMP 实现似乎在 OpenMP 并行区域(data.table 内部)完成后让线程继续运行。 因此,如果用户在 data.table 已经并行运行之后调用并行的 fork,则会发生不稳定。 该问题仅出现在来自 CRAN 的 Mac 软件包二进制文件中,因为它们是由 CRAN 使用 Intel 的 OpenMP 库构建的。 在不使用并行时,在 Windows 或 Linux 上没有已知问题,在任何平台上都没有已知问题。 如果这个仅限 Mac 的修复仍然不起作用,请在 library(data.table) 之后立即调用 setDTthreads(1),据报道通过将 data.table 更早地置于单线程模式来解决问题。

但是,就您而言,您甚至在分叉之前都没有使用过 data.table 。 所以这是一个以前没有报道过的新方面。 您的可重现示例是否严格正确,因为这 3 行实际上是在新的 R 会话中发生的所有内容? 即在加载它和调用mclapply之间没有使用 data.table 吗? 无论如何,您都可以尝试在library(data.table)之后立即调用setDTthreads(1) ,但我怀疑如果在mclapply之前确实没有使用 data.table 会有所帮助。

您是否安装了 CRAN mac 二进制文件,或者从源代码? 对于您使用哪个 OpenMP 库的mclapply问题,这在 MacOS 上似乎很重要。 您是否能够确定在机器上使用的是 Intel 的 (libomp) 还是 GNU 的 (libgomp) OpenMP 实现?

您可以使用MacOS 指令从源代码编译吗?这有帮助吗? 也许这链接到本地​​适合您的 OpenMP 库,或类似的东西。 有些人没有完全按照说明进行操作,因此必须在 MacOS 上完全按照说明进行操作。

test.data.table()对你有用吗? 测试 1705 测试mclapply并且它正在通过 CRAN。 我假设 CRAN 在 MacOS 上测试 Mac 二进制文件,但我认为它可能测试不同的构建。

来自 1.10.4-2 的 NEWS 的第 1 项我怀疑是相关的,但为了完整起见,我会提到它:

CRAN 现在支持 MacOS 上的 OpenMP,并包含在 CRAN 的 Mac 软件包二进制文件中。 但是在 MacOS 上从源代码安装 v1.10.4-1 在编译时未启用 OpenMP 时失败,#2409。 感谢 Liz Macfie 和@fupangpangpang的报道。 未启用 OpenMP 时的启动消息已更新。

以下是相关问题:
https://github.com/Rdatatable/data.table/issues/2413
https://github.com/Rdatatable/data.table/issues/2409
https://github.com/Rdatatable/data.table/issues/2406
https://github.com/Rdatatable/data.table/issues/2137

我基本上在 MacOS 上苦苦挣扎。 如果有任何来自 Apple 和/或 Intel 的人可以支持他们的产品,那就太好了。 我很难看出这真的是一个 data.table 问题。 我已经尝试了我能想到的一切来解决它并在 NEWS 中记录它。 非常感谢帮助和建议。

是的,简单的脚本只有

library(parallel)
library(data.table)
mclapply(1:2, sqrt)

这是在 Bioconductor 构建机器上。 我相信这是一个简单的二进制安装,但会确认。 我们有

$ ls /Library/Frameworks/R.framework/Resources/lib
libR.dylib      libRlapack.dylib.dSYM   libquadmath.0.dylib
libR.dylib.dSYM     libc++.1.dylib      libreadline.5.2.dylib
libRblas.0.dylib    libc++abi.1.dylib   libreadline.dylib
libRblas.dylib      libgcc_s.1.dylib    libunwind.1.dylib
libRblas.dylib.dSYM libgfortran.3.dylib
libRlapack.dylib    libomp.dylib

$ otool -L  /Library/Frameworks/R.framework/Resources/bin/exec/R 
/Library/Frameworks/R.framework/Resources/bin/exec/R:
    /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libR.dylib (compatibility version 3.4.0, current version 3.4.2)
    /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.dylib (compatibility version 0.0.0, current version 0.0.0)
    /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

所以大概链接到libomp。

test.data.table()

Running test id 1705     Assertion failure at kmp_runtime.cpp(6480): __kmp_thread_pool == __null.
Assertion failure at kmp_runtime.cpp(6480): __kmp_thread_pool == __null.
OMP: Error #13: Assertion failure at kmp_runtime.cpp(6480).
OMP: Hint: Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see http://www.intel.com/software/products/support/.
OMP: Error #13: Assertion failure at kmp_runtime.cpp(6480).
OMP: Hint: Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see http://www.intel.com/software/products/support/.
Assertion failure at kmp_runtime.cpp(6480): __kmp_thread_pool == __null.
OMP: Error #13: Assertion failure at kmp_runtime.cpp(6480).
OMP: Hint: Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see http://www.intel.com/software/products/support/.
Assertion failure at kmp_runtime.cpp(6480): __kmp_thread_pool == __null.
OMP: Error #13: Assertion failure at kmp_runtime.cpp(6480).
OMP: Hint: Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see http://www.intel.com/software/products/support/.
Running test id 1750     Test 1751 not run. If required call library(nanotime) first.

endian==little, sizeof(long double)==16, sizeof(pointer)==8

All 5936 tests in inst/tests/tests.Rraw completed ok in 00:01:45 on Sat Oct 14 21:25:30 2017

谢谢你。 是的,我相信那些__kmp_*调用是特定于英特尔 OpenMP 运行时的,我之前已经看到过它们的报道。 测试 1705 专门对此进行测试。 它利用 data.table 本身内的 2 个 OpenMP 线程,然后调用parallel::mclapply__kmp_错误是因为,iiuc,Intel 的实现即使在所有并行区域都完成后仍让线程运行,因此后续的 fork 是不稳定的。 在这种情况下,它看起来并没有崩溃,但这只是运气。 您看到 1.10.4-2 的输出这一事实意味着我尝试的解决方法不起作用。 有一个 pre-fork 回调,它现在调用omp_set_num_threads(1) ,希望 Intel 库在 fork 之前清除其正在运行的线程。 但它似乎没有。 所以,我们只剩下报告的工作了,即在 library(data.table) 之后立即调用setDTthreads(1) library(data.table)来阻止英特尔的 OpenMP 首先创建线程。

尽管只有 3 行代码,英特尔的 OpenMP 库是否有可能在链接或初始化时创建其线程? 如果是这样,那就可以解释了。 否则,我对此束手无策。

此外,我不知道clanggcc的 OpenMP 功能如何与 3 个 OpenMP 库相关: libomplibiomplibgomp 。 你似乎有libomp 。 但我认为 CRAN 用libiomp编译? 也许这与它有关。 此外,有人报告(此处)“将 llvm 更改为 gcc”停止了 MacOS 上的崩溃,但它们是从源代码编译的。

我刚刚发现了英特尔 OpenMP 运行时的源代码。 我不知道这个项目是什么,因为我认为英特尔的库是闭源的。 但也许可以针对它进行编译和调试。 https://www.openmprtl.org/可能更容易先在本地编译,看看是否可行,或者使用 GNU 库。

测试 1705 正在通过 CRAN,因此通过找出 CRAN 机器和您的机器之间的不同之处,这可能是有希望的。 测试 1705 实际上正在为您和 CRAN 通过,但是libomp正在向控制台输出断言错误,然后测试没有发现这些错误。 我想知道是否有可能以某种方式查看 CRAN 日志以查看这些__kmp消息是否也在 CRAN 的日志中。 如果消息不存在于 CRAN 的日志中,那么可能值得探索 CRAN 机器和您的机器之间的区别。

也许这是 CRAN 软件包二进制文件所需要的:http: //macappstore.org/libiomp/
或者也许 libiomp 是由 CRAN 静态编译到包二进制文件中的? 我注意到?install.packages的“二进制包”部分对于 MacOS 来说非常复杂,并且type=参数有几个二进制选项。

英特尔的图书馆正在打印:

OMP:错误 #13:kmp_runtime.cpp (6480) 处的断言失败
OMP:提示:请提交带有此消息的错误报告,编译和运行使用的命令,以及机器配置信息,包括本机编译器和操作系统版本。 通过包括所有程序源将获得更快的响应。 有关提交此问题的信息,请参阅http://www.intel.com/software/products/support/。

请问有MacOS问题的人可以向英特尔提出问题吗?

嗨,我最初报告了 BiocParallel 存储库的问题,因为我在使用该包中的函数时遇到了这个问题。 他们已将问题缩小到在加载 data.table 时调用 mclapply。

我按照此处的说明在我的 MacOS 上安装了最新版本的 data.table,但仍然遇到了问题。

有趣的是,一位同事在他的 Mac 上安装了最新版本的 data.table 并且没有任何问题。 但是,他的系统上没有安装 OpenMP。

我能够通过回滚到 data.table 1.10.2 来解决这个问题。

@asenabouth您能否向英特尔提出支持请求(请参阅我上面的评论)? 他们的图书馆似乎有问题。 或者,也许苹果公司的人可以提供帮助。 你能得到他们的支持吗? 我不相信从源代码安装并不能解决它。 你能显示命令和输出吗? 在加载 data.table 1.10.4 之后,即使在从源代码编译并避免使用 CRAN 二进制文件之后,是否还有其他人无法使用parallel::mclapply

我将向英特尔提交支持请求。

至于从源安装,这里是安装和后续测试:
```{r}
[之前保存的工作区已恢复]

remove.packages("data.table")
从“/Users/a.senabouth/Library/R/3.4/library”中删除包
(因为“lib”未指定)
install.packages("data.table", type = "source",

内容类型 'application/gzip' 长度 3312731 字节 (3.2 MB)

已下载 3.2 MB

  • 安装包'data.table' ...
    * 库/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c assign.c -o assign.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c between.c -o between.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c bmerge.c -o bmerge.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c chmatch.c -o chmatch.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c dogroups.c -o dogroups.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fastmean.c -o fastmean.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fcast.c -o fcast.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fmelt.c -o fmelt.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c forder.c -o forder.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c frank.c -o frank.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fread.c -o fread.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c freadR.c -o freadR.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fsort.c -o fsort.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fwrite.c -o fwrite.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fwriteR.c -o fwriteR.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c gsumm.c -o gsumm.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c ijoin.c -o ijoin.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c init.c -o init.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c inrange.c -o inrange.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c openmp-utils.c -o openmp-utils.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c quickselect.c -o quickselect.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c rbindlist.c -o rbindlist.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c reorder.c -o reorder.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c shift.c -o shift.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c subset.c -o subset.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c transpose.c -o transpose.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c uniqlist.c -o uniqlist.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c vecseq.c -o vecseq.o/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c wrappers.c -o wrappers.o/usr/local/opt/llvm/bin/clang -fopenmp -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/ opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -o data.table.so assign.o between.o bmerge.o chmatch .o dogroups.o fastmean.o fcast.o fmelt.o forder.o frank.o fread.o freadR.o fsort.o fwrite.o fwriteR.o gsumm.o ijoin.o init.o inrange.o openmp-utils .o quickselect.o rbindlist.o reorder.o shift.o subset.o transpose.o uniqlist.o vecseq.o wrappers.o -fopenmp -F/Library/Frameworks/R.framework/.. -framework R -Wl, -framework -Wl,CoreFoundationmv 数据表.so 数据表.so如果 [ "" != "Windows_NT" ] && [ uname -s = '达尔文' ]; 安装到 /Users/a.senabouth/Library/R/3.4/library/data.table/libs* R
    * 安装*字节编译和准备延迟加载的包
    * 帮助* * 安装帮助索引
    * 构建包索引*安装小插曲
    ** 测试是否可以加载已安装的包
  • 完成(数据表)

下载的源码包在
'/private/var/folders/zz/zyxvpxvq6csfxvn_n0001lp0000cxh/T/Rtmpl7TqS4/downloaded_pa​​ckages'

R
错误:找不到对象“R”
图书馆(并行)
库(数据表)
data.table 1.10.5 开发中建于 2017-10-16 07:29:07 UTC; 特拉维斯
最快的学习方式(由 data.table 作者提供): https ://www.datacamp.com/courses/data-analysis-the-data-table-way
文档:?data.table、example(data.table) 和 browseVignettes("data.table")
发行说明、视频和幻灯片: http ://r-datatable.com
mclapply(1:2, sqrt)

* 抓到非法操作 *
地址 0x7fffa9730ae4,导致“非法操作码”

追溯:
1:麦克福克()
2:有趣(X[[i]],...)
3: lapply(seq_len(cores), inner.do)
4: mclapply(1:2, sqrt)

可能的行动:
1:中止(如果启用,则使用核心转储)
2:正常R退出
3:退出R而不保存工作区
4:退出R保存工作区

And here's the session info:
```{r}
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

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

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

loaded via a namespace (and not attached):
[1] compiler_3.4.2

编辑
我通过从源代码安装 1.10.4 让它工作。
```{r}

需要(开发工具)
加载所需的包:devtools
install_version("data.table", version = "1.10.4", repos = "http://cran.us.r-project.org")
从 url 下载包:http: //cran.us.r-project.org/src/contrib/Archive/data.table/data.table_1.10.4.tar.gz
安装 data.table
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ
--no-save --no-restore --quiet CMD 安装
'/private/var/folders/zz/zyxvpxvq6csfxvn_n0001lp0000cxh/T/RtmpXDSgR8/devtoolsdf05280c79d9/data.table'
--library='/Users/a.senabouth/Library/R/3.4/library' --install-tests

  • 安装包'data.table' ...
    * 包'data.table'成功解包并检查MD5总和*
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c assign.c -o assign.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c between.c -o between.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c bmerge.c -o bmerge.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c chmatch.c -o chmatch.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c dogroups.c -o dogroups.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fastmean.c -o fastmean.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fcast.c -o fcast.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fmelt.c -o fmelt.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c forder.c -o forder.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c frank.c -o frank.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fread.c -o fread.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fsort.c -o fsort.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fwrite.c -o fwrite.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c gsumm.c -o gsumm.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c ijoin.c -o ijoin.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c init.c -o init.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c inrange.c -o inrange.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c openmp-utils.c -o openmp-utils.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c quickselect.c -o quickselect.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c rbindlist.c -o rbindlist.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c reorder.c -o reorder.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c shift.c -o shift.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c subset.c -o subset.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c transpose.c -o transpose.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c uniqlist.c -o uniqlist.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c vecseq.c -o vecseq.o
    /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt /llvm/include -fopenmp -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c wrappers.c -o wrappers.o
    /usr/local/opt/llvm/bin/clang -fopenmp -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/ opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -o data.table.so assign.o between.o bmerge.o chmatch .o dogroups.o fastmean.o fcast.o fmelt.o forder.o frank.o fread.o fsort.o fwrite.o gsumm.o ijoin.o init.o inrange.o openmp-utils.o quickselect.o rbindlist .o reorder.o shift.o subset.o transpose.o uniqlist.o vecseq.o wrappers.o -fopenmp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    mv 数据表.so 数据表.so
    如果 [ "" != "Windows_NT" ] && [ uname -s = '达尔文' ]; 然后 install_name_tool -id datatable.so datatable.so; 菲
    安装到 /Users/a.senabouth/Library/R/3.4/library/data.table/libs
    * R*安装
    * 测试*字节编译和准备延迟加载的包
    * 帮助* * 安装帮助索引
    * 构建包索引*安装小插曲
    ** 测试是否可以加载已安装的包
  • 完成(数据表)
    > 库(data.table)
    数据表 1.10.4
    最快的学习方式(由 data.table 作者提供):https://www.datacamp.com/courses/data-analysis-the-data-table-way
    文档:?data.table、example(data.table) 和 browseVignettes("data.table")
    发行说明、视频和幻灯片:http://r-datatable.com
    > 图书馆(并行)
    > mclapply(1:2, sqrt)
    [[1]]
    [1] 1

[[2]]
[1] 1.414214
```

我已经发布了以下https://software.intel.com/en-us/forums/intel-c-compiler/topic/746943

它可能在错误的地方,我可能会被激怒,但希望它会让球滚动。

@mattdowle让我知道您是否希望我添加/执行某些操作

想确认我重现了与@asenabouth相同的错误,并且从源代码重新安装 1.10.4 解决了问题。

会话信息:

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

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

loaded via a namespace (and not attached):
[1] compiler_3.4.2 methods_3.4.2 

只是在我的机器上记录一些细节

library(parallel)
library(data.table)
mclapply(1:2, sqrt)

生产

 *** caught illegal operation ***
address 0x7fffb500eae4, cause 'illegal opcode'

sessionInfo()

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
[1] data.table_1.10.4-2 testthat_1.0.2      devtools_1.13.3    

loaded via a namespace (and not attached):
[1] compiler_3.4.2 magrittr_1.5   R6_2.2.2       withr_2.0.0    crayon_1.3.4  
[6] memoise_1.1.0  digest_0.6.12

有趣的是,

> remove.packages("data.table")
Removing package from ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
(as ‘lib’ is unspecified)
> install.packages("data.table", type = "source",
+ repos = "http://Rdatatable.github.io/data.table")

生产

trying URL 'http://Rdatatable.github.io/data.table/src/contrib/data.table_1.10.5.tar.gz'

Content type 'application/gzip' length 3312726 bytes (3.2 MB)
==================================================
downloaded 3.2 MB

* installing *source* package ‘data.table’ ...
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include  -fopenmp -fPIC  -Wall -g -O2  -c assign.c -o assign.o
clang: error: unsupported option '-fopenmp'
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/data.table’

The downloaded source packages are in
    ‘/private/var/folders/48/q6ltldjs251000_wvjrdy_vm0000gn/T/Rtmp6eZFXj/downloaded_packages’
Warning message:
In install.packages("data.table", type = "source", repos = "http://Rdatatable.github.io/data.table") :
  installation of package ‘data.table’ had non-zero exit status

我要看看这是否相关

我还按照https://github.com/Rdatatable/data.table/wiki/Installation上的说明进行操作,但问题仍然存在......

编辑:
mclapplyillegal operation的原始问题(不是编译器错误unsupported option '-fopenmp' - 按照说明修复)

谢谢大家。 有趣的是 1.10.4 似乎可以正常工作,但 1.10.4-2 却不行。 一旦调用分叉,它似乎就会崩溃。 我在 NEWS 中提到的尝试就是在那个领域。

首先,什么没有改变。 加载 data.table 后, init.copenmp-utils.c中调用它:

void avoid_openmp_hang_within_fork() {
  // Called once on loading data.table from init.c
  #ifdef _OPENMP
    pthread_atfork(&when_fork, NULL, NULL);
  #endif
}

所以当parallel::mclapply调用它的fork()时, when_fork函数就会运行。 在 1.10.4-2 中看起来像这样:

void when_fork() {    # v 1.10.4-2
  // attempted workaround for Intel's OpenMP implementation which leaves threads
  // running after parallel region; these crash when forked.
  #ifdef _OPENMP
    omp_set_num_threads(1);
  #endif

  DTthreads = 1;
}

之前(在 1.10.4 中),它不习惯调用omp_set_num_threads(1) ,它只是设置静态变量DTthreads

void when_fork() {    # v 1.10.4
  DTthreads = 1;
}

我所能想到的就是对omp_set_num_threads(1)的调用正在使它崩溃。 但这是您可以在 OpenMP 中调用的最简单的函数。 也许它没有正确绑定到图书馆,不知何故?

  1. 对于在调用parallel::mclapply时可以重现崩溃的人来说,简单的fwrite()在新会话中是否可以在不加载包parallel的情况下为您工作? 它是否应该使用许多 CPU? 您将需要一个大的DT来测试,否则它只使用 1 个线程来处理小数据。 如果它在任何使用 OpenMP 时崩溃,那么我们就会遇到链接问题。 有谁知道链接行中的这些标志是什么意思,它们在 MacOS 上可能与它有关吗? : -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress

  2. 我可以尝试在 dev 中再次删除对omp_set_num_threads(1)的调用,而现在有 1.10.5 问题的人可以在我更改后再次尝试 dev 吗?

  3. 奇怪的是,测试在 MacOS 上通过 CRAN 没有崩溃。 测试 1705 测试调用parallel::mclapply并且所有测试都使用 2 个线程在 CRAN 上运行。 CRAN 机器和人们遇到问题的机器有什么区别?

@joethorley这很奇怪。 即使在此处运行 MacOS 指令后,您也会得到unsupported option '-fopenmp' 。 其他人可以建议如何取得进展吗? 我不知所措。

@joethorley你安装了 gettext 吗? 结果我没有。 一旦完成,我就能够在我的系统上正确编译包。

@mattdowle没有unsupported option '-fopenmp'错误在我按照此处的说明操作后消失了,但是错误

 *** caught illegal operation ***
address 0x7fffb500eae4, cause 'illegal opcode'

发生了。

我的 Makevars 是

CC=/usr/local/opt/llvm/bin/clang -fopenmp
CXX=/usr/local/opt/llvm/bin/clang++
# -O3 should be faster than -O2 (default) level optimisation ..
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include

我的会话信息()

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
[1] testthat_1.0.2  devtools_1.13.3

loaded via a namespace (and not attached):
[1] compiler_3.4.2 magrittr_1.5   R6_2.2.2       withr_2.0.0    crayon_1.3.4  
[6] memoise_1.1.0  digest_0.6.12 

和我的 R 会话

> remove.packages("data.table")
Removing package from ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
(as ‘lib’ is unspecified)
> install.packages("data.table", type = "source", repos = "http://Rdatatable.github.io/data.table")
trying URL 'http://Rdatatable.github.io/data.table/src/contrib/data.table_1.10.5.tar.gz'
Content type 'application/gzip' length 3312684 bytes (3.2 MB)
==================================================
downloaded 3.2 MB

* installing *source* package ‘data.table’ ...
** libs
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c assign.c -o assign.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c between.c -o between.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c bmerge.c -o bmerge.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c chmatch.c -o chmatch.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c dogroups.c -o dogroups.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fastmean.c -o fastmean.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fcast.c -o fcast.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fmelt.c -o fmelt.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c forder.c -o forder.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c frank.c -o frank.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fread.c -o fread.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c freadR.c -o freadR.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fsort.c -o fsort.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fwrite.c -o fwrite.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fwriteR.c -o fwriteR.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c gsumm.c -o gsumm.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c ijoin.c -o ijoin.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c init.c -o init.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c inrange.c -o inrange.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c openmp-utils.c -o openmp-utils.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c quickselect.c -o quickselect.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c rbindlist.c -o rbindlist.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c reorder.c -o reorder.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c shift.c -o shift.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c subset.c -o subset.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c transpose.c -o transpose.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c uniqlist.c -o uniqlist.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c vecseq.c -o vecseq.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c wrappers.c -o wrappers.o
/usr/local/opt/llvm/bin/clang -fopenmp -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -o data.table.so assign.o between.o bmerge.o chmatch.o dogroups.o fastmean.o fcast.o fmelt.o forder.o frank.o fread.o freadR.o fsort.o fwrite.o fwriteR.o gsumm.o ijoin.o init.o inrange.o openmp-utils.o quickselect.o rbindlist.o reorder.o shift.o subset.o transpose.o uniqlist.o vecseq.o wrappers.o -fopenmp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
mv data.table.so datatable.so
if [ "" != "Windows_NT" ] && [ `uname -s` = 'Darwin' ]; then install_name_tool -id datatable.so datatable.so; fi
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/data.table/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (data.table)

The downloaded source packages are in
    ‘/private/var/folders/48/q6ltldjs251000_wvjrdy_vm0000gn/T/RtmpWku3yc/downloaded_packages’
> library(parallel)
> library(data.table)
data.table 1.10.5 IN DEVELOPMENT built 2017-10-18 23:12:32 UTC; travis
  The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
  Documentation: ?data.table, example(data.table) and browseVignettes("data.table")
  Release notes, videos and slides: http://r-datatable.com
> mclapply(1:2, sqrt)

 *** caught illegal operation ***
address 0x7fffb500eae4, cause 'illegal opcode'

@mattdowle

  1. fwrite()似乎可以在我的机器上运行
> mtcars <- rbind(mtcars, mtcars)
> nrow(mtcars)                                       
[1] 16777216
> fwrite(mtcars, "mtcars.csv")
Written 45.1% of 16777216 rows in 2 secs using 8 threads. anyBufferGrown=no; max
Written 69.5% of 16777216 rows in 3 secs using 8 threads. anyBufferGrown=no; max
Written 93.9% of 16777216 rows in 4 secs using 8 threads. anyBufferGrown=no; max                                                                         

@asenabouth我确实安装了 gettext ,一旦按照说明进行操作,我就能够正确编译包。 我的帖子有点不清楚,所以我编辑了。

@mattdowle

  1. 如果您在 dev 中删除对 omp_set_num_threads(1) 的调用,我将再次尝试 dev。

从 CRAN(源代码或二进制文件)安装 1.10.4.2 会导致 mclapply 挂起。 安装 github.com/Rdatatable/data。 来自源的table@master仍然产生原始的 mclapply 挂起。

安装当前 master 的这个修改版本

$ git diff
diff --git a/src/openmp-utils.c b/src/openmp-utils.c
index d6e3b70..bf104fc 100644
--- a/src/openmp-utils.c
+++ b/src/openmp-utils.c
@@ -78,7 +78,7 @@ void when_fork() {
 void avoid_openmp_hang_within_fork() {
   // Called once on loading data.table from init.c
 #ifdef _OPENMP
-  pthread_atfork(&when_fork, NULL, NULL);
+//  pthread_atfork(&when_fork, NULL, NULL);
 #endif
 }
 ```

or this version

$混帐差异
差异 --git a/src/openmp-utils.cb/src/openmp-utils.c
索引 d6e3b70..8c0236d 100644
--- a/src/openmp-utils.c
+++ b/src/openmp-utils.c
@@ -62,7 +62,7 @@ void when_fork() {
// 尝试解决 Intel 的 OpenMP 实现的方法,使线程在之后运行
// 平行区域; 这些在分叉时崩溃。
#ifdef _OPENMP

  • omp_set_num_threads(1);
    +// omp_set_num_threads(1);
    #万一

// GNU OpenMP 似乎没问题,只需将 DTthreads 设置为 1,这会限制下一个并行区域

clears the hang for me.

The R we use (installed as a binary from CRAN) is the 3.4.2 release

版本
_
平台 x86_64-apple-darwin15.6.0
拱 x86_64
操作系统 darwin15.6.0
系统 x86_64,darwin15.6.0
地位
专业 3
未成年人 4.2
2017 年
09 月
第 28 天
svn 版本 73368
语言 R
version.string R 版本 3.4.2 (2017-09-28)
昵称 短暂的夏天
```

设置环境变量 OMP_NUM_THREADS=2 并没有改变结果。

我可以确认在when_fork()中注释掉omp_set_num_threads(1);也可以解决我机器上的问题

> mclapply(1:2, sqrt)
[[1]]
[1] 1

[[2]]
[1] 1.414214

感谢大家。 在开发中进行了修复并且正在通过。 @joethorley您或其他人能否确认最新的 1.10.5 现在可以了。 我将开始准备 1.10.4-3 去 CRAN。

@mattdowle

我可以确认它是固定的。

$ R

R version 3.4.2 (2017-09-28) -- "Short Summer"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> remove.packages("data.table")
Removing package from ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
(as ‘lib’ is unspecified)
> install.packages("data.table", type = "source", repos = "http://Rdatatable.github.io/data.table")
trying URL 'http://Rdatatable.github.io/data.table/src/contrib/data.table_1.10.5.tar.gz'
Content type 'application/gzip' length 3313284 bytes (3.2 MB)
==================================================
downloaded 3.2 MB

* installing *source* package ‘data.table’ ...
** libs
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c assign.c -o assign.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c between.c -o between.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c bmerge.c -o bmerge.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c chmatch.c -o chmatch.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c dogroups.c -o dogroups.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fastmean.c -o fastmean.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fcast.c -o fcast.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fmelt.c -o fmelt.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c forder.c -o forder.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c frank.c -o frank.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fread.c -o fread.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c freadR.c -o freadR.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fsort.c -o fsort.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fwrite.c -o fwrite.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c fwriteR.c -o fwriteR.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c gsumm.c -o gsumm.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c ijoin.c -o ijoin.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c init.c -o init.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c inrange.c -o inrange.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c openmp-utils.c -o openmp-utils.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c quickselect.c -o quickselect.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c rbindlist.c -o rbindlist.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c reorder.c -o reorder.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c shift.c -o shift.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c subset.c -o subset.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c transpose.c -o transpose.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c uniqlist.c -o uniqlist.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c vecseq.c -o vecseq.o
/usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  -fopenmp -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c wrappers.c -o wrappers.o
/usr/local/opt/llvm/bin/clang -fopenmp -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -o data.table.so assign.o between.o bmerge.o chmatch.o dogroups.o fastmean.o fcast.o fmelt.o forder.o frank.o fread.o freadR.o fsort.o fwrite.o fwriteR.o gsumm.o ijoin.o init.o inrange.o openmp-utils.o quickselect.o rbindlist.o reorder.o shift.o subset.o transpose.o uniqlist.o vecseq.o wrappers.o -fopenmp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
mv data.table.so datatable.so
if [ "" != "Windows_NT" ] && [ `uname -s` = 'Darwin' ]; then install_name_tool -id datatable.so datatable.so; fi
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/data.table/libs
** R
** inst
** byte-compile and prepare package for lazy loading
session** help
In*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (data.table)

The downloaded source packages are in
    ‘/private/var/folders/48/q6ltldjs251000_wvjrdy_vm0000gn/T/RtmpmAMLnD/downloaded_packages’
> library(parallel)
> library(data.table)
data.table 1.10.5 IN DEVELOPMENT built 2017-10-19 19:32:41 UTC; travis
  The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
  Documentation: ?data.table, example(data.table) and browseVignettes("data.table")
  Release notes, videos and slides: http://r-datatable.com
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
[1] data.table_1.10.5 testthat_1.0.2    devtools_1.13.3  

loaded via a namespace (and not attached):
[1] compiler_3.4.2 magrittr_1.5   R6_2.2.2       tools_3.4.2    withr_2.0.0   
[6] crayon_1.3.4   memoise_1.1.0  digest_0.6.12 
> mclapply(1:2, sqrt)
[[1]]
[1] 1

[[2]]
[1] 1.414214

非常感谢@joethorley! 提交给 CRAN 的 1.10.4-3 并且一切正常,CRAN 的魔力需要几天时间才能运行。

v1.10.4-3 中的更改(CRAN 2017 年 10 月 20 日)

  1. 修复了使用parallel::mclapply且仅加载 data.table 时 MacOS 上的崩溃/挂起问题, #2418 。 奇怪的是,包括测试 1705(使用 data.table 测试mclapply )在内的所有测试都在 CRAN 上顺利通过。 它似乎是 MacOS 的某些版本或 MacOS 上的某些版本的库,也许。 非常感谢 Martin Morgan 报告并确认此修复程序有效。 还要感谢 asenabouth、Joe Thorley 和 Danton Noriega 测试、调试和确认 data.table 内的自动并行性(例如fwrite )即使在这些 MacOS 安装上也能正常工作。 另请参阅下面有关 1.10.4-1 和 1.10.4-2 的新闻项目。

暂时关闭。 如果 1.10.4-3 有问题,请重新打开或打开一个新问题。

@mattdowle :看起来 v1.10.4-2 仍然是 CRAN 分发的版本。 v1.10.4-3 是否仍在 CRAN 提交队列中等待,还是出现其他问题?

(感谢您如此迅速地解决此问题;不幸的是,它似乎影响了 macOS 上的大量用户)

@kevinushey是的 1.10.4-3 在队列中等待(处于“重新检查”状态,我不知道这意味着什么,持续了 6 天)。 我向 CRAN 发送了一封电子邮件,现在它已发布给 CRAN。

也许我做错了什么,但我的 Mac 上仍然存在问题。

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

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

loaded via a namespace (and not attached):
 [1] httr_1.3.1      compiler_3.4.1  R6_2.2.2        tools_3.4.1     withr_2.0.0     curl_3.0       
 [7] yaml_2.1.14     memoise_1.1.0   knitr_1.17      git2r_0.19.0    digest_0.6.12   devtools_1.13.3

从源代码安装 cran 版本时,我得到:

> install.packages("data.table", type = "source", repos = "https://cran.rstudio.com")
essai de l'URL 'https://cran.rstudio.com/src/contrib/data.table_1.10.4-3.tar.gz'
Content type 'application/x-gzip' length 3071833 bytes (2.9 MB)
==================================================
downloaded 2.9 MB

* installing *source* package ‘data.table’ ...
** package ‘data.table’ correctement décompressé et sommes MD5 vérifiées
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include  -fopenmp -fPIC  -Wall -g -O2  -c assign.c -o assign.o
clang: error: unsupported option '-fopenmp'
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/data.table’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/data.table’

Les packages source téléchargés sont dans
    ‘/private/var/folders/51/6jygptvs3bb4njv0t6x7br900000gn/T/Rtmp8NJ0di/downloaded_packages’
Warning message:
In install.packages("data.table", type = "source", repos = "https://cran.rstudio.com") :
  l'installation du package ‘data.table’ a eu un statut de sortie non nul

如有必要,我可以提供更多详细信息。

@davidgohel :请参阅本指南以获取本地安装的 R LLVM 工具链。 http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/

或者,我建议在R.home("etc/Makeconf")处编辑文件并删除您在其中看到的任何-fopenmp实例,这样编译就不会尝试将 OpenMP 与 Apple 系统工具链一起使用。

@kevinushey好的,我将尝试使用替代解决方案。 我想我在第一个解决方案中搞砸了。

将此添加到我的~/.R/Makevars文件中,可以在 High Sierra 上编译没有 OpenMP 的 data.table:

# Suppress `-fopenmp` in R.home("etc/Makeconf")
# MAIN_LDFLAGS = -fopenmp
# SHLIB_OPENMP_CFLAGS = -fopenmp
# SHLIB_OPENMP_CXXFLAGS = -fopenmp
# SHLIB_OPENMP_FCFLAGS = -fopenmp
# SHLIB_OPENMP_FFLAGS = -fopenmp
MAIN_LDFLAGS =
SHLIB_OPENMP_CFLAGS =
SHLIB_OPENMP_CXXFLAGS =
SHLIB_OPENMP_FCFLAGS =
SHLIB_OPENMP_FFLAGS =

@mjsteinbaugh @kevinushey谢谢,它工作

我尝试在R.home("etc/Makeconf")处编辑文件,但我不允许编辑它。 我似乎也没有一个名为~/.R/Makevars的文件。 任何进一步的建议:) 谢谢

@ValeriVoev ~/.R/Makevars处的文件通常不存在; 你必须自己创建它。 (也就是说,在您的主目录中创建一个名为.R的文件夹,然后在该文件夹中创建一个Makevars文件)

谢谢@kevinushey - 我终于成功了,安装data.table 1.10.4-3 并且 R Studio 不再崩溃。 我还安装了 clang - 不确定这是否也有帮助。

我仍然随机看到这个错误

Assertion failure at kmp_runtime.cpp(6480): __kmp_thread_pool == __null.
OMP: Error #13: Assertion failure at kmp_runtime.cpp(6480).
OMP: Hint: Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see http://www.intel.com/software/products/support/.

而且这个案子真的很棘手。

  1. data.table 1.10.4 和 1.10.4-3 对我来说是一样的。
  2. 我有一个带有一些并行代码的小插图,当我运行所有块时可以毫无问题地运行。 但是编织那个小插图会出现上述错误。
  3. 如果我在小插图的开头放一个简单的并行代码mclapply(1:2, sqrt) ,编织小插图不再有错误!

这一切似乎都与环境变化有关。 不幸的是,我现在没有一个简单的可重现的例子。 我的代码非常复杂,涉及很多其他事情。

像 dracodoc 一样,让 (6480) 随机捕获。 macOS 10.13.3、R 3.4.3、data.table 1.10.4-3。 这里只是普通的 R 和过于复杂的代码,无法重现。

简单的 mclapply 在代码开始时工作,有时也使其余代码也工作。 在我的情况下,添加mclapply(1:2, sqrt)并不能解决问题,但运行看似随机的试验次数(现在以for (i in 1:10) mclapply(1:10000000, sqrt)开始代码)。

编辑:唉,执行似乎不稳定,虽然 mcmapply 开始了,但它会在一段时间后挂起。

我刚刚看到了这些进一步的评论。 请尝试开发 1.10.5 或等待下一个 CRAN 版本(希望很快)。 如果之后仍然存在问题,请提出新问题。

我仍然看到与 dev 1.10.5 相同的问题。 新问题已创建。

此页面是否有帮助?
0 / 5 - 0 等级