简体   繁体   中英

c# Mono Cudafy under DietPi failed to run

I have DietPi on my Odroid XU4, I have there mono-runtime installed. I made a simple program in c#:

using System;
using Cudafy;
using Cudafy.Host;
using Cudafy.Translator;

namespace cudafy_test
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                CudafyModes.Target = eGPUType.OpenCL;
                CudafyTranslator.Language = eLanguage.OpenCL;
                CudafyModule km = CudafyTranslator.Cudafy();

                string txt;
                try
                {
                    txt = CudafyHost.GetDeviceCount(eGPUType.Cuda).ToString();
                }
                catch
                {
                    txt = "0";
                }
                Console.WriteLine("Cuda devices: " + txt);
                try
                {
                    txt = CudafyHost.GetDeviceCount(eGPUType.OpenCL).ToString();
                }
                catch
                {
                    txt = "0";
                }
                Console.WriteLine("OpenCl devices: " + txt);
                try
                {
                    txt = CudafyHost.GetDeviceCount(eGPUType.Emulator).ToString();
                }
                catch
                {
                    txt = "0";
                }
                Console.WriteLine("Emulations CPU devices: " + txt);

                GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId);
                gpu.LoadModule(km);
                gpu.Launch().thekernel();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("Hello world");
            Console.ReadKey();
        }

        [Cudafy]
        public static void thekernel()
        {
        }
    }
}

and I compile it complete as x86. Even I checked the dll target via:

using System;
using System.Reflection;
using System.IO;

namespace project
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryInfo di = new DirectoryInfo(@"dir");
            var files = di.EnumerateFiles("*.dll", SearchOption.TopDirectoryOnly);

            foreach (var d in files)
            {
                var ass = AssemblyName.GetAssemblyName(d.FullName);
                Console.WriteLine(d.Name);
                Console.WriteLine(ass.ProcessorArchitecture.ToString());
                Console.WriteLine(".................");
            }

            Console.WriteLine("Done");
            Console.ReadKey();
        }
    }
}

and it produced result, that all the dll.

在此处输入图像描述

But when I run in bash the:

mono cudafy_test.exe

it is reporting me the following error:

Unhandled Exception: System.BadImageFormatException: Could not resolve field token 0x04000001 File name: 'cudafy_test'

Do you have anyone enough experience with that? Please give me a piece of advice on how to fix this.

I should not be the mono-runtime (small mono installation, but it should be the larger installation mono-devel or mono-complete). I have to look at, how they differ.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM