我可以同时运行两个单独的 jupyter notebook 文件,而不会在单 CPU 计算机上减速吗?

Tho*_*ald 3 python cpu-architecture cpu-usage jupyter-notebook

我目前正在 jupyter notebook 中运行 python 函数,这需要很长时间。Python 说它在大约 98% 的 CPU 上运行,但是,仍然有大约 60% 的 CPU 未使用。现在经过一些谷歌搜索,我发现这与我的处理器线程有关(我不是计算机工程师,如果这是不正确的,我很抱歉)。但是,我想知道是否可以在 jupyter notebook 中运行另一个函数,它会占用 60% 未使用的活动中的一部分,还是将 99% 分配给两个函数,从而减慢这两个函数的速度。我希望你们能帮忙。如果有什么不清楚的,请告诉我。

PS 我使用的是 2012 年末的 macbook pro 视网膜(我知道),2,5 gHZ intel core i5,8 gbs 内存。它有两个内核和一个处理器。

Pet*_*des 7

您有一个 Intel Sandybridge 或 Ivybridge CPU。它有两个带有超线程的物理内核,因此对于操作系统来说,它可能显示为 4 个逻辑内核。

每个内核都有自己的私有 L1i/d 和 L2 缓存,但 L3(和内存带宽)在内核之间共享。

Running a separate process or threads on the other physical CPU can slow down the first one by these mechanisms:

  • dual-core max turbo clock speed is lower than single-core turbo.
  • they compete for memory bandwidth and L3 cache footprint. (i.e. more L3 cache misses).

If L3 cache misses and memory bandwidth aren't significant bottlenecks for your workload, then using both cores for separate tasks is pretty much pure win.

Running 4 threads (so the OS will have to schedule tasks onto both logical cores of each physical core) will give some slowdown, but it depends a lot more on the details of the workload. See Agner Fog's microarch guide (http://agner.org/optimize/) for the asm / cpu-architecture details of how HT statically partitions or dynamically shares various execution resources. But really just try it and see.

Probably a single thread has some stalls for cache misses and other bottlenecks other than pure throughput, so you could gain some throughput at the expense of single-core performance with hyperthreading.