2
$\begingroup$

Pytorch seems to run 10 times slower on a 16 core machine vs 8 core machine. Any thoughts on why that is and what/if any thing I can do to speed up the 16 core machine? Thank you

Below is a list of details in the order in which you find them.

  1. 16 core pytorch env
  2. 16 core lscpu
  3. 8 core pytroch evn
  4. 8 core lscpu
  5. 16 core CMake Cache can be made avaible
  6. 8 core CMake Cache can be made avaible

Pytorch was built from source on both 16 core and 8 core

16 Core Details

PyTorch version: 1.7.0+cpu
Is debug build: True
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.4 LTS (x86_64)
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Clang version: Could not collect
CMake version: version 3.10.2

Python version: 3.6 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.4
[pip3] torch==1.7.0+cpu
[pip3] torchvision==0.4.2
[conda] Could not collect


Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          16
On-line CPU(s) list:             0-15
Thread(s) per core:              1
Core(s) per socket:              8
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           45
Model name:                      Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz
Stepping:                        7
CPU MHz:                         2700.057
CPU max MHz:                     2900.0000
CPU min MHz:                     1200.0000
BogoMIPS:                        5799.68
Virtualization:                  VT-x
L1d cache:                       512 KiB
L1i cache:                       512 KiB
L2 cache:                        4 MiB
L3 cache:                        40 MiB
NUMA node0 CPU(s):               0,2,4,6,8,10,12,14
NUMA node1 CPU(s):               1,3,5,7,9,11,13,15
Vulnerability Itlb multihit:     KVM: Vulnerable
Vulnerability L1tf:              Mitigation; PTE Inversion
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acp i mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmonpebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_ cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadl ine_timer aes xsave avx lahf_lm pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority e pt vpid xsaveopt dtherm arat pln pts md_clear flush_l1d

8 Core Details

PyTorch version: 1.7.0+cpu
Is debug build: True
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.4 LTS (x86_64)
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Clang version: Could not collect
CMake version: version 3.10.2

Python version: 3.6 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.4
[pip3] torch==1.7.0+cpu
[pip3] torchvision==0.4.2
[conda] Could not collect


Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              8
On-line CPU(s) list: 0-7
Thread(s) per core:  2
Core(s) per socket:  4
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               58
Model name:          Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz
Stepping:            9
CPU MHz:             3491.793
CPU max MHz:         3700.0000
CPU min MHz:         1200.0000
BogoMIPS:            5387.33
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            6144K
NUMA node0 CPU(s):   0-7
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
$\endgroup$
2
  • 1
    $\begingroup$ You can't simply compare the amount of cores without looking at the rest too. Technically these are 4 & 8 core systems, they have 8 and 16 threads. Intel® Xeon® Processor E5-2690, Intel® Core™ i7-3740QM Processor. You're comparing a Server CPU with a Mobile CPU. $\endgroup$ – Mast Apr 23 at 5:50
  • $\begingroup$ The xeon is apparently 28% quicker when using all cores, the i7 is 5% quicker on single core (cpuboss.com/cpus/Intel-Xeon-E5-2690-vs-Intel-Core-i7-3740QM ). So while I wouldn't expect things to be any quicker on the Xeon with 16 threads, I don't think that explains a 10x slowdown using it. (More likely it is waiting on memory, or a simple scalability limit in the (unnamed) algorithm.) $\endgroup$ – Darren Cook Apr 27 at 9:21
2
$\begingroup$

I don't have any answer as to why this is. The hand-wavy answer I once received was that PyTorch doesn't effectively utilize large number of CPU cores. But as to your second question, I have experienced the same issue using the python framework and had success using the torch.set_num_threads(n) function to artificially limit cores on machines with more CPUs which improved performance, perhaps this will work for the C++ API as well.

$\endgroup$
1
  • 3
    $\begingroup$ WOW, thank you so much, like you said it doesn't answer the question but it provides the solution. I have had this question posted on the pytorch github page for 6 days prior to posting here $\endgroup$ – rilesdg3 Apr 22 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.