Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuda support #571

Open
jjcasmar opened this issue Nov 14, 2017 · 8 comments
Open

Cuda support #571

jjcasmar opened this issue Nov 14, 2017 · 8 comments

Comments

@jjcasmar
Copy link

Hi,
ive been using CMakeCommon for a while now, but ive not been able to compile any library which uses CUDA.

If I try to compile using cuda_add_library, CMakeCommon complains that the target is not exported, but if I try to compile using common_library, g++ is used and not nvcc.

I believe that I should modify CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to use nvcc and a compatible gcc compiler. I thought that was that CommonCUDA did, but it seems there is a bug in the string(REGEX REPLACE) command.

What should I do?

Thanks!

@jjcasmar
Copy link
Author

BTW, this is the error im having
CMake Error at CMake/common/CommonCUDA.cmake:33 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
CMake/common/CommonFindPackage.cmake:276 (find_cuda_compatible_host_compiler)
CMakeLists.txt:103 (common_find_package_post)

CMake 3.9.4

@hernando
Copy link

You don't need to use CommonCUDA explicitly, the necessary code gets invoked from common_find_package_post(). If you've observed that error just by adding common_find_package(CUDA), then the problem must be in the parsing of the host_config.h CUDA header, which keeps changing all the time.

Related to the first problem, you should use cuda_add_library. Although I don't remember what's the actual explanation for it I added this to my CMakeLists.txt:

install(TARGETS your_target EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION lib COMPONENT COMMON)

It may also solve your problem.

@jjcasmar
Copy link
Author

The problem with cudacommon happens when doing common_find_package(CUDA). Isn't there an easy way to simply do common_library and that compiles it with cuda if cuda is enabled? Or what should be the correct process to configure a project with cuda with cmakecommon?

@hernando
Copy link

Ideally, having a smart common_library that can handle CUDA libraries would be perfect. But nobody has the time time right now to implement and I'm afraid that is not that simple, as it requires embedding cuda_add_library and will require making a few assumptions about the user intentions.

I think the problem is the header parsing as I said, so it should be easily fixable. Which CUDA version are you using?

@jjcasmar
Copy link
Author

Cuda 9

@hernando
Copy link

I'll try to see the difference in the host_config.h header as soon as possible.

@hernando
Copy link

Sorry for the delay, but I had to look into more urgent things and eventually forgot about this issue. If you're problem with the header parsing solved?

@jjcasmar
Copy link
Author

Ive been able to workaround the problem adding common_find_package(CUDA) after common_find_package_post(). This bypass the checks done in _post() and everything seems to work fine.

Not a production solution for CMakeCommon, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants