1 | initial version |
it's probably easier, than you think, colab already has all dependancies onboard (given you choose the python3 CUDA runtime). you also don't need to mess with virtual enviroments imho
so, here's my receipe:
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_CUDA=ON \ <-- those
-DWITH_CUBLAS=ON \ <-- are
-DWITH_CUDNN=ON \ <-- important !
-DOPENCV_DNN_CUDA=ON \ <-- !!!
/content/opencv
!make -j8 install
import cv2
cv2.__version__
(should print: 4.4.0)
but alas, your cv2 install is NOT persistant, next colab allocation will wipe it all clean, so you need to copy the so to some folder your own drive:
!mkdir "/content/drive/My Drive/cv2_cuda"
!cp /content/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so "/content/drive/My Drive/cv2_cuda"
then, the next time you want to use it, copy it back to your current workdir :
!cp "/content/drive/My Drive/cv2_cuda/cv2.cpython-36m-x86_64-linux-gnu.so" .
restart your python runtime (so it forgets about the prev. installed cv2) and it should pick up your local cv2.so ;)
2 | No.2 Revision |
it's probably easier, than you think, colab already has all dependancies onboard (given you choose the python3 CUDA runtime). you also don't need to mess with virtual enviroments imho
so, here's my receipe:
%cd /content
!git clone https://github.com/opencv/opencv
!git clone https://github.com/opencv/opencv_contrib
!mkdir /content/build
%cd /content/build
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_CUDA=ON \ <-- those
-DWITH_CUBLAS=ON \ <-- are
-DWITH_CUDNN=ON \ <-- important !
-DOPENCV_DNN_CUDA=ON \ <-- !!!
/content/opencv
!make -j8 install
import cv2
cv2.__version__
(should print: 4.4.0)
but alas, your cv2 install is NOT persistant, next colab allocation will wipe it all clean, so you need to copy the so to some folder your own drive:
!mkdir "/content/drive/My Drive/cv2_cuda"
!cp /content/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so "/content/drive/My Drive/cv2_cuda"
then, the next time you want to use it, copy it back to your current workdir :
!cp "/content/drive/My Drive/cv2_cuda/cv2.cpython-36m-x86_64-linux-gnu.so" .
restart your python runtime (so it forgets about the prev. installed cv2) and it should pick up your local cv2.so ;)
3 | No.3 Revision |
it's probably easier, than you think, colab already has all dependancies onboard (given you choose the python3 CUDA runtime). you also don't need to mess with virtual enviroments imho
so, here's my receipe:
%cd /content
!git clone https://github.com/opencv/opencv
!git clone https://github.com/opencv/opencv_contrib
!mkdir /content/build
%cd /content/build
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_CUDA=ON \ <-- those
-DWITH_CUBLAS=ON \ <-- are
-DWITH_CUDNN=ON \ <-- important !
-DOPENCV_DNN_CUDA=ON \ <-- !!!
/content/opencv
!make -j8 install
import cv2
cv2.__version__
(should print: 4.4.0)
but alas, your cv2 install is NOT persistant, next colab allocation will wipe it all clean, so you need to copy the so to some folder your own drive:
!mkdir "/content/drive/My Drive/cv2_cuda"
!cp /content/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so "/content/drive/My Drive/cv2_cuda"
then, the next time you want to use it, copy it back to your current workdir :
!cp "/content/drive/My Drive/cv2_cuda/cv2.cpython-36m-x86_64-linux-gnu.so" .
restart your python runtime (so it forgets about the prev. installed cv2) and it should pick up your local local, CUDA enabled cv2.so ;)
4 | No.4 Revision |
it's probably easier, than you think, colab already has all dependancies onboard (given you choose the python3 CUDA runtime). you also don't need to mess with virtual enviroments imho
so, here's my receipe:
%cd /content
!git clone https://github.com/opencv/opencv
!git clone https://github.com/opencv/opencv_contrib
!mkdir /content/build
%cd /content/build
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_CUDA=ON \ <-- those
-DWITH_CUBLAS=ON \ <-- are
-DWITH_CUDNN=ON \ <-- important !
-DOPENCV_DNN_CUDA=ON \ <-- !!!
/content/opencv
!make -j8 install
import cv2
cv2.__version__
(should print: 4.4.0)
but alas, your cv2 install is NOT persistant, next colab allocation will wipe it all clean, so you need to copy the so to some folder on your own drive:
!mkdir "/content/drive/My Drive/cv2_cuda"
!cp /content/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so "/content/drive/My Drive/cv2_cuda"
then, the next time you want to use it, copy it back to your current workdir :
!cp "/content/drive/My Drive/cv2_cuda/cv2.cpython-36m-x86_64-linux-gnu.so" .
restart your python runtime (so it forgets about the prev. installed cv2) and it should pick up your local, CUDA enabled cv2.so ;)
5 | No.5 Revision |
it's probably easier, than you think, colab already has all dependancies onboard (given you choose the python3 CUDA runtime). you also don't need to mess with virtual enviroments imho
so, here's my receipe:
%cd /content
!git clone https://github.com/opencv/opencv
!git clone https://github.com/opencv/opencv_contrib
!mkdir /content/build
%cd /content/build
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_CUDA=ON \ <-- those
-DWITH_CUBLAS=ON \ <-- are
-DWITH_CUDNN=ON \ <-- important !
-DOPENCV_DNN_CUDA=ON \ <-- !!!
/content/opencv
!make -j8 install
import cv2
cv2.__version__
(should print: 4.4.0)
but alas, your cv2 install is NOT persistant, next colab allocation will wipe it all clean, so you need to copy the so to some folder on your own drive:
!mkdir "/content/drive/My Drive/cv2_cuda"
!cp /content/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so "/content/drive/My Drive/cv2_cuda"
then, the next time you want to use it, copy it back to your current workdir :
!cp "/content/drive/My Drive/cv2_cuda/cv2.cpython-36m-x86_64-linux-gnu.so" .
restart your python runtime (so it forgets about the prev. installed cv2) and it should pick up your local, CUDA enabled cv2.so cv2.so. good luck ;)
6 | No.6 Revision |
it's probably easier, than you think, colab already has all dependancies onboard (given you choose the python3 CUDA runtime). you also don't need to mess with virtual enviroments imho
so, here's my receipe:
%cd /content
!git clone https://github.com/opencv/opencv
!git clone https://github.com/opencv/opencv_contrib
!mkdir /content/build
%cd /content/build
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_CUDA=ON \ <-- those
-DWITH_CUBLAS=ON \ <-- are
-DWITH_CUDNN=ON \ <-- important !
-DOPENCV_DNN_CUDA=ON \ <-- !!!
/content/opencv
!make -j8 install
import cv2
cv2.__version__
(should print: 4.4.0)
but alas, your cv2 install is NOT persistant, next colab allocation will wipe it all clean, so you need to copy the so to some folder on your own drive:
!mkdir "/content/drive/My Drive/cv2_cuda"
!cp /content/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so "/content/drive/My Drive/cv2_cuda"
then, the next time you want to use it, copy it back to your current workdir :
!cp "/content/drive/My Drive/cv2_cuda/cv2.cpython-36m-x86_64-linux-gnu.so" .
restart your python runtime (so it forgets about the prev. installed cv2) and it should pick up your local, CUDA enabled cv2.so.
it all worked like 3 weeks ago, but who knows, --- good luck ;)