英文:
makeForkCluster creates a socket cluster on Unix
问题
> library(parallel)
> cluster = makeForkCluster(2)
> cluster
socket cluster with 2 nodes on host ‘localhost’
> rm(cluster)
> .Platform$OS.type
[1] "unix"
英文:
> library(parallel)
> cluster = makeForkCluster(2)
> cluster
socket cluster with 2 nodes on host ‘localhost’
> rm(cluster)
> .Platform$OS.type
[1] "unix"
This behavior is the same on a Ubuntu 22 box and on a Mac. How come I can't create a fork cluster?
答案1
得分: 0
parallel::makeForkCluster()
设置分叉并行进程:
> cluster <- parallel::makeForkCluster(2L)
> cluster
socket cluster with 2 nodes on host 'localhost'
> str(cluster)
List of 2
$ :List of 3
..$ con : 'sockconn' int 4
.. ..- attr(*, "conn_id")=<externalptr>
..$ host: chr "localhost"
..$ rank: int 1
..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
$ :List of 3
..$ con : 'sockconn' int 5
.. ..- attr(*, "conn_id")=<externalptr>
..$ host: chr "localhost"
..$ rank: int 2
..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
- attr(*, "class")= chr [1:2] "SOCKcluster" "cluster"
以及
> parallel::clusterEvalQ(cluster, { parallelly::isForkedChild() })
[[1]]
[1] TRUE
[[2]]
[1] TRUE
英文:
parallel::makeForkCluster()
does setup forked parallel processes:
> cluster <- parallel::makeForkCluster(2L)
> cluster
socket cluster with 2 nodes on host 'localhost'
> str(cluster)
List of 2
$ :List of 3
..$ con : 'sockconn' int 4
.. ..- attr(*, "conn_id")=<externalptr>
..$ host: chr "localhost"
..$ rank: int 1
..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
$ :List of 3
..$ con : 'sockconn' int 5
.. ..- attr(*, "conn_id")=<externalptr>
..$ host: chr "localhost"
..$ rank: int 2
..- attr(*, "class")= chr [1:2] "forknode" "SOCK0node"
- attr(*, "class")= chr [1:2] "SOCKcluster" "cluster"
and
> parallel::clusterEvalQ(cluster, { parallelly::isForkedChild() })
[[1]]
[1] TRUE
[[2]]
[1] TRUE
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论