This may seem as an easy question, but i am new to CUDA, I have downloaded all the drivers, the CUDA TOOLKIT 3.1 and the SDK and I would like to use Microsoft Visual Studio c++ 2008 express edition to wright my programms.
How can i do?
Have you installed the drivers, microsoft visual c++ express edition, cuda toolkit, dan cuda sdk?
If so you can check if it’s working or not. Find and run bandwidthTest .exe located in C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win32\Release. (I use win7 32bit)
To build cuda program in Visual C++, copy this Cuda.rules file located in C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\common to VC\VCProjectDefaults in your Microsoft Visual Studio instalation folder.
Create New Project:
Open Visual C++
File > New > Project. Coose an empty project
If the project has been created, right click on the project name in the solution explorer, choose Custom Build Rules
If there’s CUDA Build Rule on the available rule, check it. If there isn’t just find existing rule, and browse CUDA bulid rule in VC\VCProjectDefaults.
Add CUDA runtime library. right click on project, choose Properties -> Linker -> General, add $(CUDA_LIB_PATH) to Additional Library Directories. And then Linker -> Input add cudart.lib to Additional Dependencies.
After that, try this one
** Hello World using CUDA
** The string "Hello World!" is mangled then restored using a common CUDA idiom
** Byron Galbraith
__global__ void helloWorld(char*);
// Host function
main(int argc, char** argv)
// desired output
char str = "Hello World Bapuk!";
// mangle contents of output
// the null character is left intact for simplicity
for(i = 0; i < 12; i++)
str[i] -= i;
// allocate memory on the device
size_t size = sizeof(str);
// copy the string to the device
cudaMemcpy(d_str, str, size, cudaMemcpyHostToDevice);
// set the grid and block sizes
dim3 dimGrid(2); // one block per word
dim3 dimBlock(6); // one thread per character
// invoke the kernel
helloWorld<<< dimGrid, dimBlock >>>(d_str);
// retrieve the results from the device
cudaMemcpy(str, d_str, size, cudaMemcpyDeviceToHost);
// free up the allocated memory on the device
// everyone's favorite part
// Device kernel
// determine where in the thread grid we are
int idx = blockIdx.x * blockDim.x + threadIdx.x;
// unmangle output
str[idx] += idx;
im new to cuda , too , and find this post very usefull , but its not worikng for me .
i`m using ms visual studio 2008 , installed the newest gpu driver (i ve got a nvidia gt 320 m) , downloaded and installed the latest versions of the cuda toolkit and sdk , ran the bandwidth test and also built and ran the bandwidth project , and they worked ok.
i followed the steps described here in the post , created a new empty C++ project , added the cuda rules , linked the libraries as you said ($(CUDA_LIB_PATH) & cudart.lib)
after that added a cpp file to the Source Files in the project , copy/paste the code you posted , but i get this error while building the project :
Error 1 fatal error C1083: Cannot open include file: ‘cuda.h’: No such file or directory c:\users\gogira\documents\visual studio 2008\projects\test2\test2\coco.cpp 9 test2
if you could point out for me what i`m missing or doing wrong , please do that .