Apollo学习001: 安装Apollo
本文旨在详细记录 Apollo在个人电脑的 Ubuntu 18.04 系统中的完整安装及运行过程。
硬件要求
百度Apollo系统正常需要安装在工业计算机IPC中,在个人电脑上也可以安装。由于网上没有查到具体的硬件要求,这里PO出个人笔记本电脑配置作为参考:电脑型号:神州战神z7m,CPU i7, 16G内存,GPU: GTX965m。实测可以跑通。(PS:Unbutu系统需要空间大一些,实测200个G的空间装完并且将Apollo完全编译后仅剩50G)
Apollo安装过程
安装Nvidia显卡驱动。
sudo apt-get update sudo apt-add-repository multiverse sudo apt-get update sudo apt-get install nvidia-driver-455
安装完毕采用
nvidia-smi
命令查看显卡:Wed Aug 25 21:55:21 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.73.01 Driver Version: 460.73.01 CUDA Version: 11.2 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 GeForce GTX 965M Off | 00000000:01:00.0 Off | N/A | | N/A 61C P0 N/A / N/A | 438MiB / 2002MiB | 25% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 1515 G /usr/lib/xorg/Xorg 216MiB | | 0 N/A N/A 1771 G /usr/bin/gnome-shell 26MiB | | 0 N/A N/A 3659 G ...AAAAAAAAA= --shared-files 16MiB | | 0 N/A N/A 4582 G ...AAAAAAAAA= --shared-files 133MiB | | 0 N/A N/A 7588 G ...AAAAAAAAA= --shared-files 7MiB | | 0 N/A N/A 10792 G ...AAAAAAAAA= --shared-files 27MiB | +-----------------------------------------------------------------------------+
安装docker
curl https://get.docker.com | sh sudo systemctl start docker && sudo systemctl enable docker
重启 Docker 守护进程以使改动生效:
sudo systemctl restart docker
完成 Docker 安装后,在终端中执行下述命令并重启系统,这样可以免去每次执行 Docker 命令时需要添加
sudo
的繁琐:sudo groupadd docker sudo usermod -aG docker your_username
安装nvidia工具包
如果是在物理机中安装的 Ubuntu,且机器配有 NVIDIA 显卡,在安装了驱动的前提下,还需要安装 NVIDIA 容器工具包以运行 Apollo Docker 镜像中的 CUDA:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get -y update sudo apt-get install -y nvidia-docker2
git clone源码
# 使用 SSH 的方式 git clone [email protected]:ApolloAuto/apollo.git # 使用 HTTPS 的方式 git clone https://github.com/ApolloAuto/apollo.git
Docker构建启动Apollo
进入到 Apollo 源码根目录,终端执行下述命令以启动 Apollo Docker 开发容器:
./docker/scripts/dev_start.sh
进入docker
./docker/scripts/dev_into.sh
容器中构建Apollo,
./apollo.sh build #若编译失败可多尝试几次,卡死可尝试 ./apollo.sh build_opt
启动Apollo
./scripts/bootstrap.sh start
上述命令会启动 DreamView 并使能模块监控机制,在浏览器中访问 http://localhost:8888 来显示 DreamView 界面。
踩坑记录
git clone Apollo仓库遇到错误
andre@andre-CN15S:~$ git clone git clone https://github.com/ApolloAuto/apollo.git
Cloning into 'apollo'...
remote: Enumerating objects: 2618, done.
remote: Counting objects: 100% (2618/2618), done.
remote: Compressing objects: 100% (1495/1495), done.
error: RPC failed; curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解决办法:
https://github.com/ApolloAuto...
Apollo执行 ./apollo.h build遇到错误
(16:20:38) ERROR: no such package '@com_github_grpc_grpc//bazel': java.io.IOException: Error downloading [https://apollo-system.cdn.bcebos.com/archive/6.0/v1.30.0.tar.gz, https://github.com/grpc/grpc/archive/v1.30.0.tar.gz] to /apollo/.cache/bazel/540135163923dd7d5820f3ee4b306b32/external/com_github_grpc_grpc/temp13334635335104087956/v1.30.0.tar.gz: Unknown host: github.com
(16:20:38) INFO: Elapsed time: 164.995s
(16:20:38) INFO: 0 processes.
(16:20:38) FAILED: Build did NOT complete successfully (0 packages loaded)
解决办法: 多编译几次 就好了
安装VS code并配置C++环境
VS code安装和配置参见: https://segmentfault.com/a/11...