(base) ➜ build cmake .. -- The C compiler identification is GNU 9.3.0 -- The CXX compiler identification is GNU 9.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found CUDA: /usr/local/cuda (found version "10.2") -- Caffe2: CUDA detected: 10.2 -- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc -- Caffe2: CUDA toolkit directory: /usr/local/cuda -- Caffe2: Header version is: 10.2 -- Found CUDNN: /usr/local/cuda/lib64/libcudnn.so -- Found cuDNN: v8.0.4 (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so) -- Autodetected CUDA architecture(s): 7.5 -- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75 -- Found Torch: /media/hao/Data/Code/DL/torchcppsample/libtorch/lib/libtorch.so -- Configuring done -- Generating done -- Build files have been written to: /media/hao/Data/Code/DL/torchcppsample/build
1 2 3 4 5 6
(base) ➜ build cmake --build . --config Release Scanning dependencies of target torchcpp [ 50%] Building CXX object CMakeFiles/torchcpp.dir/main.cpp.o [100%] Linking CXX executable torchcpp [100%] Built target torchcpp
接着前往上级文件夹,执行编译得到的主程序:
1 2 3 4 5
(base) ➜ cd .. (base) ➜ torchcppsample build/torchcpp Python/traced_resnet_model.pt model loads ok 0.1439 -0.8914 -0.0475 0.2474 0.3108 [ CPUFloatType{1,5} ]