fireice-uk / xmr-stak

Free Monero RandomX Miner and unified CryptoNight miner
GNU General Public License v3.0
4.05k stars 1.79k forks source link

Run multiple instances on NVidia GPU #1691

Open ivenetis opened 6 years ago

ivenetis commented 6 years ago

During the first run the miner created the file nvidia.txt with the following information:

"gpu_threads_conf" : [ { "index" : 0, "threads" : 22, "blocks" : 45, "bfactor" : 0, "bsleep" : 0, "affine_to_cpu" : false, "sync_mode" : 3, }, ],

Using this configuration underutilizes the GPU. Therefore I tried to run multiple instances of the miner on the GPU. I tried two approaches:

1) Replicating the above information 3 times: "gpu_threads_conf" : [ { "index" : 0, "threads" : 22, "blocks" : 45, "bfactor" : 0, "bsleep" : 0, "affine_to_cpu" : false, "sync_mode" : 3, }, { "index" : 0, "threads" : 22, "blocks" : 45, "bfactor" : 0, "bsleep" : 0, "affine_to_cpu" : false, "sync_mode" : 3, }, { "index" : 0, "threads" : 22, "blocks" : 45, "bfactor" : 0, "bsleep" : 0, "affine_to_cpu" : false, "sync_mode" : 3, }, ],

2) Using the MPS (Multi-Process Service) from NVidia, that allows multiple applications to share the GPU, and running 3 instances of the miner with the initial configuration.

In both cases the miner(s) seems to be running, but no results are sent back to the pool (no "Result accepted by the pool." messages appear on any running instance) and the hashrate is at 0.

Is there any way to correctly configure the miner to run multiple instances on the GPU and fully utilize it? I also tried to change the number of threads/blocks, but I quickly run out of memory and the GPU remains underutilized.

psychocrypt commented 6 years ago

If you use MPS you muste increase the 'index' for each virtual gpu. For cuda MPS looks like 3 gpus in your case. Also need to reduce the threads for each virtual gpu to have accumulated the same number of threads. e.g. thraeds = 22 and blocks = 15 for each virtual gpu.

ivenetis commented 6 years ago

Thanks for the suggestion. I tried it, but it doesn't seem to work. I enable MPS and I have created two separate directories, each containing the xmr-stak executable and the corresponding configuration files. The first instance starts correctly, but the second instance (with the 'index' set to 1 in the corresponding nvidia.txt file) gives the error:

[2018-07-03 22:05:05] : Starting NVIDIA GPU thread 0, no affinity. Invalid device ID! [2018-07-03 22:05:05] : Setup failed for GPU 0. Exiting.

psychocrypt commented 6 years ago

You need only one xmr-stak instance with a config for 3 gpus. Or 3 instances where each nvidia.txt has one entry and the index in increased per i stance (if I remember correct)