tensorrt的VS props配置

版本:

  • TensorRT-8.5.3.1.Windows10.x86_64.cuda-11.8.cudnn8.6
  • cuda_11.8.0_522.06_windows
  • cudnn-windows-x86_64-8.6.0.163_cuda11-archive
  • Zlib
  • OpenCV 4.7.0

安装参考: cuda、cudnn、zlib 深度学习GPU必配三件套(Windows) - 夕西行 - 博客园 (cnblogs.com)

具体配置(注意安装的路径和GPU算力):

tensorrt.props

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ImportGroup Label="PropertySheets" />
    <PropertyGroup Label="UserMacros" />
    <PropertyGroup />
    <ItemDefinitionGroup>
        <ClCompile>
            <AdditionalIncludeDirectories>C:\opencv\build\include;C:\opencv\build\include\opencv2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
            <AdditionalIncludeDirectories>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
            <AdditionalIncludeDirectories>C:\tensorrt\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
        </ClCompile>
        <Link>
            <AdditionalLibraryDirectories>C:\opencv\build\x64\vc16\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
            <AdditionalLibraryDirectories>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
            <AdditionalDependencies>cublasLt.lib;cuda.lib;cudadevrt.lib;cudart.lib;cudart_static.lib;cudnn.lib;cudnn_adv_infer.lib;cudnn_adv_infer64_8.lib;cudnn_adv_train.lib;cudnn_adv_train64_8.lib;cudnn_cnn_infer.lib;cudnn_cnn_infer64_8.lib;cudnn_cnn_train.lib;cudnn_cnn_train64_8.lib;cudnn_ops_infer.lib;cudnn_ops_infer64_8.lib;cudnn_ops_train.lib;cudnn_ops_train64_8.lib;cudnn64_8.lib;cufft.lib;cufftw.lib;cufilt.lib;curand.lib;cusolver.lib;cusolverMg.lib;cusparse.lib;nppc.lib;nppial.lib;nppicc.lib;nppidei.lib;nppif.lib;nppig.lib;nppim.lib;nppist.lib;nppisu.lib;nppitc.lib;npps.lib;nvblas.lib;nvjpeg.lib;nvml.lib;nvptxcompiler_static.lib;nvrtc.lib;nvrtc_static.lib;nvrtc-builtins_static.lib;OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
            <AdditionalLibraryDirectories>C:\tensorrt\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
            <AdditionalDependencies>nvinfer.lib;nvinfer_plugin.lib;nvonnxparser.lib;nvparsers.lib;%(AdditionalDependencies)</AdditionalDependencies>
        </Link>
        <CudaCompile>
              <CodeGeneration>compute_61,sm_61</CodeGeneration>
              <TargetMachinePlatform>64</TargetMachinePlatform>
        </CudaCompile>
    </ItemDefinitionGroup>

    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
        <Link>
            <AdditionalDependencies>opencv_world470d.lib;%(AdditionalDependencies)</AdditionalDependencies>
        </Link>
    </ItemDefinitionGroup>
    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
        <Link>
            <AdditionalDependencies>opencv_world470.lib;%(AdditionalDependencies)</AdditionalDependencies>
        </Link>
    </ItemDefinitionGroup>

</Project>

 

【c++项目添加cu文件后需要的设置】

1、项目处鼠标右键——生成依赖项——生成自定义——勾选CUDA,确定。

2、cu文件处鼠标右键——属性,如下图:

 

 

posted @ 2023-03-22 22:13  夕西行  阅读(85)  评论(0编辑  收藏  举报