{"id":22112166,"url":"https://github.com/josonchan1998/opencv_install","last_synced_at":"2025-10-12T05:30:59.717Z","repository":{"id":157063881,"uuid":"333033844","full_name":"JosonChan1998/OpenCV_Install","owner":"JosonChan1998","description":"Build OpenCV from sources with cuda in anaconda3","archived":false,"fork":false,"pushed_at":"2021-03-02T12:32:42.000Z","size":1577,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-01T10:58:18.010Z","etag":null,"topics":["anaconda3","cuda","opencv","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JosonChan1998.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-26T09:27:21.000Z","updated_at":"2024-02-27T22:58:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"2d271054-bc0f-4c5a-90a6-960fc15a08dd","html_url":"https://github.com/JosonChan1998/OpenCV_Install","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosonChan1998%2FOpenCV_Install","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosonChan1998%2FOpenCV_Install/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosonChan1998%2FOpenCV_Install/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JosonChan1998%2FOpenCV_Install/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JosonChan1998","download_url":"https://codeload.github.com/JosonChan1998/OpenCV_Install/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236169070,"owners_count":19106100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anaconda3","cuda","opencv","shell-script"],"created_at":"2024-12-01T10:57:09.620Z","updated_at":"2025-10-12T05:30:54.059Z","avatar_url":"https://github.com/JosonChan1998.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Build OpenCV from sources in anaconda virtual envs with Cuda\n\nThis is the script for installing OpenCV4.x with cuda in anaconda or default python\n\n## uninstall your old version OpenCV\n\nif you can find the build folder, you can run:\n```bash\ncd build\nsudo make uninstall\ncd ../\nrm -rf build\n```\nand remove all the opencv lib:\n\n```bash\n$  rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*\n$  cd /usr\n$  find . -name \"*opencv*\" | xargs sudo rm -rf\n```\nif you don't have the build folder , you can rebuild your old version follow next step , then try again.\n\n## Build OpenCV in anaconda with Cuda\n\n```bash\ngit clone \n\ncd opencv_install\n\nbash ./opencv_install.sh\n```\n\nFirst of all ,you should set same parameters for installing OpenCV and cuda setting\n\n- `INSTALL_DIR`: Where the OpenCV installed,default is /usr/local, recommand /usr/local\n- `OPENCV_SOURCE_DIR`: Where the OpenCV sources code download,default is your home dir\n- `WITH_CUDA`: With cuda or not\n- `ARCH_BIN`: You should check your device arch_bin in [Nvidia Devices](https://developer.nvidia.com/cuda-gpus)\n- `VIRTUAL_PYTHON_PATH`: Where is your python path,example: `/home/dnn/anaconda3/envs/opencv3`\n- `PYTHON_VERSION`: which python version your virtual envs use for,example: `python3.6`\n\n## Example\n\nMy test envs:\n\n- OpenCV 4.5.0\n- Ubuntu18.04\n- GTX 1080\n- Cuda 10.0\n- Cudnn 7.6.3\n- anaconda3\n- virtual envs: movie\n- make sure your virtual envs install numpy\n\n```bash\n[BASH]  Choose the OpenCV Version :(Enter:default 4.2.0) 4.5.0\n OpenCV Version: 4.5.0\n[BASH]  Change the path which OpenCV will be installed:(Enter:default /usr/local)\n OpenCV will be installed in: /usr/local\n[BASH]  Change the path which OpenCV Source path:(Enter:default $HOME)\n OpenCV source be downloaded in: /home/dnn\n[BASH]  Do you want to build with Cuda ? (y/n): y\n What is your arch_bin : 6.1\n[BASH]  where is your python path ? (default: /usr): /home/dnn/anaconda3/envs/movie\n[BASH]  what is your python version ? (default: python3.6): \n[BASH]  Build configuration: \n OpenCV binaries will be installed in: /usr/local\n OpenCV Source will be installed in: /home/dnn\n OpenCV build with Cuda or not: y\n Cuda ARCH_BIN: 6.1\n Python path: /home/dnn/anaconda3/envs/movie\n Python version: python3.6\n[BASH]  Do you wish to continue? (y/n) y\n```\n\n**Please check your python install path!!!**\n\n```bash\n--   Python 3:\n--     Interpreter:                 /home/dnn/anaconda3/envs/movie/bin/python3 (ver 3.6.12)\n--     Libraries:                   /home/dnn/anaconda3/envs/movie/lib/libpython3.6m.so.1.0 (ver 3.6.12)\n--     numpy:                       /home/dnn/anaconda3/envs/movie/lib/python3.6/site-packages/numpy/core/include (ver 1.19.2)\n--     install path:                lib/python3.6/site-packages/cv2/python-3.6\n```\n\nyou can see install_path :  `lib/python3.6/site-packages/cv2/python-3.6`\n\n## Linking .so file to your envs\n\n```bash\ncd /usr/local/lib/python3.6/site-packages/cv2/python-3.6\n\nls -l\n```\n\nyou will see like this:\n\n```bash\ncv2.cpython-36m-x86_64-linux-gnu.so\n```\n\nthen link to your virtual envs:\n\n```bash\ncd /home/dnn/anaconda3/envs/movie/lib/python3.6/packages\n\nsudo ln -s /usr/local/lib/python3.6/site-packages/cv2/cv2.cpython-36m-x86_64-linux-gnu.so cv2.so\n```\n\n## Test\n\n```bash\nconda activate movie\n\npython\n\nimport cv2\n\ncv2.__version__\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosonchan1998%2Fopencv_install","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosonchan1998%2Fopencv_install","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosonchan1998%2Fopencv_install/lists"}