MantisBT - CMake
View Issue Details
0015482CMakeCMakepublic2015-03-30 16:342016-02-01 09:10
Curtis Mahieu 
James Bigler 
normalfeaturehave not tried
closedfixed 
 
CMake 3.3CMake 3.3 
0015482: CUDA - Support Static Linked Binaries.
currently FindCUDA searches for "cudart" and other CUDA equivalent libraries.
These find the dynamic versions of the files, as they are named libcudart.so libcudart.dylib.... etc.

It seems to be impossible to compile with the static files named "libcudart_static.a"
No tags attached.
related to 0015723closed Rolf Eike Beer Regression: FindCUDA fails for C++ only projects in CMake 3.3.1 due find_package(Threads), while it works well in CMake 3.2.3 
Issue History
2015-03-30 16:34Curtis MahieuNew Issue
2015-03-30 16:42Brad KingNote Added: 0038364
2015-03-30 17:01James BiglerNote Added: 0038366
2015-03-30 17:06Curtis MahieuNote Added: 0038367
2015-03-30 19:39Curtis MahieuNote Added: 0038368
2015-03-30 19:43Curtis MahieuNote Added: 0038369
2015-03-31 15:04James BiglerNote Added: 0038375
2015-03-31 15:24Curtis MahieuNote Added: 0038376
2015-03-31 16:20James BiglerNote Added: 0038377
2015-03-31 16:27Curtis MahieuNote Added: 0038378
2015-03-31 17:12Curtis MahieuNote Added: 0038379
2015-03-31 17:16James BiglerNote Added: 0038380
2015-03-31 18:44Curtis MahieuNote Added: 0038381
2015-03-31 18:57Curtis MahieuNote Edited: 0038381bug_revision_view_page.php?bugnote_id=38381#r1737
2015-04-03 10:14Brad KingNote Added: 0038394
2015-04-03 10:15Brad KingNote Edited: 0038394bug_revision_view_page.php?bugnote_id=38394#r1745
2015-04-03 10:16Brad KingAssigned To => James Bigler
2015-04-03 10:16Brad KingStatusnew => resolved
2015-04-03 10:16Brad KingResolutionopen => fixed
2015-04-03 10:16Brad KingFixed in Version => CMake 3.3
2015-04-03 10:16Brad KingTarget Version => CMake 3.3
2015-09-02 09:04Brad KingRelationship addedrelated to 0015723
2016-02-01 09:10Robert MaynardNote Added: 0040387
2016-02-01 09:10Robert MaynardStatusresolved => closed

Notes
(0038364)
Brad King   
2015-03-30 16:42   
One could set the CUDA_*_LIBRARY cache entries explicitly to refer to the static libraries.
(0038366)
James Bigler   
2015-03-30 17:01   
I do have a pending change that enables this feature. I've been testing it and need to find some time to integrate it.
(0038367)
Curtis Mahieu   
2015-03-30 17:06   
Im overriding the variable as a temporary solution, but i have to switch based on the OS as I can't see an easy way to get access to the /lib or /lib64 variable.

James, Thanks for the awesome Module!
(0038368)
Curtis Mahieu   
2015-03-30 19:39   
I had some ordering wrong when i first tested my "work around" when i actually overrisde the library using this:

find_package(CUDA)
get_filename_component(CUDA_LIB_FOLDER ${CUDA_LIBRARIES} DIRECTORY)

unset(CUDA_LIBRARIES)
set(CUDA_LIBRARIES "${CUDA_LIB_FOLDER}/libcudart_static.a")

message("Using static lib: " ${CUDA_LIBRARIES})

i can see this in the build log:
Using static lib: /usr/local/cuda/lib/libcudart_static.a

But when i go to actually run the binary i get this message:

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 35
-> CUDA driver version is insufficient for CUDA runtime version
Result = FAIL

Process finished with exit code 1

NOTE: I just made a quick sample out of the deviceQuery CUDA sample source.
(0038369)
Curtis Mahieu   
2015-03-30 19:43   
James,
Is there any way you could post / point me to you patch that has this support. I could at least then bundle it into the project Im working on.
(0038375)
James Bigler   
2015-03-31 15:04   
I could give you a copy of the FindCUDA that has these changes, but there are a few other changes in there that would need to be removed to make it work for you.

Do you have the ability to use a custom FindCUDA?
(0038376)
Curtis Mahieu   
2015-03-31 15:24   
yeah i can use a custom findCUDA.
(0038377)
James Bigler   
2015-03-31 16:20   
I just teased it apart. You can find a copy in stage:

http://www.cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/FindCUDA.cmake/StaticRuntime [^]
(0038378)
Curtis Mahieu   
2015-03-31 16:27   
Awesome! Thanks!

Ill test it out today.
(0038379)
Curtis Mahieu   
2015-03-31 17:12   
Works perfectly! Thanks!
(0038380)
James Bigler   
2015-03-31 17:16   
What platforms have you tried? I developed this for Windows, Linux, and Mac.
(0038381)
Curtis Mahieu   
2015-03-31 18:44   
(edited on: 2015-03-31 18:57)
I tested it on Mac and Linux.

(0038394)
Brad King   
2015-04-03 10:14   
(edited on: 2015-04-03 10:15)
I revised the commit message slightly and added a release note. The commit is now:

 FindCUDA: Use the static CUDA runtime library if available
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7fea2b77 [^]

(0040387)
Robert Maynard   
2016-02-01 09:10   
Closing resolved issues that have not been updated in more than 4 months.