MMX on GPUs

enabling opencl acceleration

Posted on February 9, 2022

On my Machinaris cryptocurrency platform, I added initial support for the MMX blockchain within a week of the blockchain’s test release last year. However, that initial support ran exclusively on CPU resources. MMX will run much better if provided a GPU for performing certain blockchain validations.

To that end, support for GPU pass-through into the Machinaris Docker container was added in our version 0.6.9 release. Due to an ancient GPU in my Unraid tower, I was very grateful to Machinaris users for testing with their newer hardware.

MMX VDF Validation

Similar to Solana, the MMX blockchain uses a SHA-256 verifiable delay function (VDF). These VDFs are a proof-of-history for the blockchain which can be computed very quickly on GPUs, allowing faster transactions per second than older blockchains such as Bitcoin.

In particular, MMX employs the OpenCL library for verifying the Verifiable Delay Function (VDF) that is associated with each block.

GPU Support

Keeping in mind that Machinaris runs within a Docker container, one challenge of enabling GPU support is handling the pass-through from the host OS into Docker. While docker-compose supports a runtime directive, full support is somewhat more complicated.

Nvidia

For those with an Nvidia GPU, you’ll need the Nvidia Driver Runtime. If running Unraid, just install the Nvidia Driver plugin for this.

Then add the following to your docker-compose.yml. Extend the existing environment section

    environment:
        - OPENCL_GPU=nvidia
        - NVIDIA_VISIBLE_DEVICES=0
        - NVIDIA_DRIVER_CAPABILITIES=compute,utility

Then add a new runtime line, (at same level as environment):

    runtime: nvidia

OR for Unraid, using the Docker admin tab, edit the Machinaris-MMX config, create 3 new Variables (shown) and add --runtime=nvidia to the “Extra Parameters” field.

Ideally you can target the device by position or GUID, which you can later override in Unraid Docker Configuration or compose ENVs,

-e NVIDIA_VISIBLE_DEVICES=0 or -e NVIDIA_VISIBLE_DEVICES=GPU-a8b96998-xxxx-xxxx

Further explained here.

Big thanks @tjb_altf who verified this approach with his GPU.

AMD

For AMD GPUs, as per this tutorial (AMD section part-way down), add the following to your docker-compose.yml. Extend the existing environment section

    environment:
        - OPENCL_GPU=amd

and add the following devices section at the same level as environment:

    devices:
        - "/dev/kfd:/dev/kfd"
        - "/dev/dri/:/dev/dri/"

Big thanks @yamen who verified this approach with his GPU.

Conclusion

While MMX is still months away from their mainnet launch, I’ll probably just start up my Machinaris-MMX container every few weeks to verify continued support for the integration. Once mainnet is near, I may invest in a cheap GPU, if ever available, to take the load of my old CPU if running MMX 24/7.

More in this series…