关于动态链接库的依赖路径问题tensorRT

 

问题:项目依赖的3rdParty中的tensorRT的lib出现依赖woring

[W] [TRT] TensorRT was linked against cuDNN 7.6.3 but loaded cuDNN 7.6.0

查看到了tensorRT的libnvinfer.so依赖的cudnn.so.7没有使用CmakeLists.txt  link_directories(cudnn的lib路径),而是使用的/user/local/cuda/lib64的路径。

根据下面的优先级,查看到底为何没有拿到指定的库

  1. LD_RUN_PATH设置的路径
  2. 链接器使用-rpath或-R选项设置的路径
  3. LD_LIBRARY_PATH设置的路径
  4. /etc/ld.so.conf配置的路径
  5. /usr/lib/和 /lib/

其中LD_RUN_PATH和链接器使用-rpath或-R选项都是设置可执行文件中的Library rpath。

 

根据查找指令:发现了libtorch的rpath包含了系统下的cuda链接库路径(该链接库路径据说是由编译libtorch时添加的)。

readelf -d /data/.../3rdParty/libtorch/lib/libtorch.so.1



Dynamic section at offset 0xb9a488 contains 36 entries:
  标记        类型                         名称/值
 0x0000000000000001 (NEEDED)             共享库:[libnvToolsExt.so.1]
 0x0000000000000001 (NEEDED)             共享库:[libcudart.so.10.0]
 0x0000000000000001 (NEEDED)             共享库:[libcaffe2.so]
 0x0000000000000001 (NEEDED)             共享库:[libcaffe2_gpu.so]
 0x0000000000000001 (NEEDED)             共享库:[libc10.so]
 0x0000000000000001 (NEEDED)             共享库:[libpthread.so.0]
 0x0000000000000001 (NEEDED)             共享库:[libstdc++.so.6]
 0x0000000000000001 (NEEDED)             共享库:[libm.so.6]
 0x0000000000000001 (NEEDED)             共享库:[libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             共享库:[libc.so.6]
 0x0000000000000001 (NEEDED)             共享库:[ld-linux-x86-64.so.2]
 0x000000000000000e (SONAME)             Library soname: [libtorch.so.1]
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN:$ORIGIN:/usr/local/cuda/lib64:/data_1/aw/anaconda3/lib]
 0x000000000000000c (INIT)               0x1dae70
 0x000000000000000d (FINI)               0x957db8
 0x0000000000000019 (INIT_ARRAY)         0xd6f240
 0x000000000000001b (INIT_ARRAYSZ)       1272 (bytes)
 0x000000000000001a (FINI_ARRAY)         0xd6f738
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x228
 0x0000000000000005 (STRTAB)             0x511b0
 0x0000000000000006 (SYMTAB)             0x137a0
 0x000000000000000a (STRSZ)              1026838 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000003 (PLTGOT)             0xd9d000
 0x0000000000000002 (PLTRELSZ)           47760 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x1cf3e0
 0x0000000000000007 (RELA)               0x151128
 0x0000000000000008 (RELASZ)             516792 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x150ef8
 0x000000006fffffff (VERNEEDNUM)         8
 0x000000006ffffff0 (VERSYM)             0x14bcc6
 0x000000006ffffff9 (RELACOUNT)          8966
 0x0000000000000000 (NULL)               0x0

 

 

参考资料: https://blog.csdn.net/chenyulancn/article/details/80063366

你可能感兴趣的:(深度学习,编程,环境配置,cuda,c++,tensorRT)