-
Notifications
You must be signed in to change notification settings - Fork 41
/
Apollo_3.5启动perception模块.cpp
273 lines (168 loc) · 9.33 KB
/
Apollo_3.5启动perception模块.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// how to launch the perception module
reference:
https://github.com/ApolloAuto/apollo/blob/master/docs/howto/how_to_run_perception_module_on_your_local_computer.md
https://blog.csdn.net/max_loo/article/details/81304949
https://blog.csdn.net/davidhopper/article/details/85708221
https://blog.csdn.net/weixin_41803874/article/details/96568869
// essential
cuda版本,nvidia驱动版本,卡的型号
In this tutorial, it comes sucessfully with:
cuda-8.0,NVIDIA-384.130,rtx1070
1. In Ubuntu need to intsall nvidia driver
// 由于官方推荐安装NVIDIA-375版本的驱动 Apollo3.5 // 因为apollo镜像仅支持cuda8.0,不能使用太新版本的驱动程序
// 如果遇到内核编译失败的问题,很大可能是驱动版本的问题,使用ppa的安装方法,然后确定ppa下载的是那个版本的驱动。确定了版本号,就可以手动安装
///////////////////////////////////////
// 方法 1(各方法等效,出错了,可以多替代尝试)
// 首先看看自己Ubuntu内核支持到哪个版本的驱动
sudo apt-cache search nvidia*
// 如果安装的是官网下载的驱动,则重新运行run文件来卸载
sh ./nvidia.run --uninstall
// 卸载已存在驱动版本(可选)
sudo apt-get remove --purge nvidia*
// 卸载已存在驱动版本(可选)
nvidia-uninstall
Installing NVIDIA GPU Driver
The Apollo runtime in the vehicle requires the NVIDIA GPU Driver. You must install the NVIDIA GPU driver with specific options.
Download the installation files
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/375.39/NVIDIA-Linux-x86_64-375.39.run
Start the driver installation
sudo bash ./NVIDIA-Linux-x86_64-375.39.run --no-x-check -a -s --no-kernel-module
// 查看显卡驱动是否安装成功
nvidia-smi
//In docker, nvidia-smi
///////////////////////////////////////
// 方法 2(各方法等效,出错了,可以多替代尝试)
# 查看Docker当前驱动,没装过应该是没有
sudo dpkg --list | grep nvidia-*
# 如果已经安装过,并且与主机不符,需要先卸载老版本
sudo apt-get remove nvidia-xxx
# 启动并进入Docker
bash docker/scripts/dev_start.sh -C
bash docker/scripts/dev_into.sh
# 更新安装源
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
# 查看并安装NVIDIA显卡驱动
# 此处的版本号要与Docker外部一致!
apt search nvidia-430
sudo apt install nvidia-430
# 查看显卡驱动是否安装成功
nvidia-smi
2. cuda-8.0 has been installed previously in docker. If the cuda-10.0 is not needed, ignore this step.
// cuda is linked to cuda8.0
// install cuda, the .run file is download from nvidia website
sudo ./cuda_10.1.168_418.67_linux.run
Please make sure that
- PATH includes /usr/local/cuda-10.1/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-10.1/lib64, or, add /usr/local/cuda-10.1/lib64 to /etc/ld.so.conf and run ldconfig as root
//配置到环境变量(不同环境下,配置不同环境变量,可以使用多个cuda版本)
sudo gedit ~/.bashrc
打开文件后在文件末尾添加路径,也就是安装目录,命令如下:
export PATH=/usr/local/cuda-10.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-10.0
source ~/.bashrc
sudo rm -rf cuda
sudo ln -s /usr/local/cuda-8.0/ /usr/local/cuda
ls /usr/local/cuda
nvcc -V
//cudnn
//. the cuDNN library installation path is /usr/lib/x86_64-linux-gnu/
依照自己先前下載CUDA的版本,選擇配合的cuDNN版本,將三個deb檔案都下載下來,分別再執行
$ sudo dpkg -i libcudnn7_7.1.4.18-1+cuda8.0_amd64.deb
$ sudo dpkg -i libcudnn7-dev_7.1.4.18-1+cuda8.0_amd64.deb
$ sudo dpkg -i libcudnn7-doc_7.1.4.18-1+cuda8.0_amd64.deb
// docker copy
docker cp /home/zy/Downloads/libcudnn7-dev_7.1.4.18-1+cuda8.0_amd64.deb b7544a6273e0:/apollo
# test cuda and cudnn
cuda-install-samples-8.0.sh ~
cd ~/NVIDIA_CUDA-8.0_Samples/0_Simple/cdpSimplePrint
make ./cdpSimplePrint
// build apollo with gpu
./apollo.sh build_gpu
// without debug information
./apollo.sh build_opt_gpu
// errors due to the lack of cudnn
ERROR: (08-14 00:21:08.409) /apollo/modules/perception/base/BUILD:127:1: Linking of rule '//modules/perception/base:common_test' failed (Exit 1).
/usr/bin/ld: cannot find -lnppi
/usr/bin/ld: cannot find -lnppi
3. commit the docker image
docker commit container_id apolloauto/apollo:tag_name
// container_id用docker ps -l查看, tag_name自己取名字。该命令用于将已基于源镜像更改的内容保存成新的镜像
In docker:
主机端:
cd apollo#主机到阿波罗的根目录
sudo bash docker/scripts/dev_start.sh -l -t tag_name#(对应之前commit的tag名称)
sudo bash docker/scripts/dev_into.sh
4. // if it tells some error about the camera intrinsic
// obs_sensor_intrinsic_path=/apollo/modules/perception/data/params
mkdir /apollo/modules/perception/data/params/
zy@in_dev_docker:/apollo$ sudo cp -r /apollo/modules/perception/production/data/perception/camera/params/. /apollo/modules/perception/data/params/
5. // launch the perception module
source scripts/apollo_base.sh
cyber_launch start /apollo/modules/perception/production/launch/perception.launch
// if below two commands give the "segmentation fault", one way to dag into the problem is the core dump file. Use the gdb tool to find which line generates error.
// mostly,it is due to driver unmathch
mainboard -d /apollo/modules/perception/production/dag/dag_streaming_perception.dag
mainboard -d /apollo/modules/perception/production/dag/dag_streaming_perception_camera.dag -p perception -s CYBER_DEFAUL
// gdb debug:
gdb -q /apollo/bazel-bin/cyber/mainboard /apollo/data/core/core_mainboard.16227
#0 0x00007fb3be0f8280 in apollo::perception::inference::RTNet::Init (this=0x20c2e00, shapes=...)
at modules/perception/inference/tensorrt/rt_net.cc:634
634 context_ = engine->createExecutionContext();
6. // warnings:
[perception] [NVBLAS] NVBLAS_CONFIG_FILE environment variable is NOT set : relying on default config filename 'nvblas.conf'
[perception] [NVBLAS] Cannot open default config file 'nvblas.conf'
[perception] [NVBLAS] Config parsed
[perception] [NVBLAS] CPU Blas library need to be provided
// how to slove warnings
export NVBLAS_CONFIG_FILE=/usr/local/cuda
export NVBLAS_CONFIG_FILE=/usr/local/cuda/nvblas.conf
zy@in_dev_docker:/usr/local/cuda$ sudo touch nvblas.conf
zy@in_dev_docker:/usr/local/cuda$ vim nvblas.conf // put_in: NVBLAS_CPU_BLAS_LIB /usr/lib/libopenblas.so
7. 可执行一个demo检查是否成功编译GPU版本的APOLLO
./bazel-bin/modules/perception/camera/test/camera_lib_obstacle_detector_yolo_region_output_test
//若出现 error while loading shared libraries: libcuda.so.1: cannot open shared object file: No such file or directory ,之类的错误提示,则说明docker 或者主机的NVIDIA驱动未正确安装
8. 直接运行所有测试
./apollo.sh test
9. how to run demo?
source scripts/apollo_base.sh
cyber_launch start /apollo/modules/dreamview/launch/dreamview.launch
cyber_recorder play -f docs/demo_guide/demo_3.5.record --loop
10
. E0819 14:59:31.854367 22746 hdmap_input.cc:92] [mainboard] Failed to find hadmap file: /apollo/modules/map/data/fourlanes/base_map.bin
//
modules/common/data/global_flagfile.txt
--map_dir=/apollo/modules/map/hdmap/test-data
///////////////////////////////
/apollo/modules/perception/map/hdmap/hdmap_input.cc
hdmap_file_ = apollo::common::util::StrCat(FLAGS_map_dir, "/base_map.xodr");
Difference between base_map, routing_map and sim_map
base_map is the most complete map that has all roads, lane geometry and labels. The other maps are generated based on base_map.
// routing_map has the topology of the lanes in base_map. It can be generated by command:
dir_name=modules/map/data/demo # example map directory
./scripts/generate_routing_topo_graph.sh --map_dir ${dir_name}
// sim_map is a light weight version of base_map for dreamview visualization. It has reduced data density for better runtime performance. It can be generated by command:
dir_name=modules/map/data/demo # example map directory
bazel-bin/modules/map/tools/sim_map_generator --map_dir=${dir_name} --output_dir=${dir_name}
/apollo/modules/common/configs/config_gflags.cc
DEFINE_string(base_map_filename, "base_map.bin|base_map.xml|base_map.txt|base_map.xodr|base_map.odr", "Base map files in the map_dir, search in order.");
root@apollo5-apollo-ubuntu14-1:/apollo# find -name "kk.sh"
./scripts/kk.sh
apollo/modules/common/data/global_flagfile.txt
--map_dir=/apollo/modules/map/data/sunnyvale_with_two_offices
11.
// cyber_recorder
// 录制
root@apollo5-apollo-ubuntu14-1:/apollo# cyber_recorder record -a
// 查看录制信息
root@apollo5-apollo-ubuntu14-1:/apollo# cyber_recorder info 20190819115806.record.00002
// 回放和暂停
root@apollo5-apollo-ubuntu14-1:/apollo# cyber_recorder play -f 20190819115806.record.00002
// 查看channel
root@apollo5-apollo-ubuntu14-1:/apollo# cyber_channel list
// 查看channel的内容
cyber_channel echo /apollo/planning
cyber_channel echo /apollo/perception/obstacles
// 回放和暂停
root@apollo5-apollo-ubuntu14-1:/apollo# cyber_recorder play -f 20190819115806.record.00002