【问题标题】:Using all cores with Microsoft R Open and Google Compute Engine将所有内核与 Microsoft R Open 和 Google Compute Engine 一起使用
【发布时间】:2023-03-12 08:37:01
【问题描述】:

我在具有两个 vCPU 的 GCE 实例上使用 Microsoft R Open。这是它的规格。

$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    2
Core(s) per socket:    1
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 63
Model name:            Intel(R) Xeon(R) CPU @ 2.30GHz
Stepping:              0
CPU MHz:               2300.000
BogoMIPS:              4600.00
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              46080K
NUMA node0 CPU(s):     0,1
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush
 mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc
 eagerfpu pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hyp
ervisor lahf_lm abm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms xsaveopt

即使我有两个内核,Microsoft R Open 似乎也只能识别其中一个,所以我没有充分利用我的计算能力。我也不能手动设置线程数。

Microsoft R Open 3.3.2
The enhanced R distribution from Microsoft
Microsoft packages Copyright (C) 2016 Microsoft Corporation
Using the Intel MKL for parallel mathematical computing(using 1 cores).
Default CRAN mirror snapshot taken on 2016-11-01.
See: https://mran.microsoft.com/.
> getMKLthreads()
[1] 1
> setMKLthreads(2)
Number of threads at maximum: no change has been made.

这是显示 CPU 使用率的图表。它从不使用超过 50% 的 CPU 功率。

那么,我应该怎么做才能将我的所有内核都用于 MRO?

【问题讨论】:

  • 当你输入> library(parallel)> detectCores()时你会看到什么
  • detectCores() 返回2
  • 请看下面我的回答。

标签: r google-cloud-platform rstudio-server microsoft-r


【解决方案1】:

您正在运行超线程的 Xeon。您有 1 个带有超线程的 cpu,操作系统将其视为 2 个 cpu,但只有一个物理 cpu。 MRO 仅使用物理内核(无超线程)

【讨论】:

    【解决方案2】:

    你可以用这个:

    library(doParallel)
    no_cores <- detectCores() - 1
    registerDoParallel(cores=no_cores)

    它将比您拥有的实际核心少一个核心。它为操作系统操作留下一个核心。试试看。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-08
      • 2018-07-27
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 2019-11-25
      • 2018-04-28
      • 2018-03-17
      相关资源
      最近更新 更多