CUDA.NET examples issues

The examples attached with the CUDA.NET library demonstrate simple aspects of programming with CUDA.NET to the GPU.
They mostly consist of a code that runs on the GPU itself, written in the CUDA language. These files end with the *.cu suffix.

In order to use these files with the GPU, they have to pass a compilation step, processed by the nvcccompiler (included in CUDA Toolkit) to create a cubin file (binary file the GPU uses).
To operate properly, the nvcc compiler needs access to the cl compiler (Visual C++ equipped with Visual Studio or can be downloaded as standalone).

If nvcc cannot find the cl compiler or the environment is not fully configured it fails.
This can happen when cl is executed from a C# or VB.NET project (where the environment is not configured to C++).
To overcome the errors, it is possible to define to nvcc command line parameters that will allow it to compile the code. This parameter specifies the path to the cl compiler.
For example (considering a Visual Studio 2008 installation), add the following parameter:
–compiler-bindir=”C:Program FilesMicrosoft Visual Studio 9.0VCbin”

On different platforms/installations this path can be different. Older versions of Visual Studio will have a different path as well.
The complete command line to execute nvcc with is:
nvcc –cubin –compiler-bindir=”C:Program FilesMicrosoft Visual Studio 9.0VCbin”
If compiling a CUDA file named “”.

2 Replies to “CUDA.NET examples issues”

  1. In addition to your post it’s worth to mention that when you compile your projects in x64 windows common error occur:

    “c:cudaincludehost_config.h(96) : fatal error C1083: Cannot open include file:
    ‘crtdefs.h’: No such file or directory”

    But when you add this line to your C:cudabin64nvcc.profile file in INCLUDES section

    “-IC:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/include”

    everything goes ok.

    My whole nvcc.profile:

    TOP = $(_HERE_)/..

    PATH += $(TOP)/extools/bin;$(TOP)/open64/bin;$(_HERE_);$(TOP)/lib;

    INCLUDES += “-I$(TOP)/include” “-I$(TOP)/include/cudart” “-IC:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/include” $(_SPACE_)

    LIBRARIES =+ $(_SPACE_) “/LIBPATH:$(TOP)/lib$(_TARGET_SIZE_)” cudart.lib


Comments are closed.