Skip to content

CUDA: fix automatic cc#17571

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
tomoaki0705:fixAutomaticCC
Jun 18, 2020
Merged

CUDA: fix automatic cc#17571
opencv-pushbot merged 1 commit intoopencv:3.4from
tomoaki0705:fixAutomaticCC

Conversation

@tomoaki0705
Copy link
Copy Markdown
Contributor

resolves #17544
relates #17432

Honestly, I couldn't reproduce the situation on my local environment, but according to @Bleach665 's comment, this should fix the issue.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@opencv-pushbot opencv-pushbot merged commit 6bd87e8 into opencv:3.4 Jun 18, 2020
@tomoaki0705 tomoaki0705 deleted the fixAutomaticCC branch June 18, 2020 07:49
This was referenced Jun 18, 2020
@JulienMaille
Copy link
Copy Markdown
Contributor

This fix does indeed resolve the cmake error, but the generated solution won't properly compile any .cu file

>Building NVCC (Device) object modules/world/CMakeFiles/cuda_compile_1.dir/__/core/src/cuda/Release/cuda_compile_1_generated_gpu_mat.cu.obj
>nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

I've noticed that cmake trace shows
-- CUDA detected: 10.2
-- CUDA NVCC target flags: -gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_53,code=sm_53;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-D_FORCE_INLINES
when it used to show
-- CUDA NVCC target flags: -ccbin;$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget);-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_53,code=sm_53;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-D_FORCE_INLINES

@alalek
Copy link
Copy Markdown
Member

alalek commented Jun 30, 2020

@JulienMaille BTW, CMake output for CUDA NVCC target flags differs between separate launches (it is a bug - run of cmake . should be idempotent).
Clear CMake cache files to get stable result until bug got investigated/fixed.

@JulienMaille
Copy link
Copy Markdown
Contributor

Thank you @alalek
I tried from a clean build folder, but issue is the same. Actually I spent quite some time reverting changes until I found the section that breaks compilation on my setup:

if(PREFERRED_CUDA_HOST_COMPILER)
LIST(APPEND CUDA_NVCC_FLAGS -ccbin "${PREFERRED_CUDA_HOST_COMPILER}")
else()
if(WIN32 AND CMAKE_LINKER) #Workaround for VS cl.exe not being in the env. path
get_filename_component(host_compiler_bindir ${CMAKE_LINKER} DIRECTORY)
LIST(APPEND CUDA_NVCC_FLAGS -ccbin ${host_compiler_bindir})
endif()
endif()

@tomoaki0705
Copy link
Copy Markdown
Contributor Author

@JulienMaille could you please share your environment variable situation, especially the CUDA_HOST_COMPILER please ?
i.e. try following command on command prompt

>echo %CUDA_HOST_COMPILER%

I expect that you see

$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)

when I see

%CUDA_HOST_COMPILER%

as a result. The output on my side indicates that this variable is not set.
This environment variable needs to be set manually or otherwise it's supposed to be not set.
Did you set it manually ? If so, could you let me know what's the purpose ?
If you didn't set by purpose, is it possible to remove this environment variable, please ?

@JulienMaille
Copy link
Copy Markdown
Contributor

I did not set CUDA_HOST_COMPILER and in my terminal echo shows it is not set. I suppose this is set earlier by cmake?

@tomoaki0705
Copy link
Copy Markdown
Contributor Author

@JulienMaille
What I can only say is, please add message(STATUS "CUDA_HOST_COMPILER ${CUDA_HOST_COMPILER}") some where before here and share the result here.

if(CUDA_HOST_COMPILER)

Please please make sure that you start from clean directory to avoid cache of CMake

@alalek
Copy link
Copy Markdown
Member

alalek commented Jul 1, 2020

There are several patches about ccbin which breaks logic in CMake's CUDA scripts (from CMake).
My suggestion is to revert these patches (most of them are on the master branch only). PR will be created soon.

Until that do not use cmake-gui or run cmake multiple times for the same build directory (or perform cleaning of CMake cache from build directory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMake Error at cmake/OpenCVDetectCUDA.cmake:111

4 participants