VerthashMiner =============== VerthashMiner is a high performance GPU miner for the Verthash algorithm. **Developer:** CryptoGraphics Stratum, WorkIO and GBT implementations are partly based on [cpuminer-multi](https://github.com/tpruvot/cpuminer-multi) and [lyclMiner](https://github.com/CryptoGraphics/lyclMiner) This open source release was made possible thanks to [Vertcoin project](https://vertcoin.org) and its community. ## Supported hardware - AMD GPU GCN 1.0 or later. - NVIDIA GPU with compute capability 3.0 or later. (Some compute versions may require different miner builds for the CUDA backend. e.g 8.0 requires CUDA 11.0, which removes support for 3.0.) Additionally miner requires GPU with 2GB VRAM or higher. (depends on the `WorkSize` parameter). ## Supported platforms - AMD: OpenCL 1.2+ from AMD Radeon Software driver on Windows. AMDGPU-Pro and ROCm on Linux. - NVIDIA: Both OpenCL 1.2+ and CUDA are supported through the proprietary driver. Mesa Gallium Compute and macOS are not supported. ## Download * Binary releases: https://github.com/CryptoGraphics/VerthashMiner/releases * Clone with `git clone https://github.com/CryptoGraphics/VerthashMiner.git` * Follow [Building VerthashMiner](#building-verthashminer). ## Quick start guide Miner can be configured through the command line, configuration file and a mix of both. All options are documented inside. Most parameters are optional and will be auto-configured to their default values, while some of them are mandatory. Both solo(getblocktemplate) and pooled mining(Stratum) are supported. Note: Verthash algorithm requires a special file `verthash.dat`, which can be obtained from external sources or generated by the miner using the following command(available in v0.6.2 or later): `./VerthashMiner --gen-verthash-data verthash.dat` This file is static and can be safely copied from one computer to another. VerthashMiner includes a verification stage(enabled by default) to ensure, that `verthash.dat` is valid. ### Configuration examples: ___ #### Command line only: Run `./VerthashMiner` to get a full list of possible options. Solo mining using GBT(getblocktemplate): `./VerthashMiner -u user -p password -o http://127.0.0.1:port --coinbase-addr core_wallet_address --verthash-data your_path/verthash.dat --all-cl-devices --all-cu-devices` Pooled mining using Stratum: `./VerthashMiner -u user -p password -o stratum+tcp://example.com:port --verthash-data your_path/verthash.dat --all-cl-devices --all-cu-devices` ___ #### Configuration file: All miner settings can also be managed through the configuration file. Similar to [lyclMiner](https://github.com/CryptoGraphics/lyclMiner) 1. **Generating a configuration file.** - Config file can be generated using the following command inside cmd/terminal: `./VerthashMiner -g your_config_file.conf` - Alternative (Windows). Create a file `GenerateConfig.bat` in the same folder as `VerthashMiner.exe` with the following content: `VerthashMiner -g your_config_file.conf` - **Additional notes:** - Configuration file is generated specifically for your GPU and driver setup. - Configuration file must be re-generated every time you add/remove a new Device to/from the PCIe slot. - If you want to use NVIDIA GPUs with OpenCL backend when CUDA is available, then configuration file must be generated with `--no-restrict-cuda` option. example(command line): `./VerthashMiner -g your_config_file.conf --no-restrict-cuda` or bat file: `VerthashMiner -g your_config_file.conf --no-restrict-cuda` 2. **Configuring a miner.** Open `your_config_file.conf` using any text editor and edit `"Url"`, `"Username"`, `"Password"` and `"CoinbaseAddress"`(Solo mining only) fields inside a `"Connection"` block. Additional notes: - It is recommended to adjust `BatchTimeMs` and `OccupancyPct` [parameters](#Static and Adaptive WorkSize configuration) for each `Device` to get better performance or desktop responsiveness. 3. **Use** `VerthashMiner -c your_config_file.conf` **to start mining.** - Alternative (Windows). Create a file `Run.bat` in the same folder as `VerthashMiner.exe` with the following content: `VerthashMiner -c your_config_file.conf` - **Additional notes:** - To use NVIDIA GPUs with OpenCL backend when CUDA is available: `VerthashMiner -c your_config_file.conf --no-restrict-cuda`. Note that in this case `your_config_file.conf` must be generated with `--no-restrict-cuda` too. #### Both command line and configuration file: For example you may want to configure the miner using a configuration file partly or completely. Command line options have higher priority than the file and it is possible to overwrite almost every option. `VerthashMiner -c your_config_file.conf -u user -p password` In this case miner will use a configuration file while Username and Password options will be overwritten by command line. ## There is more ### Device management Miner uses 2 backends for device management and mining algorithm implementation. - CUDA. Used for NVIDIA devices. All unsupported devices (e.g SM3.0 on CUDA 11 get automatically transfered to the OpenCL backend). - OpenCL. Used for AMD, Intel and others. If miner has been compiled with CUDA enabled, then all NVIDIA devices, which are supported by CUDA will be automatically ignored by the OpenCL backend, unless `--no-restrict-cuda` command line parameter is used. #### Selecting all devices using command line CUDA and OpenCL devices are configured separately. To select all cappable devices use `--all-cl-devices` for OpenCL devices `--all-cu-devices` for CUDA. #### Selecting specific devices using command line All devices are selected by indices. To print the list of all cappable devices use `--device-list` or `-l` option. To select specific device use `--cl-devices` for OpenCL and `--cu-devices` for CUDA. For example: `--cl-devices 0,2` will select device0 and device2. Additionally, it is possible to set specific paramaters for each device. Parameters are specified using prefixes in the following form: `device_index:prefixValue:prefixValue, device_index:prefixValue:prefixValue...` There 5 prefixes to set 5 different options: - `w` set `WorkSize` value. Must be power of 256 or 0(Automatic). Default value is `0` - `b` set `BatchTimeMs` value(Automatic work/batch size). Must be above 0. Default value is `500` - `o` set `OccupancyPct` value. Must be above 0 and less than or equal 100. Default value is `100` - `m` enables or disables device minitoring. 1 enables, 0 disable. Default value is `1` - `t` set `GPUTemperatureLimit` value in degrees C. Default value is `79`. If parameter is not set manually, then a default value will be used. Here are some examples: - `--cu-devices 0:w131072,2:w32768` will select CUDA devices 0,2 and set their `WorkSize` values to `131072` and `32768` respectively. - `--cu-devices 0:b150:m1:t60,2:w32768` will select CUDA devices 0,2 where device 0 will use an automatic work size with `BatchTimeMs = 150`, device monitoring enabled and `GPUTemperatureLimit = 60`. ### Static and Adaptive WorkSize configuration Earlier (pre v0.7.0) VerthashMiner versions have used a hardcoded `WorkSize = 131072`, which was either too low or too high. It was not intuitive to control and caused stability issues. An "Adaptive work size" module has been developed to solve this problem, which allows a new way to configure devices along with new features. To enable an "Adaptive work size" set `WorkSize = 0`(used by default since v0.7.0), which allows to configure two other options `BatchTimeMs` and `OccupancyPct`. VerthashMiner works on job in batches and `WorkSize` parameter allows to specify a batch size(must be a power of 256). Low values increase CPU and PCIe transfer(GPU to CPU) overhead, which lowers hashrate, but also saves GPU memory, makes other applications and user interface more responsive. Higher values on the other hand, are the opposite(too high values may reduce performance too). But which value is the optimal? It depends on the device capabilities and how long it takes to process a batch(small part of the job). We can profile and try to predict a batch time as soon as the miner is the only software running on the GPU. However things become complicated when we start running other GPU heavy applications e.g games, render/simulate some stuff. Batch time may increase by 2x times, 10x times or more, which may trigger `timeout` errors and other issues. Some of them can be mitigated by OS and GPU driver settings. This is where the `BatchTimeMs` parameter comes in. It allows to specify a "prefered" amount of time(in milliseconds), that the device should spend on processing a single batch. VerthashMiner will dynamically select an optimal `WorkSize` for every batch and manage all GPU memory allocations/reallocations. If there are not enough GPU memory, then the miner will automatically adapt and try to get as closer as possible to the target value. Minimal Verthash requirements(2GB memory) still apply here. Here are some recommendations for `BatchTimeMs` values: - For the "performance mode" set value above `100` (e.g in range [100-1000], increase until there is a performance improvement). - To make other applications and user interface more responsive: choose values below `100`. In some cases, low `BatchTimeMs` value will not be enough and desktop can still be quiet unresponsive.(for example when using NVIDIA proprietary driver with X Window system on Linux). Second parameter `OccupancyPct` exists for this reason. It allows to specify a GPU usage in [1%-100%] range. By default Miner is configured to use/occupy 100% of the device resources and will "fight" for them with other GPU applications. Combining `BatchTimeMs` and `OccupancyPct` one can achieve a good balance between performance and GUI responsiveness. Additional notes: - `BatchTimeMs` and `OccupancyPct` parameters work only when "Adaptive batch size" is enabled(`WorkSize = 0`). If `WorkSize` is specified manually, they will be ignored by the miner. - Both `BatchTimeMs` and `OccupancyPct` can also be configured using a manual device selection in the command line.(`b` and `o` prefixes) For example: `--cl-devices 0:b50:o75` selects device with index 0, sets `BatchTimeMs` to `50` and `OccupancyPct` to `75%`. ### Device monitoring and GPU temperature limit Since(v0.7.0) Miner allows to monitor device temperature, power usage, fan speed and specify GPU temperature limit to prevent overheat. Device monitoring can be enabled with `DeviceMonitor = "1"` and disabled using `DeviceMonitor = "0"`. GPU temperature limit can be set using the `GPUTemperatureLimit` option. For example to set the GPU temperature limit to `79` degrees C use: `GPUTemperatureLimit = "79"` If the limit is reached, the miner will suspend the work of a particular worker and resume after the GPU has cooled down. `GPUTemperatureLimit = "0"` will disable this parameter and leave the GPU temperature limit to the driver. Additional notes: - Device monitoring features may vary between OS, devices and drivers. - `GPUTemperatureLimit` parameter works only when device monitoring is enabled(`DeviceMonitor = "1"`). - Both `DeviceMonitor` and `GPUTemperatureLimit` can also be configured using a manual device selection in the command line.(`m` and `t` prefixes) For example: `--cl-devices 0:m1:t79` selects device with index 0, enables device monitoring and sets `GPUTemperatureLimit` to `79` degrees C. ### Pool connection setup: - **Connection password** - If the pool doesn't require this parameter, leave it as `x` ### Comments inside a config file - Comments can be in C format, e.g. `/* some stuff */`, with a `//` at the start of the line, or in shell format (`#`). ## Building VerthashMiner Make sure that OpenCL drivers are installed. See [Supported platforms](#supported-platforms). lyclMiner uses [CMake](https://cmake.org/) to build platform specific projects. ### Dependencies: 1. OpenCL 2. Jansson(https://github.com/akheron/jansson) 3. CURL(https://curl.haxx.se/libcurl/) 4. OpenSSL(optional on Windows) 5. CUDA(optional) Otherwise OpenCL will be used. Both versions are optimized and performance will be the same. With CUDA you can avoid 100% CPU usage during mining using NVIDIA GPUs. ### Compiling from the source code 1. Make sure that all dependencies are installed 2. Install the latest version of [CMake](https://cmake.org/). 3.18 or above is required. https://cmake.org/ 3. Open CMake and in `Where is the source code` select miner root directory with `CMakeLists.txt` 4. Choose the path "Where to build the binaries" for cache. 5. Press `Configure` and select `Generator`. Note, that CUDA is not supported when using MinGW compiler on Windows platform. Recommended generators: `Visual Studio`(select installed version) on Windows and `Unix Makefiles` on Linux. 6. Make sure that `Optional platform for generator` is `x64` and press `Finish` 7. Build system will configure everything automatically and use precompiled dependencies on Windows if possible. You can always specify your own. 8. Modify `CMAKE_INSTALL_PREFIX` option and set the miner install path. 9. Some build systems have `CMAKE_BUILD_TYPE` option set to empty. Make sure it is set to `Release` for the final use. 10. Use `Generate` and navigate to `Where to build the binaries` directory. 11. Compile miner(depends on the selected compiler and generator) - Navigate to `Where to build the binaries` directory - On Linux and Windows MinGW * Open Terminal/Windows PowerShell in this directory. * Linux: `make`, Windows MinGW: `mingw32-make` * Wait for the compilation to finish * Linux: `make install`, Windows MinGW: `mingw32-make install` - On Windows(Microsoft Visual Studio) * Open `VerthashMiner.sln` using Microsoft Visual Studio * Right click on the `ALL_BUILD` solution inside the Solution Explorer window and select `Build` * Wait for the compilation to finish * Right click on the `INSTALL` solution inside the Solution Explorer window and select `Build` 12. Miner binaries will be stored inside the `CMAKE_INSTALL_PREFIX` directory. ## Additional Notes - `LONGPOLL pushed new work` spam may happen during GMT solo mining if network was stale for a long time. (e.g. testnet) In this case miner should be run with either `--no-longpoll` or `LongPoll` option set to `false` inside the configuration file. - To enable file logger use `--log-file` command option. - All miner "devices" are virtual. By default miner assigns 1 virtual GPU per physical one. Thus 1 thread per GPU. It is possible to emulate any devices you want by putting duplicates in the list. You can even use multiple CUDA and OpenCL devices at the same time while having only 1 physical NVIDIA GPU. There are 3 ways to do it: 1. Using Command Line. Instead of `--all-cl-devices` and/or `--all-cu-devices` use: `--cl-devices ...`(-d) and `--cu-devices ...(-D)` respectively. To get all physical devices available to the miner use: `-l` or `--device-list` To create 2 virtual devices for one physical device, specify the same device twice. `--cl-devices 0:w131072,0:w131072` 131072 is a work size. You can try specify your own(e.g 32768, 65536, 262144, 524288 etc) and check performance/power consumption. 2. Using a Configuration File. For example: There will be only 1 `` block with 1 physical GPU. Duplicate it and rename a new one to ``. * When using 2 or more devices for a single physical GPU, their hash-rate will probably be the same. You can try to specify a different `WorkSize` for each of them and compare multiple `WorkSize` values at the same time. Not sure about accuracy though. It may vary between different GPUs, drivers, OS and other apps running in the background.