# Dual Mine

## Dual ethash mining and transcoding​

### Choosing a miner​

Dual ethash mining and transcoding has been tested on the GPUs in this list and with the following miners:

If you successfully test with other miners, contributions to this document are welcome.

If you are using a post-Volta GPU, the recommendation is to use ethminer because it exposes flags for more granular adjustments to the GPU workload which will be needed when using CUDA MPS (see the next section) to prevent the miner from fully staturating the GPU. Other miners that support similar flags can be substituted for ethminer as well.

If you are using a pre-Volta GPU, the recommendation is to use t-rex because it is, at the time of writing, the most popular and efficient ethash miner that has been tested with livepeer. Other miners that have been tested successfully with livepeer can be substituted for t-rex as well.

Note that regardless of the miner used, the VRAM available on your GPU will affect the number of concurrent streams that can be transcoded while mining.

### Run a ethminer + livepeer script​

If you are using ethminer, this script can be used to start both processes.

If you want to setup a dual mining manually perhaps because the script does not serve your needs, continue to the next sections.

### Run CUDA MPS​

CUDA MPS can be used to try to improve parallelization of the ethash mining and transcoding workloads on the GPU. If you are not using CUDA MPS you can move on to the next section.

Requirements:

Start the MPS server by following these instructions

Take note of the following points that are mentioned in the docs:

• The CUDA_VISIBLE_DEVICES environment variable should be set with device IDs of the GPUS you will be using before the MPS daemon is started, but it should NOT be set before starting the miner and livepeer
• If you are using a mix of pre-Volta and post-Volta GPUs, make sure to read this section to avoid device ID issues

### Run the miner​

The following instructions will assume you are using either t-rex or ethminer. If you are using a different miner, the miner commands should be updated to reflect the requirements of the miner being used.

If you are using ethminer, run ethminer with flags to adjust the GPU workload (other flags to connect to a mining pool omitted):

ethminer \  -U \  --cu-devices <GPU_DEVICE_IDS> \ # List of Nvidia GPU IDs  --cuda-streams <CUDA_STREAMS> \ # Number of multiprocessor streams  --cuda-block-size <CUDA_BLOCK_SIZE> \ # Number of threads per block  --cuda-grid-size <CUDA_GRID_SIZE> \ # Number of blocks per grid

The --cuda-streams, --cuda-block-size and --cuda-grid-size flags are used to adjust the GPU workload. The best values to use for these flags will depend on your GPU and whether you want lower hashrate and faster transcoding speed or higher hashrate and lower transcoding speed.

If you are using t-rex, run t-rex with a flag to adjust mining intensity (other flags to connect to a mining pool omitted):

t-rex \  -a ethash \  -d <GPU_DEVICE_IDS> \ # List of Nvidia GPU IDs  -i <MINING_INTENSITY \ # The mining intensity

The -i flag is used to adjust the mining intensity. Note that in testing, this flag did not seem to provide very granual control over the GPU workload so adjusting it to a level at which CUDA MPS could work led to a larger hashrate drop which is why ethminer is recommended if you plan on using CUDA MPS.

### Run livepeer​

1. If you are using CUDA MPS, wait until the miner completes DAG generation

2. Run livepeer on the same machine as the miner and using the same GPU device IDs as the miner with the -nvidia flag

3. If you are using CUDA MPS, livepeer will need to be stopped when the miner re-generates the DAG to avoid transcoding issues and can be re-started when DAG generation completes

### Switching​

Instead of always concurrently ethash mining and transcoding, it could also be possible to switch between the two to maximize mining efficiency when there is low transcoding demand and maximize transcoding capacity when there is high transcoding demand.