can't build CUDA project in visual studio 2008
I'm a first year student Computer Science major at the University of Belgrade.My Soft Computing project is to compare a performance of CUDA implementations of different population based algorithms, such as Genetic algorithms, Ant Colony Optimization, Bee Colony, Firefly and PSO. It is not expected from me to write all these codes, since I am a first year student.My assignment is just to try to find codes, run them and measure the performance difference between CPU and GPU implementations.
A few good people sent me a CUDA implementation of Genetic Algorithm that was developed under Linux. Since I am not very familiar with Linux, I am having trouble to build and run CUDA project in visual studio on windows.
Make file is included in project but I think that it is not complete. Make file includes another make file which I do not have. I tried to run it under win 7, but it was unsuccessful, so I installed win xp, visual studio 2008, CUDA SDK 2.3 and matching drivers. Whatever I try, I am always having same problems.
First, I got u_int32_t is undefined
(u_int32_t
is custom defined type), so I replace it with __int32
, and that solves the problem.
After that I get the following errors: rint is not defined
and log2 is not defined
. I don't know why I get these errors since math_functions.h
is included indirectly in project via common_functions.h
. Then I put two lines with these function under comments, and give some fixed values to that variables.
And afte开发者_如何学运维r that I get linker errors. For example:
Error 3 error LNK2019: unresolved external symbol _h_fit referenced in function "public: __thiscallGa::Ga(int *,char * *)
Is there anything that I can do? In addition, I would be very thankful if anyone is willing to send me CUDA implementation of Genetic Algorithm that works. My e-mail address is in my profile.
EDIT:
I set include pats to all h files, link pats to lib files. I also set CUDA build rule. I can build and run other CUDA projects just fine.
Install NSight 1.51. This will get the build rules etc all set up for you.
May sure that the Include Directories property in the projects Configuration Properties | VC++ Directories tab include a path to the SDK's includes. Something like:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include
Make sure that the Linker | Input tab has cudart.lib as one of the Additional Dependencies
The linker error looks like it can't find methods like Ga(int *,char * *) which I'm assuming is part of your GA algorithm. Are you trying to link a CUDA project to another VS project to use the CUDA GA library? If so you need to make sure that the class that exploses the GA library to other code is marked as
class __declspec(dllexport) {classname}
So that the DLL exports the class and the other VS project needs to include a dependency to the CUDA project. Without seeing how your solution is configured it's hard to say more.
Here are two tutorials on getting started with CUDA and Visual C++ 2010, most of this applies to VS 2008:
http://blog.cuvilib.com/2011/02/24/how-to-run-cuda-in-visual-studio-2010/
http://www.ademiller.com/blogs/tech/2011/03/using-cuda-and-thrust-with-visual-studio-2010/
There's also a post on the NVIDIA forum:
http://forums.nvidia.com/index.php?showtopic=184539
Make sure you have set include path to h files, link path to lib files, build event to copy dlls. (All to correct paths in Toolkit and SDK.)
And also use CUDA's rule file to set up build tool for cu files.
精彩评论