Closed ph-code-repo closed 2 years ago
The "no such file" error usually occurs when the compiler cannot find the opencv lib path. Did you run sudo make install
after compiling opencv from source? Or maybe let's install opencv from apt using sudo apt install libopencv-dev
. (See readme)
I did not try opencv4 and not sure how that affects the compiling. Opencv3 should be a less problemic choice.
The second problem seems to be a linking problem. Can you share your platform,nvcc,cuda version with me?
Apologies for the slow response, very busy at the moment.
I believe I have both OpenCV 3 and 4 installed, and have compiled other projects with both before. However, this is usually with cmake, which I can specify a version to find. It might be the installations aren't installed in a typical manner, confusing pkg-config. I have run sudo apt install libopencv-dev
, and it says the opencv version 3 is up to date.
Running Ubuntu 18.04, with RTX 3070. nvcc: 11.4; CUDA 11.4 too. Thanks for the response!
Regarding your linking problem, could you try adding --compiler-options "-shared -fPIC
to your nvcc compling bash. I heard this from another user who successfully solved a similar issue.
gpu_kernel_build_cmd = f'/usr/local/cuda/bin/nvcc --compiler-options "-shared -fPIC" {gpu_sources_cpp} {gpu_sources_cu} -lib -o libgpu-kernels.so -O3 {nvcc_machine_code}'
Regarding your opencv problem, could you check the output of pkg-config --libs opencv
in your bash. The script uses this command to find opencv. If still not working, try adding opencv paths to library_dirs
and include_dirs
at around line 26.
i fix this problem by creating a link to include dir
cd /usr/include
sudo ln -s opencv4/opencv2 opencv2
my opencv include files' dir is /usr/include/opencv4/opencv2
Thanks for sharing the fixing!
I was getting the error
../../gpu-kernels/aux_funs.cpp:98:10: fatal error: opencv2/highgui.hpp: No such file or directory
whilst trying to compile things normally, noticing that when I had compiled opencv, it had not added to pkg-config. I was getting the error:../../gpu-kernels/aux_funs.cpp:98:10: fatal error: opencv2/highgui.hpp: No such file or directory
Having recompiled opencv4 with pkg_config enabled, I changed the
opencv_libs = subprocess.check_output('pkg-config --libs opencv'.split())
line to 'opencv_libs = subprocess.check_output('pkg-config --libs opencv4'.split())' and added the /usr/local/include/opencv4 directory to the Extension include_dirs argument.This produces the necessary library flags, but I still get the error I started with. I then noticed that libgpu-kernels is compiled by the nvcc compiler, not g++, so I tried manipulating some of the directories. However, I have not found a workable solution. In these cases, the compilation ends with the error:
relocation R_X86_64_PC32 against symbol '_Z31apply_weighted_sqrt_cauchy_lossibb' can not be used when making a shared object