Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:39:35+00:00 2026-06-07T15:39:35+00:00

I’ve been looking for some information on coding CUDA (the nvidia gpu language) with

  • 0

I’ve been looking for some information on coding CUDA (the nvidia gpu language) with C#. I have seen a few of the libraries, but it seems that they would add a bit of overhead (because of the p/invokes, etc).

  • How should I go about using CUDA in my C# applications? Would it be better to code it in say C++ and compile that into a dll?
  • Would this overhead of using a wrapper kill any advantages I would get from using CUDA?
  • And are there any good examples of using CUDA with C#?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:39:37+00:00Added an answer on June 7, 2026 at 3:39 pm

    There is such a nice complete cuda 4.2 wrapper as ManagedCuda.
    You simply add C++ cuda project to your solution, which contains yours c# project, then you just add

    call "%VS100COMNTOOLS%vsvars32.bat"
    for /f %%a IN ('dir /b "$(ProjectDir)Kernels\*.cu"') do nvcc -ptx -arch sm_21 -m 64 -o "$(ProjectDir)bin\Debug\%%~na_64.ptx" "$(ProjectDir)Kernels\%%~na.cu"
    for /f %%a IN ('dir /b "$(ProjectDir)Kernels\*.cu"') do nvcc -ptx -arch sm_21 -m 32 -o "$(ProjectDir)bin\Debug\%%~na.ptx" "$(ProjectDir)Kernels\%%~na.cu"
    

    to post-build events in your c# project properties, this compiles *.ptx file and copies it in your c# project output directory.

    Then you need simply create new context, load module from file, load function and work with device.

    //NewContext creation
    CudaContext cntxt = new  CudaContext();
    
    //Module loading from precompiled .ptx in a project output folder
    CUmodule cumodule = cntxt.LoadModule("kernel.ptx");
    
    //_Z9addKernelPf - function name, can be found in *.ptx file
    CudaKernel addWithCuda = new CudaKernel("_Z9addKernelPf", cumodule, cntxt);
    
    //Create device array for data
    CudaDeviceVariable<cData2> vec1_device = new CudaDeviceVariable<cData2>(num);            
    
    //Create arrays with data
    cData2[] vec1 = new cData2[num];
    
    //Copy data to device
    vec1_device.CopyToDevice(vec1);
    
    //Set grid and block dimensions                       
    addWithCuda.GridDimensions = new dim3(8, 1, 1);
    addWithCuda.BlockDimensions = new dim3(512, 1, 1);
    
    //Run the kernel
    addWithCuda.Run(
        vec1_device.DevicePointer, 
        vec2_device.DevicePointer, 
        vec3_device.DevicePointer);
    
    //Copy data from device
    vec1_device.CopyToHost(vec1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.