iT邦幫忙

0

建置tensorrt_demos遭遇的makefile問題

css 2022-12-07 20:49:16867 瀏覽
  • 分享至 

  • xImage

想利用TensorRT來加速YOLOV4 Model,按網路上使用tensorrt_demos\plugins\下的Makefile將相關的程式build起來

# space separated compute values ex: computes=70 75. If not present will fetch device's CC
computes=70 75

ifeq ($(computes), )
  computes= $(shell python gpu_cc.py)
  $(info computes: $(computes))
endif

NVCCFLAGS= $(foreach compute, $(computes),-gencode arch=compute_$(compute),code=[sm_$(compute),compute_$(compute)])
$(info NVCCFLAGS: $(NVCCFLAGS))

# These are the directories where I installed TensorRT on my x86_64 PC.
#TENSORRT_INCS=-I"/usr/local/TensorRT-7.1.3.4/include 原作者"
#TENSORRT_LIBS=-L"/usr/local/TensorRT-7.1.3.4/lib 原作者"
TENSORRT_INCS=-I"C:/TensorRT-8.5.1.7/include" #我修改
TENSORRT_LIBS=-L"C:/TensorRT-8.5.1.7/lib" #我修改

# INCS and LIBS
#INCS=-I"/usr/local/cuda/include" $(TENSORRT_INCS) -I"/usr/local/include" -I"plugin 原作者"
#LIBS=-L"/usr/local/cuda/lib64" $(TENSORRT_LIBS) -L"/usr/local/lib" -Wl,--start-group -lnvinfer -lnvparsers -lnvinfer_plugin -lcudnn -lcublas -lnvToolsExt -lcudart -lrt -ldl -lpthread -Wl,--end-group 原作者
INCS=-I"C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v11.8/include" $(TENSORRT_INCS) -I "C:/MinGW/include"  -I "plugin" #我修改
LIBS=-L"C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v11.8/lib/x64" $(TENSORRT_LIBS) -L "C:/MinGW/lib"  -Wl,--start-group -lnvinfer -lnvparsers -lnvinfer_plugin -lcudnn -lcublas -lnvToolsExt -lcudart -lrt -ldl -lpthread -Wl,--end-group #我修改

.PHONY: all clean

all: libyolo_layer.so

clean:
	rm -f *.so *.o

libyolo_layer.so: yolo_layer.o
	$(CC) -shared -o $@ $< $(LIBS)

yolo_layer.o: yolo_layer.cu yolo_layer.h
	$(NVCC) -allow-unsupported-compiler -ccbin $(CC) $(INCS) $(NVCCFLAGS) -Xcompiler -fPIC -c -o $@ $<

網路上的介紹皆是在Linux模式下執行,但不知是否因為我在WINDOWS下指令模式執行,在修正相關路徑語法有出入,造成make後出錯:

PS D:\project\C++project\tensorrt_demos\plugins> make
NVCCFLAGS: -gencode arch=compute_70,code=[sm_70,compute_70] -gencode arch=compute_75,code=[sm_75,compute_75]
nvcc   -allow-unsupported-compiler -ccbin g++ -I"C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v11.8/include" -I"C:/TensorRT-8.5.1.7/include" -I "C:/MinGW/include"  -I "plugin" -gencode arch=compute_70,code=[sm_70,compute_70] -gencode arch=compute_75,code=[sm_75,compute_75] -Xcompiler -fPIC -c -o yolo_layer.o yolo_layer.cu
yolo_layer.cu
g++: error: cuda_runtime.h: No such file or directory
g++: error: unrecognized command line option '-nologo'
g++: error: unrecognized command line option '-EHsc'
Makefile:41: recipe for target 'yolo_layer.o' failed
make: *** [yolo_layer.o] Error 1

我確定cuda_runtime.h是是在

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include

無誤,所以按照MakeFile的語法我寫成:

C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v11.8/include

不知道是不是語法何處錯誤造成找不到檔案

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
re.Zero
iT邦研究生 5 級 ‧ 2022-12-08 18:16:01
最佳解答

因為你的路徑字串是以雙引號含括,移除左斜線(\)後試試。 (參考)

css iT邦新手 5 級 ‧ 2022-12-08 19:33:00 檢舉

恩!! 按照您的說的思路,我將" "拿掉就可以了,感謝!!

INCS=-I/C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v11.8/include $(TENSORRT_INCS) -I"/C:/MinGW/include" -I"plugin"

我要發表回答

立即登入回答