VS just doesn't work with CUDA on my computer!

I don’t have CUDA-enabled card. Previously I had VS2010 and after I installed Windows SDK 7, CUDA Toolkit 3.2 and Nsight 1.5 (couldn’t install any driver because there’s no supported hardware), I tried to build the CUDA matrixMul sample that comes with the Nsight. No matter whether I enabled the Emulation Mode or not the end result was always a -1 return value from nvcc.

I searched a bit on the net and figured it could be the lack of VS2008. So I uninstalled 2010 and installed 2008.
Now I try to build the matrixMul, it gives this:

fatal error LNK1181: cannot open input file ‘.\obj\Win32_Debug_vc90\matrixMul.cu.obj’

CUDA SDK and Nsight are installed in their default paths. Though VS2008 is installed in custom path.

Any idea how to fix that? Could is it that without a CUDA-enabled card there’s nothing I could do?

I don’t have CUDA-enabled card. Previously I had VS2010 and after I installed Windows SDK 7, CUDA Toolkit 3.2 and Nsight 1.5 (couldn’t install any driver because there’s no supported hardware), I tried to build the CUDA matrixMul sample that comes with the Nsight. No matter whether I enabled the Emulation Mode or not the end result was always a -1 return value from nvcc.

I searched a bit on the net and figured it could be the lack of VS2008. So I uninstalled 2010 and installed 2008.
Now I try to build the matrixMul, it gives this:

fatal error LNK1181: cannot open input file ‘.\obj\Win32_Debug_vc90\matrixMul.cu.obj’

CUDA SDK and Nsight are installed in their default paths. Though VS2008 is installed in custom path.

Any idea how to fix that? Could is it that without a CUDA-enabled card there’s nothing I could do?

As far as I know, CUDA isn’t supported by VS2010 yet, so you’re right to use VS2008. I’m not sure about the emulators and how they’ll affect this, although you’ may need to go into the project properties and add linker dependencies for CUDA libraries. You’ll also want to check VC++ Directories and do the same. Also, the fact that the input file is named ‘matrixMul.cu.obj’ doesn’t seem right - it seems as though it is mistaking your .cu file for an .obj file or something.

As far as I know, CUDA isn’t supported by VS2010 yet, so you’re right to use VS2008. I’m not sure about the emulators and how they’ll affect this, although you’ may need to go into the project properties and add linker dependencies for CUDA libraries. You’ll also want to check VC++ Directories and do the same. Also, the fact that the input file is named ‘matrixMul.cu.obj’ doesn’t seem right - it seems as though it is mistaking your .cu file for an .obj file or something.

Device Emulation is deprecated for CUDA 3.0, and has been removed with CUDA 3.1.

You can revert to a previous version of the CUDA toolkit in order to work with emulation.

eldad.

Device Emulation is deprecated for CUDA 3.0, and has been removed with CUDA 3.1.

You can revert to a previous version of the CUDA toolkit in order to work with emulation.

eldad.

Hi!
i am new to cuda on windows. so hope u can help me start up.
i have

  1. cuda toolkit 3.2,
  2. VS 2008
  3. sdk 3.2
    installed on my laptop with a CUDA card.
    the codes from the “browser” of sdk run perfectly, indicating that the drivers are installed well.
    however, integrating it with my VS 2008 is a problem. it says that ‘C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\NvCudaRuntimeApi.rules’ was not found or failed to load.

i think i need to use cuda.rules for this but they are not available in the folder “common” as mentioned in some forums. please help.
thanks.

the “cuda.rules” file should be under your SDK installation (try: “%NVSDKCOMPUTE_ROOT%\C\common”).

if it’s not there - try reinstalling the SDK.

in any case - I’m attaching my rules file so you can use it…(rename it back to cuda.rules)

good luck,

eldad.
cuda.rules.txt (14 KB)

I had exactly the same problem (using XP, installed int’F’ partition).I am a newbie( --> don’t know what I’m doing) but found the .rules files had been copied into wrong location so sopied them over and was able to compile the examples.

As a newbie - I still have to find out how to write code that can communicate with a main program written invS2008 and o/p the results of calculation to a form.

Thanks everyone for CUDA - it appears easy from the forums and documentaiton (not actually written anything yet!)

Sounds like you are wanting to pass results back to an app using .NET

If so then I have used CUDA.NET http://www.hoopoe-cloud.com/Solutions/CUDA.NET/Default.aspxCUDA.NET is available for free.”

Its provides an interface callable from .NET applications to the cuda libraries

the interface calls are similar in format to those of the low-level API (CUDA “driver” API)

NB I think most SDK examples use the high level API but you might find some for the driver API

NB The CUDA Programming Guide contains partial examples of code for both low and high level API.

Another alternative is to write C or C++ code that uses the CUDA high level API and call the C/C++ code from C#/whatever and pass data back.

NB C# has automatic garbage collection which may cause problems if your C/C++ code tries to store any data between calls, providing you dont try to store data between calls the garbage collection shouldn’t matter.

regards,

kbam

PS here is an example of C# code using CUDA.NET. May/maynot work been I while since I tried it

// Low level API

            const int size_x = 256;

            const int size_y = 4096;

            const int mem_size = sizeof(float) * size_x * size_y;

float[] h_idata = new float;

// set up some test data

            for (int i = 0; i < h_idata.Length; i++)

            {

                h_idata[i] = (float)i;

            }

// Init and select 1st device.

            CUDA cuda = new CUDA(0, true);

// load module

            cuda.LoadModule(Path.Combine(Environment.CurrentDirectory, "transpose_kernel.cubin"));

            CUfunction transpose_naive = cuda.GetModuleFunction("transpose_naive");

// allocate device memory

            // copy host memory to device

            CUdeviceptr d_idata = cuda.CopyHostToDevice<float>(h_idata);

            CUdeviceptr d_odata = cuda.Allocate<float>(h_idata);

// setup execution parameters

            cuda.SetFunctionBlockShape(transpose_naive, BLOCK_DIM, BLOCK_DIM, 1);

            cuda.SetParameter(transpose_naive, 0, (uint)d_odata.Pointer);

            cuda.SetParameter(transpose_naive, IntPtr.Size, (uint)d_idata.Pointer);

            cuda.SetParameter(transpose_naive, IntPtr.Size * 2, (uint)size_x);

            cuda.SetParameter(transpose_naive, IntPtr.Size * 2 + 4, (uint)size_y);

            cuda.SetParameterSize(transpose_naive, (uint)(IntPtr.Size * 2 + 8));

cuda.Launch(transpose_naive, size_x / BLOCK_DIM, size_y / BLOCK_DIM);

Note that in each call to cuda.SetParameter the 2nd parameter increases by the size of the 3rd parameter of SetParameter on the line above.

Once you get your head round whats happening it should be easy, but make sure all your SetParameter calls and SetParameterSize call are right.

The parameters in the kernel this is being passed to look like this

extern "C" __global__ void transpose_naive(float *odata, float* idata, int width, int height)

{

  ...

}

Just for comparison, with the high level API all of the SetParameter calls happen automatically, reducing ~10 lines of code down to this.

transpose_naive<<<grid, threads>>>(d_odata, d_idata, size_x, size_y, size_z);

Thank you KBam,

First, sorry to be slow in replying - I didn’t get an email that you had posted (my fault - as usual - have changed the settings).

I will study the code you posted but first - you mentioned file with a .cubin extension in line

        cuda.LoadModule(Path.Combine(Environment.CurrentDirectory, "transpose_kernel.cubin"));

may I ask: How can you compile such a file - when I use the provided SDK examples in visualStudio (compile /run with F7 /F5) I never get a .cubin extension. I suppose it used nvcc - need to find out.

Thanks for the CUDA.NET - new to me.

What I am trying to do is get a few matrix operations (multiplication, convolution and FFT) to be available on DELPHI using an app with a form. Searching this forum with keyword ‘delphi’ revealed 2 pieces of code. The first was an FFT which used a .DLL with name something like cufft.dll. The second was a program based on the simpleTexture (drv?) SDK - I hope to imitate this but need to know how to derive file of type .cubin . Any advice/suggestions are most welcome - (bearing in mind I’m a bit new to this).

Thanks and best wishes

angus

Hi all,

I had just the very same issue: VC++ complaining for NvCudaRuntimeApi.rules not found under C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults

I copied your cuda.rules, renamed it into NvCudaRuntimeApi.rules under that VS folder, and magically the project opened.

How can it be that you have to tweak things this way to just open a project… that sounds just about awkward to me… anyways at least so far it worked :)

Thank for the vital info :)