In this guide, we'll go over how to process video on the Livepeer Network using your GPU while simultanously mining cryptocurrencies such as Filecoin or Bitcoin using the same GPU.
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
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 (opens in a new tab) 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 (opens in a new tab) 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.
- A post-Volta Nvidia GPU. Refer to the GPU NVENC/NVDEC support matrix (opens in a new tab) for the generation that a GPU is from.
Start the MPS server by following these instructions (opens in a new tab)
Take note of the following points that are mentioned in the docs:
CUDA_VISIBLE_DEVICESenvironment 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
- If you are using a mix of pre-Volta and post-Volta GPUs, make sure to read this section (opens in a new tab) 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
--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
-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.
If you are using CUDA MPS, wait until the miner completes DAG generation
livepeeron the same machine as the miner and using the same GPU device IDs as the miner with the
If you are using CUDA MPS,
livepeerwill need to be stopped when the miner re-generates the DAG to avoid transcoding issues and can be re-started when DAG generation completes
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.