CPU Miner Set-Up for the Monero XMR Coin

Quick intro on how to use Tanguy Pruvot’s version of the “cpuminer-multi” tool to CPU mine Monero Coins.

This guide is continually updated on the wiki. Please see there to get the latest version.

Important Notes

♦ Version: 1, 01/10/2015

♦ This tutorial is provided as a service to the community and if you decide to follow these instructions, you do this on your own responsibility.

♦ Never run miners and such applications with root rights, ie. never sudo them.

Introduction

Currently, in the year 2015, Monero’s hash-based memory-bound proof-of-work algorithm CryptoNight still is considered ASIC resistant and even a pure CPU miner is able to produce coins. I have not made the calculation if the energy-cost to equipment-costs to money-gain relation is advantageous, but, hey, it’s for the fun :)

Before start mining, you need a Monero address. There are multiple ways to get one, and one possibility is described here.

Miner Set-up

In this guide, we use Tanguy Pruvot’s version of the “cpuminer-multi” tool. It’s one of the most advanced CPU miner applications, supporting an impressive amount of algorithms. Cryptonight, used by Monero, is one of them.

On way of setting up the CPU miner is described on this page. Alternative ways of performing the installation are of course fine.

Running the Miner

Running the Miner on its own is not efficient. His work will very likely result in Stale Blocks, ie. Blocks that have already been found by other Miners. To increase efficiency and to obtain a relatively predicable Mining Reward return, the best is to use a Mining Pool.

The Mining Pool URL is configured at the command line. The exact syntax should be described on the pool’s web page. In this example, I use http://xmr.poolto.be. (Note: I’m not related to the owner of this pool, I don’t get ‘a bonus’ if you use this pool, and the server is not located in Belgium).

A classic command line looks like this:

./cpuminer -a cryptonight -o stratum+tcp://xmr.poolto.be:2999 -u -p x --api-bind 0

-a           : Mining Algorithm, "cryptonight" in case of Monero.
-u           : User, in case of the Monero Pool server, it's the address that will receive the Mining Reward.
-p           : Password, received from server owner, most of times 'x' for public servers.
-o           : Pool server URL, with
                    stratum+tcp: - Protocol
                    //xmr.poolto.be - Server Address
                    :2999 - Server Port
--api-bind 0 : Disables the Miner's remote monitoring functionality. No listening port is open.
               See the installation tutorial for more information.

Example log/console output:

monero@NOSHIP ~/cpuminer-multi $ ./cpuminer -a cryptonight -o stratum+tcp://xmr.poolto.be:2999 -u 45mezmBHxtCivwct1xhKXycUcKHDhmkBAP9wRuEVsK1BjX7TxVVBZSYAPXY7mMbRmC8vYqYnr4ggwJDQEGCUJXLHKr56hwJ -p x --api-bind 0

** cpuminer-multi 1.2-dev by Tanguy Pruvot (tpruvot@github) **
BTC donation address: 1FhDPLPpw18X4srecguG3MxJYe4a1JsZnd

[2015-09-27 14:16:46] Using JSON-RPC 2.0
[2015-09-27 14:16:46] CPU Supports AES-NI: NO
[2015-09-27 14:16:46] Starting Stratum on stratum+tcp://xmr.poolto.be:2999
[2015-09-27 14:16:46] 4 miner threads started, using 'cryptonight' algorithm.
[2015-09-27 14:16:48] Stratum difficulty set to 500
[2015-09-27 14:16:50] CPU #1: 34.61 H/s
[2015-09-27 14:16:50] CPU #0: 33.65 H/s
[2015-09-27 14:16:50] CPU #2: 30.65 H/s
[2015-09-27 14:16:51] CPU #3: 22.59 H/s
[2015-09-27 14:16:51] CPU #0: 30.98 H/s
[2015-09-27 14:16:51] accepted: 1/1 (100.00%), 118.83 H/s yes!
[2015-09-27 14:16:52] CPU #2: 31.06 H/s
:

To exit the Miner, hit CTRL+C.

Please verify that the output shows “….H/s yes!”. When “….H/s nooooo!” appears, your result submission has not been accepted and “something” is wrong. Please note that “something is wrong” is merely the only information that you get about the problem – happy debugging!

Error Handling and Autonomous Operation

If you plan to let the Miner run as background process, in a terminal window or as daemon, you need to keep an eye on the log/output. For more information, please have a look to the section Error Handling and Autonomous Operation in the dedicated article about the miner tool.

Command-Line Options

monero@NOSHIP ~/cpuminer-multi $ ./cpuminer --help

** cpuminer-multi 1.2-dev by Tanguy Pruvot (tpruvot@github) **
BTC donation address: 1FhDPLPpw18X4srecguG3MxJYe4a1JsZnd

Usage: cpuminer-multi [OPTIONS]
Options:
  -a, --algo=ALGO       specify the algorithm to use
                          scrypt       scrypt(1024, 1, 1) (default)
                          scrypt:N     scrypt(N, 1, 1)
                          sha256d      SHA-256d
                          axiom        Shabal-256 MemoHash
                          blake        Blake-256 (SFR)
                          blakecoin    Blakecoin
                          blake2s      Blake-2 S
                          bmw          BMW 256
                          c11/flax     C11
                          cryptolight  Cryptonight-light
                          cryptonight  Monero
                          dmd-gr       Diamond-Groestl
                          drop         Dropcoin
                          fresh        Fresh
                          groestl      GroestlCoin
                          heavy        Heavy
                          keccak       Keccak
                          luffa        Luffa
                          lyra2re      Lyra2RE
                          lyra2rev2    Lyra2REv2 (Vertcoin)
                          myr-gr       Myriad-Groestl
                          neoscrypt    NeoScrypt(128, 2, 1)
                          nist5        Nist5
                          pluck        Pluck:128 (Supcoin)
                          pentablake   Pentablake
                          quark        Quark
                          qubit        Qubit
                          shavite3     Shavite3
                          skein        Skein+Sha (Skeincoin)
                          skein2       Double Skein (Woodcoin)
                          s3           S3
                          x11          X11
                          x13          X13
                          x14          X14
                          x15          X15
                          zr5          ZR5
  -o, --url=URL         URL of mining server
  -O, --userpass=U:P    username:password pair for mining server
  -u, --user=USERNAME   username for mining server
  -p, --pass=PASSWORD   password for mining server
      --cert=FILE       certificate for mining server using SSL
  -x, --proxy=[PROTOCOL://]HOST[:PORT]  connect through a proxy
  -t, --threads=N       number of miner threads (default: number of processors)
  -r, --retries=N       number of times to retry if a network call fails
                          (default: retry indefinitely)
  -R, --retry-pause=N   time to pause between retries, in seconds (default: 30)
      --time-limit=N    maximum time [s] to mine before exiting the program.
  -T, --timeout=N       timeout for long poll and stratum (default: 300 seconds)
  -s, --scantime=N      upper bound on time spent scanning current work when
                          long polling is unavailable, in seconds (default: 5)
      --randomize       Randomize scan range start to reduce duplicates
  -f, --diff-factor     Divide req. difficulty by this factor (std is 1.0)
  -m, --diff-multiplier Multiply difficulty by this factor (std is 1.0)
  -n, --nfactor         neoscrypt N-Factor
      --coinbase-addr=ADDR  payout address for solo mining
      --coinbase-sig=TEXT  data to insert in the coinbase when possible
      --no-longpoll     disable long polling support
      --no-getwork      disable getwork support
      --no-gbt          disable getblocktemplate support
      --no-stratum      disable X-Stratum support
      --no-extranonce   disable Stratum extranonce support
      --no-redirect     ignore requests to change the URL of the mining server
  -q, --quiet           disable per-thread hashmeter output
      --no-color        disable colored output
  -D, --debug           enable debug output
  -P, --protocol-dump   verbose dump of protocol-level activities
  -S, --syslog          use system log for output messages
  -B, --background      run the miner in the background
      --benchmark       run in offline benchmark mode
      --cputest         debug hashes from cpu algorithms
      --cpu-affinity    set process affinity to cpu core(s), mask 0x3 for cores 0 and 1
      --cpu-priority    set process priority (default: 0 idle, 2 normal to 5 highest)
  -b, --api-bind        IP/Port for the miner API (default: 127.0.0.1:4048)
      --api-remote      Allow remote control
      --max-temp=N      Only mine if cpu temp is less than specified value (linux)
      --max-rate=N[KMG] Only mine if net hashrate is less than specified value
      --max-diff=N      Only mine if net difficulty is less than specified value
  -c, --config=FILE     load a JSON-format configuration file
  -V, --version         display version information and exit
  -h, --help            display this help text and exit

 

8 thoughts on “CPU Miner Set-Up for the Monero XMR Coin”

    1. I did no real research in this direction, so I only can give my educated guess :)

      Monero uses the CryptoNight Proof-Of-Work algorithm, which seems to have some AES components in it (1), but apparently (2) the only “documentation” on how it works is the source code. That’s not a good point when it comes to crypto obviously. AES-IN provides new CPU instructions (3) that have to be used explicitely by the code.

      So, I see 2 ways to actually finding out what the answer to your question is:

      (a) Have a look in the “cpuminer” source code to see if these instructions are used, and then do (b) to test if they are used correctly.
      (b) Benchmark the 2 variations. (Which might be a bit tricky since one needs to change CPU, which brings other parameter variations along.)

      (1) https://en.wikipedia.org/wiki/CryptoNote#Egalitarian_proof_of_work
      (2) https://downloads.getmonero.org/whitepaper_review.pdf
      (3) https://en.wikipedia.org/wiki/AES_instruction_set#New_instructions

      Out of curiosity, I’ll do (a) when I have a bit of time and post the result here.

      In the meantime, till proof of the contrary, I would say “YES” (to mine *efficiently* without AES-NI)

      Update to “I don’t know, need to test” (see next comment).

      1. Update (I couldn’t resist :)

        The CryptoNight code of the “cpuminer” has a method “cryptonight_hash_ctx_aes_ni()”:
        https://github.com/tpruvot/cpuminer-multi/blob/windows/algo/cryptonight.c#L246

        Which *can” use the AES-NI:
        https://github.com/tpruvot/cpuminer-multi/blob/windows/asm/aesb-x64.S#L48

        This is “blocked” by a combination of compile time definitions, which I haven’t figured totally out yet. According to readme and “make” output, the NI are included by a default LINUX compile configuration, which then raises the question what happens when you start the code on a CPU without the NI.

        Did you tried this?

  1. hi
    ” This is “blocked” by a combination of compile time definitions, which I haven’t figured totally out yet. According to readme and “make” output, the NI are included by a default LINUX compile configuration, which then raises the question what happens when you start the code on a CPU without the NI.

    Did you tried this?”

    im see in you tuto you cpu dont have AES-NI Enabled ( by the way, others cpu-multi like a wolf or other they cant run under linux without AES-NI) im tried run under linux and they fail in the compilation-code-

    im tested under Lunbutu ( 16.10) and works without AES-NI :)

  2. If you would like to compile and use cpuminer_multi (wolf9466 branch: https://github.com/wolf9466/cpuminer-multi) on a computer without the AES-NI instructions, do the following:
    Get the newest version from git repository:
    git clone https://github.com/wolf9466/cpuminer-multi.git
    cd to the directory
    start the compilation with the flags to circumvent the AES-NI option:
    ./configure –disable-aes-ni –disable-linux-hugepages
    (the –disable-linux-hugepages is sometimes not necessary, try without it first, if you get compilation errors, use the above flag).
    It is also advisable to tune the compilation flags for your specific processor. This can be done by editing the ‘Makefile.in’. For a non AES-NI configuration search for @USE_LOBOTOMIZED_AES_TRUE. The following flags work perfectly for a core2 machine compiled on gcc4.4.7. (Chect your gcc man page to see which particular processors are supported by your version of the compiler.)
    @USE_LOBOTOMIZED_AES_TRUE@am__append_2 = -O3 -fno-strict-aliasing -march=core2 -mmmx -msse -msse2 -msse3 -mfpmath=both
    (on older gcc use -mfpmath=sse,387)
    After editing the Makefile.in, do
    make distclean
    before the ./configure…

    Speed: A dual dual-core (NUMA Sun Xfire series) AMD Opteron computer (use -march=opteron -mmmx -msse -msse2 -m3dnow -mfpmath=both) 2.2 GHz performs around 22.5 H/s, whereas on a slightly older Sun of the same series, with 2 GHz processors gives approx. 19.5 H/s.
    A dual quad-core (non-numa) XEON (core2) computer (use the -core2 flags mentioned) gives approx. 93.5 H/s.

    So yes, it is possible to mine Monero without an AES-NI processor. If you have a bunch of such computers, they can be be a nice, but relatively slow mining operation :)
    Presently 100 H/s will give you an average revenue of 0.02 XMR/day. Find a pool without pool fee (there are some, usually smaller, but beware that the pool has to have at least 20-30 KH/s to give you any chance to get some Moneroj in reasonable time), make the Monero address (for that you can use https://moneroaddress.org/, but I recommend to cycle the addresses several times, and then use the address you got as the “Custom entropy” entry. This way you would be more certain that somebody else did not get your key already – seems to me to be more secure regarding the generation of randomness in computers).

    1. Error in my text:
      For a pool selection I actually meant pools between 20 and 30 KH/s (Kilo, not Mega!). Sorry for that.

      [Note Tasha: I updated to original comment]

      Actually I am presently not aware of a pool (as of writing) making more then 10M/h, but the two mentioned at http://moneropools.com/ (of course there are other pools not cited there!) which have more than 1MH/s presently both have high total fee. And you would be probably gaining every half an hour or so, but your earning would be very low per block.
      Actually in a long run it should even out (except the fee)… It is worth experimenting though. However, it is important for the network health to have more smaller pools!
      Big pool – many blocks – small gaining steps – shorter wait (but you always have to reach the minimum payment anyway)
      Small/medium pool – few blocks – larger gaining steps – longer wait
      Minor pool – if there is nobody, you are on your own, so the wait time is huge

Leave a Reply

Your email address will not be published. Required fields are marked *