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

opencv-rust won't build after 0.41.1 on OSX do to cuda deps #159

Closed
dadkins789 opened this issue Jul 31, 2020 · 20 comments
Closed

opencv-rust won't build after 0.41.1 on OSX do to cuda deps #159

dadkins789 opened this issue Jul 31, 2020 · 20 comments

Comments

@dadkins789
Copy link

Before reporting an issue please first check the
troubleshooting guide. If
the issue you're encountering is not solved thereby please state the following in your bugreport:

  1. Operating system
  2. The way you installed OpenCV: package, official binary distribution, manual compilation, etc.
  3. OpenCV version
  4. Attach the full output of the following command from your project directory:
    RUST_BACKTRACE=full cargo build -vv 

OSX 10.15.6

OpenCV 4.4.0 built using command line tools.

running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "/Users/davea/.cargo/registry/src/github.com-1ecc6299db9ec823/opencv-0.44.1/src_cpp" "-I" "/Volumes/Work/src/rustgtkclient/target/release/build/opencv-f947e94bb244eed7/out" "-I" "." "-I" "/usr/local/include/opencv4" "-Wall" "-Wextra" "-std=c++11" "-Wno-deprecated-declarations" "-Wno-unused-variable" "-Wno-return-type-c-linkage" "-o" "/Volumes/Work/src/rustgtkclient/target/release/build/opencv-f947e94bb244eed7/out/cudafilters.o" "-c" "/Volumes/Work/src/rustgtkclient/target/release/build/opencv-f947e94bb244eed7/out/cudafilters.cpp"

Pretty self explanitory. Cuda support was added after 0.41 nothing later builds no CUDA support on OSX anymore.

@twistedfall
Copy link
Owner

Hi, I fail to grasp the problem TBH. You are saying that CUDA is no longer supported on macOS, am I right? But the crate generates the OpenCV bindings based on the OpenCV you have installed. So if it tries to build CUDA modules then it means that your OpenCV installation contains those modules. So if they don’t work then you should exclude them from your OpenCV installation.

You haven’t provided the exact error you’re getting and the output of cargo build -vv, that makes troubleshooting really difficult.

@dadkins789
Copy link
Author

dadkins789 commented Jul 31, 2020 via email

@twistedfall
Copy link
Owner

You mentioned that you'd attach the build log, but I can't find any attachment. The log file you pasted into the message is incomplete unfortunately.

@dadkins789
Copy link
Author

dadkins789 commented Aug 3, 2020 via email

@twistedfall
Copy link
Owner

The most important for me is -vv, it shows the necessary debug information. You can also upload the log somewhere like pastebin and such. One thing you can also try is making sure you build with crate feature buildtime-bindgen enabled (it’s enabled by default unless you build with default-features=false).

@dadkins789
Copy link
Author

I was using default-features=false, fixed that, ran the cargo build -vv and added RUST_BACKTRACE='full' to the environment.

build.log

@twistedfall
Copy link
Owner

That's interesting, can you please share the headers you have in /usr/local/include/opencv4/opencv2? It looks like there is something unexpected there.

@dadkins789
Copy link
Author

Ya, that panic was unexpected. Built the same thing on Fedora 32 as close to the same config as I could and no problem.

opencv2.headers.tar.gz

@twistedfall
Copy link
Owner

Can you check if rel branch works for you?

@dadkins789
Copy link
Author

dadkins789 commented Aug 4, 2020

Log from build on the rel branch.

build.log

@twistedfall
Copy link
Owner

I wonder how it turned out that "opencv2/core/cuda.hpp" is missing in your install. You have some header files, e.g. "opencv2/videostab/wobble_suppression.hpp" or "opencv2/stitching/detail/warpers.hpp" that include it (#include "opencv2/core/cuda.hpp") so that makes includes for modules videostab and stitching invalid in your headers. Even when it's built in the CI environment (definitely no CUDA there) with WITH_CUDA=OFF the "core/cuda.hpp" header is still getting installed. Can you please share in details of how you built your OpenCV installation?

@dadkins789
Copy link
Author

My procedure assuming I have all my dependencies installed which I install with brew.
select version git checkout

make a build dir.
run cmake
" cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules -DOPENCV_GENERATE_PKGCONFIG=YES -DWITH_QT=YES -DCMAKE_VERBOSE_MAKEFILE=ON .."
run make

if it all goes without error
run make install

log from cmake

cmake.log

make log for opencv

make.log

I also started building this on fedora 32 with extra verbosity. It works on Fedora and it also included the offending cuda headers. Its not done building yet so I'll copy it up later.

cmake cache file from cmake on osx

CMakeCache.txt

@twistedfall
Copy link
Owner

Thanks, I’ll try to reproduce it! meanwhile can you try the rel branch again? I force-pushed it, the generation of the core module should work fine now, but I’m afraid some other modules like those videostab or stitching would fail.

@dadkins789
Copy link
Author

Tried rel and core was fine but it failed in other modules. I checked the installed opencv4/opencv2/core directory from a Fedora 32 build against the one that the OSX build. In the Fedora32 which worked cuda.hpp cuda.inl.hpp cuda_stream_accessor.hpp cuda_types.hpp were present. In the OSX build they were not. I manually copied them from the module/core/include/opencv2/core both the rel branch and the stock 0.44.1 built without incident. I guess that was to be expected. This sure looks like an opencv or cmake issue and not your problem.

I've got the build from rel both with and without the copied headers.

build-with-extra.log.gz
build-without-extra.log.gz

@twistedfall
Copy link
Owner

I actually made a fresh build with options you mentioned (but also without Qt) in macOS and it did contain CUDA files. I haven’t made any deep comparisons of the logs between my build and yours though yet. But it might be worth trying to rebuild and reinstall OpenCV, maybe something went wrong the first time.

@dadkins789
Copy link
Author

I built from scratch and got your results (built with Qt). Whatever I did with that previous build I broke a while ago. .Sorry to chew up this much time.

Thanks for your time.

@twistedfall
Copy link
Owner

No problem at all! Due to your bugreport I managed to fix one of the issues that haunted me for a while, so it wasn’t in vain! I’m going to release the new version without the conditionals for CUDA, thanks!

@twistedfall
Copy link
Owner

Should be fixed in the crate version 0.44.2, please test

@dadkins789
Copy link
Author

No build problems with 0.44.2

@twistedfall
Copy link
Owner

Great to hear!

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