解決TensorRT編譯時protobuf的載編譯的錯誤

在編譯TensorRT6.0的時候,可能會遇到protobuf下載導致的錯誤,
錯誤的issue:https://github.com/NVIDIA/TensorRT/issues/78
主要報錯內容:

CMakeFiles/third_party.protobuf.dir/build.make:90: recipe for target 'third_party.protobuf/src/third_party.protobuf-stamp/third_party.protobuf-download' failed
make[2]: *** [third_party.protobuf/src/third_party.protobuf-stamp/third_party.protobuf-download] Error 1
CMakeFiles/Makefile2:139: recipe for target 'C
MakeFiles/third_party.protobuf.dir/all' failed

解決方法

issue上有一種解決方法是在編譯cmake的時候加curl參數,我試過,沒有解決我的問題。
查看報錯內容,分析發現是是因爲protobuf文件無法下載下來,於是根據報錯內容,自己下載cmake的源碼包,然後修改cmake文件,進行解決
修改的步驟如下:

1. 編譯的時候,指定protobuf版本

在編譯語句中,添加如下參數:

-DPROTOBUF_VERSION="3.11.4"

完整一點的

cmake .. -DTRT_LIB_DIR=$TRT_RELEASE/lib -DTRT_BIN_DIR=`pwd`/out  -DPROTOBUF_VERSION="3.11.4"

2.下載cmake源碼

在執行完1中的命令後,執行下面的命令

cd hird_party.protobuf/src
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protobuf-cpp-3.11.4.tar.gz

如果你使用的是其他版本的protobuf,進行相應的修改,protobuf的下載地址在這裏:https://github.com/protocolbuffers/protobuf/releases

3. 修改cmake

接上一步,執行下面的命令

vim third_party.protobuf-stamp/download-third_party.protobuf.cmake

在82行下添加

return()

也就是chek_file_hash()上面,和該行對其

4. 重新編譯

先回到build目錄下,然後執行

make -j$(nproc)

5.extract錯誤

如果在make的時候報extract的錯誤,那麼就按照下面的步驟進行解決

  1. 解壓protobuf
    如果已經解壓了出現了protobuf1234的目錄,那麼就用這個
cp -rf protobuf1234/protobuf-3.11.4 third_party.protobuf

否則就自己解壓

tar -zxvf protobuf-cpp-3.11.4.tar.gz -C third_party.protobuf
  1. 修改cmake文件
vim third_party.protobuf-stamp/extract-third_party.protobuf.cmake

在第一行加

return()

然後再次回到build目錄進行make

make -j$(nproc)

我這邊是沒有再繼續保持,編譯成功過了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章