OpenCV编译C++测试程序获取cuda设备信息

视频讲解

OpenCV编译C++测试程序获取CUDA设备信息

测试代码

test-cv.cpp

#include 
#include 
#include 

using namespace cv;
using namespace cv::cuda;
using namespace std;

int main(int argc, char **argv) {
    cuda::printCudaDeviceInfo(cuda::getDevice());
    int cnt = getCudaEnabledDeviceCount();
    printf("Now get CUDA device count:%d \r\n", cnt);
    return 0;
}

手动编译的opencv的安装目录在/usr/lib下,可以看之前的cmake参数

-DCMAKE_INSTALL_PREFIX=/usr/local \

故使用g++编译的时候,需要加上-l指定头文件目录,否则就会报找不到opencv头文件

fatal error: opencv2/opencv.hpp: No such file or directory

再增加-L指定依赖动态库的位置,-lopencv_core为基础库
还有如下库可能会使用到
-lopencv_aruco -lopencv_barcode -lopencv_bgsegm -lopencv_bioinspired -lopencv_calib3d -lopencv_ccalib -lopencv_core -lopencv_datasets -lopencv_dnn_objdetect -lopencv_dnn -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_features2d -lopencv_flann -lopencv_freetype -lopencv_fuzzy -lopencv_gapi -lopencv_hfs -lopencv_highgui -lopencv_imgcodecs -lopencv_img_hash -lopencv_imgproc -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_ml -lopencv_objdetect -lopencv_optflow -lopencv_phase_unwrapping -lopencv_photo -lopencv_plot -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_stereo -lopencv_stitching -lopencv_structured_light -lopencv_superres -lopencv_surface_matching -lopencv_text -lopencv_tracking -lopencv_videoio -lopencv_video -lopencv_videostab -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_ximgproc -lopencv_xobjdetect -lopencv_xphoto

g++ test-cv.cpp -o test-cv -I/usr/local/include/opencv4 -L/usr/local/lib -lopencv_core

运行得到如下结果

./test-cv 
*** CUDA Device Query (Runtime API) version (CUDART static linking) *** 

Device count: 1

Device 0: "Orin"
  CUDA Driver Version / Runtime Version          11.40 / 11.40
  CUDA Capability Major/Minor version number:    8.7
  Total amount of global memory:                 7471 MBytes (7834177536 bytes)
  GPU Clock Speed:                               0.62 GHz
  Max Texture Dimension Size (x,y,z)             1D=(131072), 2D=(131072,65536), 3D=(16384,16384,16384)
  Max Layered Texture Size (dim) x layers        1D=(32768) x 2048, 2D=(32768,32768) x 2048
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per block:           1024
  Maximum sizes of each dimension of a block:    1024 x 1024 x 64
  Maximum sizes of each dimension of a grid:     2147483647 x 65535 x 65535
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and execution:                 Yes with 2 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            Yes
  Support host page-locked memory mapping:       Yes
  Concurrent kernel execution:                   Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support enabled:                No
  Device is using TCC driver mode:               No
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Bus ID / PCI location ID:           0 / 0
  Compute Mode:
      Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) 

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version  = 11.40, CUDA Runtime Version = 11.40, NumDevs = 1

Now get CUDA device count:1 

你可能感兴趣的:(jetson,opencv,opencv,c++,人工智能,计算机视觉,YOLO)