Closed Xiaoming-Zhao closed 7 years ago
Update
About OpenCV, I used sudo apt-get install libopencv-dev
to install it. And when I used pkg-config --cflags opencv
to locate the file, the output is -I/usr/include/opencv
. However, when I went into /usr/include
I found there are two files named opencv
and opencv2
repectively.
After I added either of the two file's absolute path into config.mk's ADD_LDFLAGS
and ADD_CFLAGS
, the make result was make[1]: Leaving directory '/home/zhaoxiaoming/mxnet/dmlc-core'
. But to my surprise, I was able to use the mnist dataset example now.
Anyone could help me about this problem? Is there something wrong with the setting?
I guess you have opencv3, if so, try to add -limgcodecs
to ADD_LDFLAGS =
in your make configuration.
@zeakey Thanks for your kind reply, but unfortunately it did not work. The make output is:
/usr/bin/ld: cannot find -limgcodecs
collect2: error: ld returned 1 exit status
Makefile:190: recipe for target 'lib/libmxnet.so' failed
and
/usr/bin/ld: cannot find -limgcodecs
collect2: error: ld returned 1 exit status
Makefile:203: recipe for target 'bin/im2rec' failed
make: *** [bin/im2rec] Error 1
@Xiaoming-Zhao Trying to checkout your opencv library directory(usually /usr/lib
, /usr/local/lib
) and locate the file 'opencv_imgcodecs.so'.
ld errors with 'cannot find xxx' usually means your library files are not in the searching directory.
@zeakey
Hi, thanks a lot for your reply. I follow your advice to search for the two path /usr/lib
and /usr/local/lib
. However, unfortunately there is not any file related to opencv. I follow this web to check if I have installed opencv correctly, the outputs are following:
pkg-config --cflags opencv
, the output is
-I/usr/include/opencv
2.pkg-config --libs opencv
, the output is
/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so -lopencv_calib3d /usr/lib/x86_64-linux-gnu/libopencv_contrib.so -lopencv_contrib /usr/lib/x86_64-linux-gnu/libopencv_core.so -lopencv_core /usr/lib/x86_64-linux-gnu/libopencv_features2d.so -lopencv_features2d /usr/lib/x86_64-linux-gnu/libopencv_flann.so -lopencv_flann /usr/lib/x86_64-linux-gnu/libopencv_gpu.so -lopencv_gpu /usr/lib/x86_64-linux-gnu/libopencv_highgui.so -lopencv_highgui /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so -lopencv_imgproc /usr/lib/x86_64-linux-gnu/libopencv_legacy.so -lopencv_legacy /usr/lib/x86_64-linux-gnu/libopencv_ml.so -lopencv_ml /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so -lopencv_objdetect /usr/lib/x86_64-linux-gnu/libopencv_ocl.so -lopencv_ocl /usr/lib/x86_64-linux-gnu/libopencv_photo.so -lopencv_photo /usr/lib/x86_64-linux-gnu/libopencv_stitching.so -lopencv_stitching /usr/lib/x86_64-linux-gnu/libopencv_superres.so -lopencv_superres /usr/lib/x86_64-linux-gnu/libopencv_ts.so -lopencv_ts /usr/lib/x86_64-linux-gnu/libopencv_video.so -lopencv_video /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_videostab
Any suggestion? thanks~
@Xiaoming-Zhao
pkg-config --libs opencv
.
I face a similar error with Ubuntu 16.04
Ubuntu 16.04 x86_64. GCC 4.9.3. CUDA 7.5, CUDNN 4
MXNET make error:
/tmp/ccyoBXdv.o: In function main': im2rec.cc:(.text.startup+0x2878): undefined reference to
cv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator
I installed opencv following the documentation "sudo apt-get install -y build-essential git libatlas-base-dev libopencv-dev"
$ pkg-config --cflags opencv -I/usr/include/opencv $ pkg-config --libs opencv /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so -lopencv_calib3d /usr/lib/x86_64-linux-gnu/libopencv_contrib.so -lopencv_contrib /usr/lib/x86_64-linux-gnu/libopencv_core.so -lopencv_core /usr/lib/x86_64-linux-gnu/libopencv_features2d.so -lopencv_features2d /usr/lib/x86_64-linux-gnu/libopencv_flann.so -lopencv_flann /usr/lib/x86_64-linux-gnu/libopencv_gpu.so -lopencv_gpu /usr/lib/x86_64-linux-gnu/libopencv_highgui.so -lopencv_highgui /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so -lopencv_imgproc /usr/lib/x86_64-linux-gnu/libopencv_legacy.so -lopencv_legacy /usr/lib/x86_64-linux-gnu/libopencv_ml.so -lopencv_ml /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so -lopencv_objdetect /usr/lib/x86_64-linux-gnu/libopencv_ocl.so -lopencv_ocl /usr/lib/x86_64-linux-gnu/libopencv_photo.so -lopencv_photo /usr/lib/x86_64-linux-gnu/libopencv_stitching.so -lopencv_stitching /usr/lib/x86_64-linux-gnu/libopencv_superres.so -lopencv_superres /usr/lib/x86_64-linux-gnu/libopencv_ts.so -lopencv_ts /usr/lib/x86_64-linux-gnu/libopencv_video.so -lopencv_video /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_videostab
@opraveen I also have the same error. Ubuntu 16.04 x86_64 GCC 4.9.3 CUDA 7.5 OpenCV 2.4.10
As suggested in #744, I have been able to use clang and build mxnet without any issues.
The only changes I had to make are:
Although it works with clang, I see errors with CUDA enabled. There seem to be compatibility issues with cuda-7.5 and clang:
clang++ -c -O3 -Wall -msse2 -Wno-unknown-pragmas -Iinclude -std=c++0x -fPIC -DDMLC_USE_HDFS=0 -DDMLC_USE_S3=0 -DDMLC_USE_AZURE=0 -o config.o src/config.cc
ar cr libdmlc.a line_split.o recordio_split.o input_split_base.o io.o local_filesys.o data.o recordio.o config.o
make[1]: Leaving directory '/home/praveen/DeepLearning/mxnet/dmlc-core'
/usr/local/cuda/bin/nvcc -std=c++11 -Xcompiler -D_FORCE_INLINES -g -O3 -ccbin clang++ -Xcompiler "-DMSHADOW_FORCE_STREAM -Wall -O3 -I/home/praveen/DeepLearning/mxnet/mshadow/ -I/home/praveen/DeepLearning/mxnet/dmlc-core/include -fPIC -Iinclude -msse3 -funroll-loops -Wno-unused-parameter -Wno-unknown-pragmas -I/usr/local/cuda/include -DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_MKL=0 -DMSHADOW_RABIT_PS=0 -DMSHADOW_DIST_PS=0 -DMSDHADOW_USE_PASCAL=0 -DMXNET_USE_OPENCV=1 pkg-config --cflags opencv
-DMSHADOW_USE_CUDNN=1 -DMXNET_USE_NVRTC=0" -M -MT build/src/ndarray/ndarray_function_gpu.o src/ndarray/ndarray_function.cu >build/src/ndarray/ndarray_function_gpu.d
nvcc fatal : The version ('30800') of the host compiler ('clang') is not supported
Hi, I also got this problem when using gcc4.8 and g++4.8 but when I use gcc 5 and g++5, the compilation succeed. hope to help you.
@opraveen @seva100 Hi, sorry to hear that you got a similar error.
Actually, in the end, I did not solve this problem. However, this error did not prohibit me from doing work. I was trying to do some work about image at that time. This error told us that it could not create a file bin/im2rec
, which was used to transform image to MXNet's own data format record
. However, we do not need this. In the path mxnet/tools/
, there exist two programs, namely im2rec.cc
and im2rec.py
. We could directly use im2rec.py
to complete the work which should be done by bin/im2rec
. Something like this:
python im2rec.py <source image's path> <the path to put record file> <--resize=n>
Hope this could make you feel better.
@Xiaoming-Zhao I faced the same problem with you , but solved by added -lopencv_imgcodecs
not -limgcodecs
,and locate opencv_imgcodecs.so ,then add in ADD_LDFLAGS =, then it works.
$ locate opencv_imgcodecs.so
/home/scw4150/caffe_centos/opencv-3.1.0/lib/libopencv_imgcodecs.so
/home/scw4150/caffe_centos/opencv-3.1.0/lib/libopencv_imgcodecs.so.3.1
/home/scw4150/caffe_centos/opencv-3.1.0/lib/libopencv_imgcodecs.so.3.1.0
/usr/local/lib/libopencv_imgcodecs.so
/usr/local/lib/libopencv_imgcodecs.so.3.1
/usr/local/lib/libopencv_imgcodecs.so.3.1.0
hope this will help you!
Good discussion but the suggestions are not very obvious to readers. Anyhow, in my case, I managed to solve the problem by issuing the following commands.
make ADD_CFLAGS="/usr/include/opencv2" CC="gcc-4.9" CXX="g++-4.9" -j 4 USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 USE_USE_CUDNN=1
Right now I am using ubuntu zesty and by default it installed opencv2. As mentioned by Xiaoming, the cflags path was missing from pkg-config. Also, I can't use gcc-6 or gcc-5 because cuda 8 will complain.
Hi, I met a problem here.
My OS is Ubuntu 15.10 x86_64. My gcc is 4.9.3. My CUDA is 7.5.17. My OpenCV is 2.4.9.
If I
make -j4
withOpenCV=0
of the config.mk file, everything goes well. I can use the example, namely MLP on the mnist dataset put on the MXNet official web install guide with GPU. However, if Imake -j4
withOpenCV=1
, I met an errorI search google for several days but no answer has solved this problem. Could anyone help me?
Thanks!
PS. I think the similar problem is #744 , but the answers there could not solve this problem unfortunately.