Prefer Your Language

Search This Blog

Compile and Run CUDA C/C++ Programs



Kernels can be written using the CUDA instruction set architecture, called PTX (Parallel thread Execution ). It is however usually more effective to use a high-level programming language such as C. In both cases, kernels must be compiled into binary code by nvcc to execute on the device.




Process 

Command Line Procedure 

Step 1: Save your program with the extension .cu   let say Example.cu

Step 2: Open command prompt (in Windows) or Terminal (in Linux) and locate your program     directory.

Step 3: Type in command prompt (Terminal in Linux)

            
 

C:\Users\Gnits> nvcc Example.cu    // for compiling 

C:\Users\Gnits> a.exe                    // To run your program 




[ Procedure is same in Linux ]

    


Feel free to comment...

19 comments:

  1. It's showing error:
    nvcc fatal : Cannot find compiler 'cl.exe' in PATH

    ReplyDelete
  2. In Linux environment run as ./cl.exe

    ReplyDelete
  3. nvcc fatal : Cannot find compiler 'cl.exe' in PATH

    please any one help to solve this error

    ReplyDelete
    Replies
    1. you must type send command like: ./a.out

      Delete
    2. This comment has been removed by the author.

      Delete
  4. use "./a.out" in linux

    ReplyDelete
  5. by parent directory u mean that it should point to nvcc.exe

    ReplyDelete
  6. nvcc is not there.....says to install using cmd sudo apt-get install nvidia-cuda-toolkit
    but this results in E: Unable to locate package nvidia-cuda-toolkit

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. sudo apt install nvidia-cuda-toolkit
    this is for only LINUX users..

    ReplyDelete
  9. sudo apt install nvidia-cuda-toolkit
    this is for only LINUX users..

    ReplyDelete
  10. My first program. During compilation it displayed fatal error:helper_cuda.h: no such file or directory #include please let me know what is wrong

    ReplyDelete
  11. My first program. During compilation it displayed fatal error:helper_cuda.h: no such file or directory #include please let me know what is wrong

    ReplyDelete
  12. Thanks, This command works for me. But for linux, the second comment is ./a.out .

    ReplyDelete
  13. Thanks, This command works for me. But for linux, the second comment is ./a.out .

    ReplyDelete

  14. Now I found everything in this topic,thank you for sharing this.
    Selenium With C# Online Training
    Selenium with C#

    ReplyDelete

Help us to improve our quality and become contributor to our blog

Become a contributor to this blog. Click on contact us tab
Blogger Template by Clairvo