xmr-stak-cpu icon indicating copy to clipboard operation
xmr-stak-cpu copied to clipboard

12 Core VPS, MEMORY ALLOC FAILED: mmap failed (Would really like some help)

Open StealthBadger747 opened this issue 7 years ago • 16 comments

I have a 12 physical core VPS on which I am trying to run XMR-STAK-CPU on, but I get the MEMORY ALLOC FAILED: mmap failed error whenever I try to start the program. I am running Centos 7 and I complied the miner myself. I tried doing what it says to do in the README, but the command fails, even when executing as root. sudo sysctl -w vm.nr_hugepages=128 sysctl: permission denied on key 'vm.nr_hugepages' I also added these lines to /etc/security/limits.conf

  • soft memlock 262144
  • hard memlock 262144 Even running the miner as root doesn't solve my problem.
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
-------------------------------------------------------------------
xmr-stak-cpu 1.3.0-1.5.0 mining software, CPU Version.
Based on CPU mining code by wolf9466 (heavily optimized by fireice_uk).
Brought to you by fireice_uk and psychocrypt under GPLv3.
 
Configurable dev donation level is set to 2.0 %
 
-------------------------------------------------------------------
[2017-10-19 17:46:47] : Starting single thread, affinity: 0.
[2017-10-19 17:46:47] : Starting single thread, affinity: 1.
[2017-10-19 17:46:47] : Starting single thread, affinity: 2.
[2017-10-19 17:46:47] : Starting single thread, affinity: 3.
[2017-10-19 17:46:47] : Starting single thread, affinity: 4.
[2017-10-19 17:46:47] : Starting single thread, affinity: 5.
[2017-10-19 17:46:47] : Starting single thread, affinity: 11.
[2017-10-19 17:46:47] : Starting single thread, affinity: 12.
[2017-10-19 17:46:47] : Starting single thread, affinity: 13.
[2017-10-19 17:46:47] : Starting single thread, affinity: 14.
[2017-10-19 17:46:47] : Starting single thread, affinity: 15.
[2017-10-19 17:46:47] : Starting single thread, affinity: 16.
[2017-10-19 17:46:47] : Connecting to pool pool.supportxmr.com:3333 ...
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : hwloc: memory pinned
[2017-10-19 17:46:47] : MEMORY ALLOC FAILED: mmap failed
[2017-10-19 17:46:47] : Connected. Logging in...
[2017-10-19 17:46:47] : Difficulty changed. Now: 1000.
[2017-10-19 17:46:47] : New block detected.
[2017-10-19 17:46:48] : Result accepted by the pool.
[2017-10-19 17:46:51] : Result accepted by the pool.

StealthBadger747 avatar Oct 19 '17 17:10 StealthBadger747

try running with "no_mlck" once, and then with "never". Anyway, would you tell me which VPS service are you using ? :D

0z4ck avatar Oct 19 '17 18:10 0z4ck

Both "no_mlck" and "never" gave MEMORY ALLOC FAILED: mmap failed.

StealthBadger747 avatar Oct 19 '17 21:10 StealthBadger747

What kind of VPS is that? What virtualization?

What is the output of lscpu? Some virtualizations don't support hugepages... You can also post output of dmesg | grep -i huge and grep Huge /proc/meminfo .

marki555 avatar Oct 30 '17 14:10 marki555

Have the same issue, KVM virtualization

lscpu :

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             4
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 79
Model name:            Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz
Stepping:              1
CPU MHz:               2399.996
BogoMIPS:              4799.99
Virtualization:        VT-x
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              4096K
NUMA node0 CPU(s):     0-3
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt

dmesg | grep -i huge

[    0.010445] Initializing cgroup subsys hugetlb
[    0.853517] HugeTLB registered 1 GB page size, pre-allocated 0 pages
[    0.853520] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[    3.390799] systemd[1]: Mounting Huge Pages File System...
[    3.438719] systemd[1]: Mounted Huge Pages File System.

grep Huge /proc/meminfo

AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

imakiro avatar Nov 28 '17 00:11 imakiro

Same Error on vMWare /Ubuntu :

root@osboxes:~/xmr-stak-2.0.0.tar/xmr-stak-2.0.0/xmr-stak-2.0.0/xmr-stak/build/bin# ./xmr-stak [2017-12-06 04:40:07] : MEMORY ALLOC FAILED: mmap failed [2017-12-06 04:40:07] : MEMORY ALLOC FAILED: mmap failed

xmr-stak 2.0.0 79154f7

Brought to you by fireice_uk and psychocrypt under GPLv3. Based on CPU mining code by wolf9466 (heavily optimized by fireice_uk).

Configurable dev donation level is set to 2.0%

You can use following keys to display reports: 'h' - hashrate 'r' - results 'c' - connection

[2017-12-06 04:40:07] : Start mining: MONERO [2017-12-06 04:40:07] : Starting double thread, affinity: 0. [2017-12-06 04:40:08] : hwloc: memory pinned [2017-12-06 04:40:08] : Starting double thread, affinity: 1. [2017-12-06 04:40:08] : MEMORY ALLOC FAILED: mmap failed [2017-12-06 04:40:08] : MEMORY ALLOC FAILED: mmap failed [2017-12-06 04:40:08] : hwloc: memory pinned [2017-12-06 04:40:08] : Starting double thread, affinity: 2. [2017-12-06 04:40:08] : MEMORY ALLOC FAILED: mmap failed [2017-12-06 04:40:08] : MEMORY ALLOC FAILED: mmap failed [2017-12-06 04:40:08] : hwloc: memory pinned [2017-12-06 04:40:08] : Starting double thread, affinity: 3. [2017-12-06 04:40:08] : MEMORY ALLOC FAILED: mmap failed [2017-12-06 04:40:08] : MEMORY ALLOC FAILED: mmap failed

root@osboxes:~/xmr-stak-2.0.0.tar/xmr-stak-2.0.0/xmr-stak-2.0.0/xmr-stak/build/bin# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 24 On-line CPU(s) list: 0-23 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 6 NUMA node(s): 6 Vendor ID: GenuineIntel CPU family: 6 Model: 45 Model name: Intel(R) Xeon(R) CPU E5-2440 0 @ 2.40GHz Stepping: 7 CPU MHz: 2394.230 BogoMIPS: 4788.46 Hypervisor vendor: VMware Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 15360K NUMA node0 CPU(s): 0-3 NUMA node1 CPU(s): 4-7 NUMA node2 CPU(s): 8-11 NUMA node3 CPU(s): 12-15 NUMA node4 CPU(s): 16-19 NUMA node5 CPU(s): 20-23 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc cpuid aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx hypervisor lahf_lm epb dtherm ida arat pln pts root@osboxes:~/xmr-stak-2.0.0.tar/xmr-stak-2.0.0/xmr-stak-2.0.0/xmr-stak/build/bin# dmesg | grep -i huge [ 0.148044] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages root@osboxes:~/xmr-stak-2.0.0.tar/xmr-stak-2.0.0/xmr-stak-2.0.0/xmr-stak/build/bin# grep Huge /proc/meminfo AnonHugePages: 0 kB ShmemHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB

pfreindorf avatar Dec 06 '17 09:12 pfreindorf

Problem solved, RTFM :

  • On Linux you will need to configure large page support "sudo sysctl -w vm.nr_hugepages=128" and increase your
  • ulimit -l. To do do this you need to add following lines to /etc/security/limits.conf - "* soft memlock 262144"
  • and "* hard memlock 262144". You can also do it Windows-style and simply run-as-root, but this is NOT
  • recommended for security reasons.

pfreindorf avatar Dec 06 '17 10:12 pfreindorf

For me (Linux/Ubuntu 16.04 running xmr-stak) it was enough to run; sudo sysctl -w vm.nr_hugepages=128

to get rid of the mmap ERROR, no need to set the ulimits (they were already 'unlimited').

jjaone avatar Jan 12 '18 18:01 jjaone

@jjaone You need to change ulimits if you want to run xmr-stak as a normal user. By default only root can use hugepages.

marki555 avatar Jan 12 '18 21:01 marki555

@marki555 No I didn't need to change the ulimits in my system. They were 'unlimited' to begin with.

I'm running xmr-stak as normal user in Ubuntu/Linux and it works with hugepages after the above sysctl vm.nr_hugepages setting to 128 (which of course has to be run with sudo).

jjaone avatar Jan 12 '18 22:01 jjaone

@jjaone You are correct, sir! Tested on Ubuntu 16.04 and now my Hash rate has increased perhaps by 20% or more so far. I am running xmr-stak-cpu with no command line args, are there any I should use to boost threads, or increase power consumption.

So far I got past "mmap memory allocation error" with your one liner, and no ulimit adjustments at the moment. It just works...

sudo sysctl -w vm.nr_hugepages=128

Thank you for your comments. Have a great night and good luck!

shopglobal avatar Jan 13 '18 02:01 shopglobal

@shopglobal Thanks, glad it helped. 😉

That sysctl setting command was actually in the build process generated config.txt file as a suggestion to try if mmap-related errors are encountered and it seems to work without that ulimit setting part in Ubuntu.

I don't know about other optimisations in the command line or in the config file that could help in CPU-mining in Linux. I have an old Radeon HD7700 GPU, but I still haven't found a way to use it in mining XMR in Ubuntu 16.04 with this otherwise excellent miner xmr_stak.

May I ask which hardware are you running the xmr_stak miner in Ubuntu, how many CPUs do you have and what model and type are they? How are your Hashrates with them?

I'm just starting Monero/Ethereum mining and have been trying different miners and pools with my AMD Athlon II X4 640 CPU on Linux/Ubuntu16.04 and getting with xmr_stak Monero miner hashrate of 20 H/s (with config using only 2 cores) and about 40 H/s (when config using all 4 cores).

jjaone avatar Jan 13 '18 04:01 jjaone

@jjaone I am running Intel Xeon E5-2630L on Ubuntu 16.04 with 4 cores and 8gb Ram, and I am seeing 80-90 H/s per server on a single thread. With more tweaks I could achieve maybe 2-4 times this I believe. However, profitability will not begin until we scale.

shopglobal avatar Jan 13 '18 16:01 shopglobal

I'm getting 430 h/s on 12 cores on 2x Intel E5-2620v3 (still cannot enable Hugepages despite all attempts, probably due to KVM). You can adjust the core ultilization where you see low power mode and the thread number (beginning of the line after the "{" and starts at 0 ) by adding more lines, basically copy pasting, just changing the thread ID.

StealthBadger747 avatar Jan 13 '18 16:01 StealthBadger747

Thanks @StealthBadger747
You're right and I have increased my threads to 4 in the config and added the following lines, now I am reaching 150 H/s on same Ubuntu 16.04

"cpu_threads_conf" : [ 
	{ "low_power_mode" : false, "no_prefetch" : false, "affine_to_cpu" : 0 },
	{ "low_power_mode" : false, "no_prefetch" : false, "affine_to_cpu" : 1 },
	{ "low_power_mode" : false, "no_prefetch" : false, "affine_to_cpu" : 2 },
	{ "low_power_mode" : false, "no_prefetch" : false, "affine_to_cpu" : 3 },
],

shopglobal avatar Jan 13 '18 17:01 shopglobal

Doesn't the E5-2630L have six cores?

StealthBadger747 avatar Jan 13 '18 17:01 StealthBadger747

AFAIK there is multiple models... Can't seem to find a link to E5-2630L with 4 cores....Found v2 with 6 cores and v4 10 cores.. But I am running E5-2630L v2 at 4 cores. E5-2630L v2 : https://ark.intel.com/products/64586/Intel-Xeon-Processor-E5-2630L-15M-Cache-2_00-GHz-7_20-GTs-Intel-QPI E5-2630L v4: https://ark.intel.com/products/92978/Intel-Xeon-Processor-E5-2630L-v4-25M-Cache-1_80-GHz

I double checked my CPU using the following command

cat /proc/cpuinfo  | grep 'name' | uniq

which returned

Intel (R) Xeon (R) CPU E5-2630L v2 @ 2.40 GHZ

I thought to check the processors as well, just to be sure...

cat /proc/cpuinfo  | grep process| wc -l

which returned

4

shopglobal avatar Jan 13 '18 17:01 shopglobal