Created
September 18, 2018 11:23
-
-
Save raytroop/7d271a39c41a136d2fae73b00c4e62e9 to your computer and use it in GitHub Desktop.
opencv install cuda9, conda env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it clone https://github.com/opencv/opencv.git | |
cd opencv | |
git checkout 3.4.2 | |
mkdir build && cd build | |
source activate tpt | |
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D FORCE_VTK=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES --expt-relaxed-constexpr" -D WITH_GDAL=ON -D WITH_XINE=ON -D BUILD_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.3/modules -DPYTHON3_EXECUTABLE=/home/software/miniconda3/envs/tpt/bin/python3 -DPYTHON_INCLUDE_DIRS=/home/software/miniconda3/envs/tpt/include/python3.6m -DPYTHON_LIBRARIES=/home/software/miniconda3/envs/tpt/lib -DPYTHON3_NUMPY_INCLUDE_DIRS=/home/software/miniconda3/envs/tpt/lib/python3.6/site-packages/numpy/core/include .. | |
make -j $(($(nproc) + 1)) | |
sudo make install | |
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' | |
sudo ldconfig | |
sudo apt-get update | |
reboot the system. | |
Check if the OpenCV file exists | |
python2 | |
“/usr/local/lib/python2.7/dist-packages/cv2.so” | |
python3.5 | |
“/usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-x86_64-linux-gnu.so” | |
or | |
"/usr/local/lib/python3.5/site-packages/cv2.cpython-35m-x86_64-linux-gnu.so" | |
python3.6 | |
“/usr/local/lib/python3.6/dist-packages/cv2.cpython-36m-x86_64-linux-gnu.so” | |
To use OpenCV 3.4.0 in virtual environment like virtualenv, conda or any other, copy related .so file or softlink in your virtual environment python directory | |
“lib/site-packages/” | |
or | |
"miniconda3/envs/tf/lib/python3.5/site-packages/" | |
Finally, check OpenCV version. Go to the terminal and type python | |
On the python terminal, type | |
import cv2 | |
cv2.__version__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment