Ask Your Question

sumit_K's profile - activity

2015-04-09 09:45:54 -0600 received badge  Necromancer (source)
2013-06-29 11:56:46 -0600 commented answer OpenCV, Cuda and Visual Studio... Dirty hacking (maybe?)

Yes you can

2013-06-28 14:41:09 -0600 answered a question Building OpenCV with Visual Studio 2012

Please try the solution given in this instructionCudaApps_With_VS2012.png (This is actually a .7z file; rename it after downloading it).Is there a better way to post these instructions?

2013-06-28 14:26:01 -0600 answered a question compiling openCV 2.4.5 under VS 2012 x64

Ben, I have a solution to this problem. Can you tell me how can I post it here? This space is screwing up my comments :(

2013-06-28 14:24:01 -0600 answered a question compiling openCV 2.4.5 under VS 2012 x64

Hello Ben If you are using OpenCV 2.4.9 and Visual Studio 2012 (Win 64) and Cuda 5.0 then read on;) So here is the process: 1.) Download and install Cuda 5.0 2.) Install the current version of CMake (as of writing this post: 2.8.10.2) 3.) Go to your CMake folder and inside the sub folder FindCuda. You will find run_nvcc.cmake. In that make the following changes: a.) Replace everything below ..."# nvcc doesn't define __CUDACC__ for some reason when generating dependency files. This can cause incorrect dependencies when #including files based on this macro which is .............." with this

set(CUDACC_DEFINE -D__CUDACC__) set(CUDA_VS2012_DEFINES) IF( (${my_generator} STREQUAL "Visual Studio 11 Win64") OR (${my_generator} STREQUAL "Visual Studio 11 Win32")) set(CUDA_VS2012_DEFINES --use-local-env --cl-version 2010) ENDIF()

IF( (${my_generator} STREQUAL "Visual Studio 11 Win64") OR (${my_generator} STREQUAL "Visual Studio 11 Win32"))

Generate the dependency file

cuda_execute_process( "Generating dependency file: ${NVCC_generated_dependency_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" ${CUDA_VS2012_DEFINES} -M ${CUDACC_DEFINE} "${source_file}" -o "${NVCC_generated_dependency_file}" #${CCBIN} ${nvcc_flags} ${nvcc_host_compiler_flags} ${depends_CUDA_NVCC_FLAGS} -DNVCC ${CUDA_NVCC_INCLUDE_ARGS} ) ELSEIF()

Generate the dependency file

cuda_execute_process( "Generating dependency file: ${NVCC_generated_dependency_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" -M ${CUDACC_DEFINE} "${source_file}" -o "${NVCC_generated_dependency_file}" ${CCBIN} ${nvcc_flags} ${nvcc_host_compiler_flags} ${depends_CUDA_NVCC_FLAGS} -DNVCC ${CUDA_NVCC_INCLUDE_ARGS} ) ENDIF()

if(CUDA_result) message(FATAL_ERROR "Error generating ${generated_file}") endif()

Generate the cmake readable dependency file to a temp file. Don't put the

quotes just around the filenames for the input_file and output_file variables.

CMake will pass the quotes through and not be able to find the file.

cuda_execute_process( "Generating temporary cmake readable file: ${cmake_dependency_file}.tmp" COMMAND "${CMAKE_COMMAND}" -D "input_file:FILEPATH=${NVCC_generated_dependency_file}" -D "output_file:FILEPATH=${cmake_dependency_file}.tmp" -P "${CUDA_make2cmake}" )

if(CUDA_result) message(FATAL_ERROR "Error generating ${generated_file}") endif()

Copy the file if it is different

cuda_execute_process( "Copy if different ${cmake_dependency_file}.tmp to ${cmake_dependency_file}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${cmake_dependency_file}.tmp" "${cmake_dependency_file}" )

if(CUDA_result) message(FATAL_ERROR "Error generating ${generated_file}") endif()

Delete the temporary file

cuda_execute_process( "Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}" COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}" )

if(CUDA_result) message(FATAL_ERROR "Error generating ${generated_file}") endif()

IF( (${my_generator} STREQUAL "Visual Studio 11 Win64") OR (${my_generator} STREQUAL "Visual Studio 11 Win32"))

Generate the code

cuda_execute_process( "Generating ${generated_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" ${CUDA_VS2012_DEFINES} "${source_file}" ${format_flag} -o "${generated_file}" #${CCBIN} ${nvcc_flags} ${nvcc_host_compiler_flags} ${CUDA_NVCC_FLAGS} -DNVCC ${CUDA_NVCC_INCLUDE_ARGS} ) ELSEIF() cuda_execute_process( "Generating ${generated_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" "${source_file}" ${format_flag} -o "${generated_file}" ${CCBIN} ${nvcc_flags} ${nvcc_host_compiler_flags} ${CUDA_NVCC_FLAGS} -DNVCC ${CUDA_NVCC_INCLUDE_ARGS} ) ENDIF()

if(CUDA_result) # Since nvcc can sometimes leave half done files make sure that we delete the output file. cuda_execute_process( "Removing ${generated_file}" COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}" ) message(FATAL_ERROR "Error generating file ${generated_file}") else() if(verbose) message("Generated ${generated_file} successfully.") endif() endif()

Cubin resource report commands.

if( build_cubin ) IF( (${my_generator} STREQUAL "Visual Studio 11 Win64") OR (${my_generator} STREQUAL "Visual Studio 11 Win32")) # Run with -cubin to produce resource usage report. cuda_execute_process( "Generating ${generated_cubin_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" ${CUDA_VS2012_DEFINES} "${source_file}" ${CUDA_NVCC_FLAGS} ${nvcc_flags} #${CCBIN} ${nvcc_host_compiler_flags} -DNVCC -cubin -o "${generated_cubin_file}" ${CUDA_NVCC_INCLUDE_ARGS} ) ELSEIF() cuda_execute_process( "Generating ${generated_cubin_file}" COMMAND "${CUDA_NVCC_EXECUTABLE}" "${source_file}" ${CUDA_NVCC_FLAGS} ${nvcc_flags} ${CCBIN} ${nvcc_host_compiler_flags} -DNVCC -cubin -o "${generated_cubin_file}" ${CUDA_NVCC_INCLUDE_ARGS} ) ENDIF()

# Execute the parser script. cuda_execute_process( "Executing the parser script" COMMAND "${CMAKE_COMMAND}" -D "input_file:STRING=${generated_cubin_file}" -P "${CUDA_parse_cubin}" )

endif()

b.) Now, in FindCuda.cmake, replace line ... (more)