Install ethminer in a machine with NVIDIA video card under Ubuntu 16.04 LTS

This is simple “how to” to get started mining crypto currency with explanations using Ethash algorithm like Ethererum. Just follow the simple steps and you’ll have an optimized GPU for Ethash crypto currencies:

STEP 1) Download latest CUDA from NVDIA site.

Open your favorite browser and go to

http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/

and search for copy the link

cuda-repo-ubuntu1604-

in our case the latest version of CUDA 9.1.85 is

http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.1.85-1_amd64.deb

There is also

cuda-repo-ubuntu1604_8.0.44-1_amd64.deb 4.0KB 2017-09-22 22:08
cuda-repo-ubuntu1604_8.0.61-1_amd64.deb 4.0KB 2017-09-22 22:08
cuda-repo-ubuntu1604_9.0.176-1_amd64.deb 4.0KB 2017-09-22 22:09
cuda-repo-ubuntu1604_9.1.85-1_amd64.deb 4.0KB 2017-12-02 01:29

you could try them to see if you have a better performance for your video card with some of the older CUDA platform.
So now we download the file with wget just execute

cd ~
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.1.85-1_amd64.deb

STEP 2) Install the NVIDIA CUDA repository in you UBUNTU with

sudo dpkg -i /root/cuda-repo-ubuntu1604_9.1.85-1_amd64.deb
* If you encounter error

The public CUDA GPG key does not appear to be installed.
To install the key, run this command:
sudo apt-key adv –fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub

Just execute the command it says and then again, so in our case:

sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
dpkg -i /root/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb

STEP 3) Install repository for your proprietary drivers of NVIDIA video cards

sudo add-apt-repository -y ppa:graphics-drivers/ppa

STEP 4) Update all repositories to download the latest package lists

sudo apt-get update -y

STEP 5) Install the dependencies for the ethminer, NVIDIA video driver and NVIDIA CUDA platform5).

Install the dependencies for the ethminer, NVIDIA video driver and NVIDIA CUDA platform

sudo apt-get -y install git cmake libleveldb-dev libjsoncpp-dev libboost-all-dev libgmp-dev libreadline-dev libcurl4-gnutls-dev ocl-icd-libopencl1 opencl-headers mesa-common-dev libmicrohttpd-dev build-essential cuda libcrypto++-dev libjsonrpccpp-dev

You probably will see how you packet manager downloads around 852 packets (arround 1.5G) and installs them all, at last you must see no errors and probably there will be double “done”

done.
done.

STEP 6) now reboot the machine to load the NVIDIA proprietary driver.

At the time of this howto we the NVIDIA driver is 390.30 (nvidia-390 (390.30-0ubuntu1)), but you can list older ones and install them to see if they are better than the last. It happens frequently an older driver (but not much old) to be slightly better in performance than the latest driver, so you can experiment with other older drivers if you like.

sudo reboot

STEP 7) Check to see if your driver is loaded properly

Execute command

dmesg|grep nvidia

Here is example output

[   11.096593] nvidia: module license 'NVIDIA' taints kernel.
[   11.116551] nvidia: module verification failed: signature and/or required key missing - tainting kernel
[   11.134454] nvidia-nvlink: Nvlink Core is being initialized, major device number 248
[   11.226239] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  390.30  Wed Jan 31 22:08:49 PST 2018 (using threaded interrupts)
[   11.265963] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  390.30  Wed Jan 31 21:32:48 PST 2018
[   11.275447] [drm] [nvidia-drm] [GPU ID 0x0000001e] Loading driver
[   14.527352] nvidia-uvm: Loaded the UVM driver in 8 mode, major device number 247

So we finished the first stage, the preparation of your machine to install the ethminer. Now we move to the actual installation of the gpu mining software (and cpu mining, of course):

STEP 8)* Tune screen for better support of your scrolling history, because usually you execute the ethminer in screen (this step is not required for proper working of ethminer)

echo "termcapinfo xterm* ti@:te@" > /root/.screenrc

STEP 9) Start screen and clone the ethminer repository

git clone https://github.com/ethereum-mining/ethminer

STEP 10) Compile ethminer with “native” optimizations for the compiler gnu gcc. It has probably no impact of the GPU computing, but still it is a good practice to build the source with the best suited optimization for you mining machine.

mkdir -p ./ethminer/build
cd ./ethminer/build
export CFLAGS="-O2 -march=native -msse3 -fomit-frame-pointer -pipe"
export CHOST="x86_64-pc-linux-gnu"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-Wl,-O1"
cmake .. -DETHASHCUDA=ON -DETHASHCL=ON
make -j 4

STEP 11) Execute ethminer, but before you must execute some tuning exports for the GPU

export GPU_FORCE_64BIT_PTR=0
export GPU_MAX_HEAP_SIZE=100
export GPU_USE_SYNC_OBJECTS=1
export GPU_MAX_ALLOC_PERCENT=100
export GPU_SINGLE_ALLOC_PERCENT=100
cd ~/ethminer/build/ethminer
./ethminer -U -F http://yourpooladdress:80/11111111111111111111111111111111111/miner-01

In the example above we use a pool: yourpooladdress and the ethereum address 11111111111111111111111111111111111 – the two values are not valid, SET YOUR VALUES, do not use this fake values!

*Running the miner is simple just execute

ethminer

  • -U – When mining use the GPU via CUDA.
  • -G – When mining use the GPU via OpenCL.
  • -X,–cuda-opencl Use OpenCL + CUDA in a system with mixed AMD/Nvidia cards. May require setting –opencl-platform 1

*Here is the output of the properly built and running ethminer:

m 10:54:42|ethminer| ethminer version 0.14.0.dev2
m 10:54:42|ethminer| Build: Linux/g++ / Release
cu 10:54:45|ethminer| Using grid size 8192 , block size 128
m 10:54:45|ethminer| not-connected
ℹ 10:54:45|getwork | Connected to http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
ℹ 10:54:45|getwork | Spinning up miners...
ℹ 10:54:45|cuda-0 | No work. Pause for 3 s.
ℹ 10:54:45|getwork | Received new job #f0a5f915 from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
ℹ 10:54:48|cuda-0 | Initialising miner 0
m 10:54:50|ethminer| Speed 0.00 Mh/s gpu/0 0.00 [A0+0:R0+0:F0] Time: 00:00
cu 10:54:50|cuda-0 | Using device: Tesla K80 (Compute 3.7)
cu 10:54:50|cuda-0 | Set Device to current
cu 10:54:50|cuda-0 | Resetting device
cu 10:54:50|cuda-0 | Allocating light with size: 39190336
cu 10:54:50|cuda-0 | Generating mining buffers
cu 10:54:50|cuda-0 | Generating DAG for GPU # 0 with dagSize: 2508191872 gridSize: 8192
m 10:54:55|ethminer| Speed 0.00 Mh/s gpu/0 0.00 [A0+0:R0+0:F0] Time: 00:00
ℹ 10:54:56|getwork | Received new job #5a34e38b from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
m 10:55:00|ethminer| Speed 0.00 Mh/s gpu/0 0.00 [A0+0:R0+0:F0] Time: 00:00
ℹ 10:55:01|getwork | Received new job #d48be1aa from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
m 10:55:05|ethminer| Speed 0.00 Mh/s gpu/0 0.00 [A0+0:R0+0:F0] Time: 00:00
m 10:55:10|ethminer| Speed 0.00 Mh/s gpu/0 0.00 [A0+0:R0+0:F0] Time: 00:00
m 10:55:15|ethminer| Speed 0.00 Mh/s gpu/0 0.00 [A0+0:R0+0:F0] Time: 00:00
ℹ 10:55:19|getwork | Received new job #7f50d832 from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
m 10:55:20|ethminer| Speed 5.56 Mh/s gpu/0 5.56 [A0+0:R0+0:F0] Time: 00:00
ℹ 10:55:21|getwork | Received new job #b41b6784 from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
ℹ 10:55:23|getwork | Received new job #b9a76ceb from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
m 10:55:25|ethminer| Speed 5.86 Mh/s gpu/0 5.86 [A0+0:R0+0:F0] Time: 00:00
m 10:55:30|ethminer| Speed 6.30 Mh/s gpu/0 6.30 [A0+0:R0+0:F0] Time: 00:00
m 10:55:35|ethminer| Speed 6.57 Mh/s gpu/0 6.57 [A0+0:R0+0:F0] Time: 00:00
ℹ 10:55:38|getwork | Received new job #e0329f03 from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
m 10:55:40|ethminer| Speed 6.60 Mh/s gpu/0 6.60 [A0+0:R0+0:F0] Time: 00:00
m 10:55:45|ethminer| Speed 6.50 Mh/s gpu/0 6.50 [A0+0:R0+0:F0] Time: 00:01
m 10:55:50|ethminer| Speed 6.58 Mh/s gpu/0 6.58 [A0+0:R0+0:F0] Time: 00:01
m 10:55:55|ethminer| Speed 6.58 Mh/s gpu/0 6.58 [A0+0:R0+0:F0] Time: 00:01
m 10:56:00|ethminer| Speed 6.68 Mh/s gpu/0 6.68 [A0+0:R0+0:F0] Time: 00:01
m 10:56:05|ethminer| Speed 6.58 Mh/s gpu/0 6.58 [A0+0:R0+0:F0] Time: 00:01
m 10:56:10|ethminer| Speed 6.58 Mh/s gpu/0 6.58 [A0+0:R0+0:F0] Time: 00:01
m 10:56:15|ethminer| Speed 6.68 Mh/s gpu/0 6.68 [A0+0:R0+0:F0] Time: 00:01
m 10:56:20|ethminer| Speed 6.58 Mh/s gpu/0 6.58 [A0+0:R0+0:F0] Time: 00:01
m 10:56:25|ethminer| Speed 6.68 Mh/s gpu/0 6.68 [A0+0:R0+0:F0] Time: 00:01
ℹ 10:56:25|getwork | Received new job #22e64b5b from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
m 10:56:30|ethminer| Speed 6.50 Mh/s gpu/0 6.50 [A0+0:R0+0:F0] Time: 00:01
m 10:56:35|ethminer| Speed 6.50 Mh/s gpu/0 6.50 [A0+0:R0+0:F0] Time: 00:01
m 10:56:40|ethminer| Speed 6.58 Mh/s gpu/0 6.58 [A0+0:R0+0:F0] Time: 00:01
ℹ 10:56:41|cuda-0 | Nonce 0x656b10dfbe95134f submitted to http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
ℹ 10:56:42|getwork | **Accepted in 500 ms.
m 10:56:45|ethminer| Speed 6.68 Mh/s gpu/0 6.68 [A1+0:R0+0:F0] Time: 00:02
ℹ 10:56:47|getwork | Received new job #304cc9df from http://eth-eu.dwarfpool.com:80/11111111111111111111111111111111111/miner-02
m 10:56:50|ethminer| Speed 6.50 Mh/s gpu/0 6.50 [A1+0:R0+0:F0] Time: 00:02
m 10:56:55|ethminer| Speed 6.51 Mh/s gpu/0 6.51 [A1+0:R0+0:F0] Time: 00:02

* Here is the all options of the ethminer:

./ethminer --help
Usage ethminer [OPTIONS]
Options:

Work farming mode:
    -F,--farm <url>  Put into mining farm mode with the work server at URL (default: http://127.0.0.1:8545)
    -FF,-FO, --farm-failover, --stratum-failover <url> Failover getwork/stratum URL (default: disabled)
        --farm-retries <n> Number of retries until switch to failover (default: 3)
        -S, --stratum <host:port>  Put into stratum mode with the stratum server at host:port
        -SF, --stratum-failover <host:port>  Failover stratum server at host:port
    -O, --userpass <username.workername:password> Stratum login credentials
    -FO, --failover-userpass <username.workername:password> Failover stratum login credentials (optional, will use normal credentials when omitted)
    --work-timeout <n> reconnect/failover after n seconds of working on the same (stratum) job. Defaults to 180. Don't set lower than max. avg. block time
    -SC, --stratum-client <n>  Stratum client version. Version 1 support only.
    -SP, --stratum-protocol <n> Choose which stratum protocol to use:
        0: official stratum spec: ethpool, ethermine, coinotron, mph, nanopool (default)
        1: eth-proxy compatible: dwarfpool, f2pool, nanopool (required for hashrate reporting to work with nanopool)
        2: EthereumStratum/1.0.0: nicehash
    -RH, --report-hashrate Report current hashrate to pool (please only enable on pools supporting this)
    -HWMON [n] Displays gpu temp, fan percent and power usage. Note: In linux, the program uses sysfs, which may require running with root priviledges.
        0: Displays only temp and fan percent (default)
        1: Also displays power usage
    --exit Stops the miner whenever an error is encountered
    -SE, --stratum-email <s> Email address used in eth-proxy (optional)
    --farm-recheck <n>  Leave n ms between checks for changed work (default: 500). When using stratum, use a high value (i.e. 2000) to get more stable hashrate output

Benchmarking mode:
    -M [<n>],--benchmark [<n>] Benchmark for mining and exit; Optionally specify block number to benchmark against specific DAG.
    --benchmark-warmup <seconds>  Set the duration of warmup for the benchmark tests (default: 3).
    --benchmark-trial <seconds>  Set the duration for each trial for the benchmark tests (default: 3).
    --benchmark-trials <n>  Set the number of benchmark trials to run (default: 5).
Simulation mode:
    -Z [<n>],--simulation [<n>] Mining test mode. Used to validate kernel optimizations. Optionally specify block number.
Mining configuration:
    -G,--opencl  When mining use the GPU via OpenCL.
    -U,--cuda  When mining use the GPU via CUDA.
    -X,--cuda-opencl Use OpenCL + CUDA in a system with mixed AMD/Nvidia cards. May require setting --opencl-platform 1
    --opencl-platform <n>  When mining using -G/--opencl use OpenCL platform n (default: 0).
    --opencl-device <n>  When mining using -G/--opencl use OpenCL device n (default: 0).
    --opencl-devices <0 1 ..n> Select which OpenCL devices to mine on. Default is to use all
    -t, --mining-threads <n> Limit number of CPU/GPU miners to n (default: use everything available on selected platform)
    --list-devices List the detected OpenCL/CUDA devices and exit. Should be combined with -G or -U flag
    --display-interval <n> Set mining stats display interval in seconds. (default: every 5 seconds)
    -L, --dag-load-mode <mode> DAG generation mode.
        parallel    - load DAG on all GPUs at the same time (default)
        sequential  - load DAG on GPUs one after another. Use this when the miner crashes during DAG generation
        single <n>  - generate DAG on device n, then copy to other devices
 OpenCL configuration:
    --cl-kernel <n>  Use a different OpenCL kernel (default: use stable kernel)
        0: stable kernel
        1: experimental kernel
    --cl-local-work Set the OpenCL local work size. Default is 128
    --cl-global-work Set the OpenCL global work size as a multiple of the local work size. Default is 8192 * 128
    --cl-parallel-hash <1 2 ..8> Define how many threads to associate per hash. Default=8
 CUDA configuration:
    --cuda-block-size Set the CUDA block work size. Default is 128
    --cuda-grid-size Set the CUDA grid size. Default is 8192
    --cuda-streams Set the number of CUDA streams. Default is 2
    --cuda-schedule <mode> Set the schedule mode for CUDA threads waiting for CUDA devices to finish work. Default is 'sync'. Possible values are:
        auto  - Uses a heuristic based on the number of active CUDA contexts in the process C and the number of logical processors in the system P. If C > P, then yield else spin.
        spin  - Instruct CUDA to actively spin when waiting for results from the device.
        yield - Instruct CUDA to yield its thread when waiting for results from the device.
        sync  - Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the results from the device.
    --cuda-devices <0 1 ..n> Select which CUDA GPUs to mine on. Default is to use all
    --cuda-parallel-hash <1 2 ..8> Define how many hashes to calculate in a kernel, can be scaled to achieve better performance. Default=4
    --cuda-noeval  bypass host software re-evalution of GPU solutions.
        This will trim some milliseconds off the time it takes to send a result to the pool.
        Use at your own risk! If GPU generates errored results they WILL be forwarded to the pool
        Not recommended at high overclock.
 API core configuration:
    --api-port Set the api port, the miner should listen to. Use 0 to disable. Default=0, use negative numbers to run in readonly mode. for example -3333.
 General Options:
    -v,--verbosity <0 - 9>  Set the log verbosity from 0 to 9 (default: 5). Set to 9 for switch time logging.
    -V,--version  Show the version and exit.
    -h,--help  Show this help message and exit.
 Envionment variables:
     NO_COLOR - set to any value to disable color output. Unset to re-enable color output.

One thought on “Install ethminer in a machine with NVIDIA video card under Ubuntu 16.04 LTS”

Leave a Reply

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