The clusters I have access to have a mix of AMD and NVIDIA GPUs. How can I develop code which is easy to run with any accelerator?
One option is to use ILGPU. This is a project built on top of C# which makes it easy to target code to both AMD and NVIDIA GPUs.
Start by installing dotnet (C# shares some of the same tools with F# and other Microsoft languages).
If you are on a cluster you will want to install via bash script which does not require admin privileges.
Otherwise you can install via:
After install, you should be able to run dotnet --info
from your command line.
ILGPU has some documentation for more details but let’s run a simple program here to get started.
Start by running git clone https://github.com/m4rs-mt/ILGPU
to get the ILGPU source code.
Now, cd ILGPU/Samples/DeviceInfo
.
Now edit the DeviceInfo.csproj
file so that
The line beginning: <TargetFrameworks>
reads:
<TargetFrameworks>net5.0</TargetFrameworks>
To build this project start by restoring it:
dotnet restore
Then build it & run it
dotnet build -c Release
dotnet run -c Release --framework net5.0
You have now run your first sample of ILGPU + C#. Try running some of the other samples on computes with AMD or NVIDIA GPUs.