First CUDA tutorial - CUDA toolkit 6.0 + Visual studio 2012 setting and example simple source


You have already installed Visual studio 2012 or other version.
And, you have to install CUDA toolkit, go to the nvidia homepage -> https://developer.nvidia.com/cuda-downloads
Now cuda 6.5 is available.

Don't worry, In this introduction, version is not important.


After install cuda toolkit and Visual studio.
There is two option to start simple cuda project.

One is little bit complex.
Make win32 console project (empty optioni)
set cuda include and lib directory.
set build option
add cuda file
and coding...

See the this video.
https://www.youtube.com/watch?v=i43dUW4E-fE&feature=youtu.be



Another method is using cuda runtime project.
This is very easy.
See the this video.
https://www.youtube.com/watch?v=j2wV4-IiGh4&feature=youtu.be


This is example source code

#include < iostream>
#include "cuda.h"  
#include "cuda_runtime.h"  
#include "device_launch_parameters.h"  

__global__ void add(int a, int b, int*c)
{
 *c = a+b;
}

int main()
{

 int c;
 int *dev_c;
 cudaMalloc( (void**)&dev_c, sizeof(int) );

 add<<< 1,1>>>(2,7, dev_c);

 cudaMemcpy(&c, dev_c, sizeof(int), cudaMemcpyDeviceToHost);

 printf(" 2+7 = %d \n", c);

 cudaFree(dev_c); 

 return 0;

}

As I am cuda beginner, I don't know which method is good.
But I think first method is more useful for adding cuda code into existing project.

And refer to this youtube channel.
https://www.youtube.com/channel/UCBHcMCGaiJhv-ESTcWGJPcw

cudacast playlist will be efficient.

Thank you.

Comments

Popular posts from this blog

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

OpenCV Stitching example (Stitcher class, Panorama)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Real-time N camera stitching Class.

Optical Flow sample source code using OpenCV

OpenCV Drawing Example, (line, circle, rectangle, ellipse, polyline, fillConvexPoly, putText, drawContours)

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)

SICK LMS511 sensor data acquisition interface (source code, C++/MFC)

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Image warping (using opencv findHomography, warpPerspective)