1. 安装过程基本遵循以下步骤
电脑端环境配置 - OriginBot智能机器人开源套件
需要注意以下两点:
1> 由于深度学习需要的包和镜像体积都比较大,所以虚拟机硬盘大小建议120GB
2> 虚拟机的网络适配器应该设置为桥接模式,如果使用NAT模式,会导致两个问题:
a. 不能接收到无人车发布的话题
b. docker pull 镜像的时候速度极慢
2. 在执行以下语句时,可能会报错:
thomas@J-35:~$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 11 ms: Connection refused
解决办法是修改 /etc/hosts文件,并添加以下内容
185.199.111.133 raw.githubusercontent.com
如果111也连接失败,可以试试108,109,110
3. 安装pytorch,需要先安装pip3
sudo apt install python3-pip
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
4. 安装Docker
安装命令如下
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
docker --version
执行 docker --version 显示安装完成
thomas@J-35:~/dev_ws$ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# Executing docker install script, commit: e5543d473431b782227f8908005543bb4389b8de
+ sudo -E sh -c 'apt-get update -qq >/dev/null'
+ sudo -E sh -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null'
+ sudo -E sh -c 'install -m 0755 -d /etc/apt/keyrings'
+ sudo -E sh -c 'curl -fsSL "https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg'
+ sudo -E sh -c 'chmod a+r /etc/apt/keyrings/docker.gpg'
+ sudo -E sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list'
+ sudo -E sh -c 'apt-get update -qq >/dev/null'
+ sudo -E sh -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin >/dev/null'
+ sudo -E sh -c 'docker version'
Client: Docker Engine - Community
Version: 26.0.0
API version: 1.45
Go version: go1.21.8
Git commit: 2ae903e
Built: Wed Mar 20 15:17:48 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 26.0.0
API version: 1.45 (minimum version 1.24)
Go version: go1.21.8
Git commit: 8b79278
Built: Wed Mar 20 15:17:48 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
================================================================================
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
dockerd-rootless-setuptool.sh install
Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
to root access on the host. Refer to the 'Docker daemon attack surface'
documentation for details: https://docs.docker.com/go/attack-surface/
================================================================================
thomas@J-35:~/dev_ws$ docker --version
Docker version 26.0.0, build 2ae903e
thomas@J-35:~/dev_ws$
安装完成后,通过如下命令,下载后续模型转换的工具链和docker镜像
- 下载AI工具链OE包(6.1GB)
wget -c ftp://vrftp.horizon.ai/Open_Explorer_gcc_9.3.0/2.3.3/horizon_xj3_open_explorer_v2.3.3_20220727.tar.gz
- 下载AI工具链docker(14.8GB)
wget -c ftp://vrftp.horizon.ai/Open_Explorer_gcc_9.3.0/2.3.3/x3pi_toolchain/ai_toolchain_2.3.3.tar.gz
安装 onnx, onnxruntime
pip install onnx
pip install onnxruntime
完成Docker环境安装后,需要将无root权限的用户添加到Docker用户组中。参考如下命令:
sudo groupadd docker
sudo gpasswd -a ${USER} docker # ${USER} 替换成用户名
sudo systemctl restart docker
设置docker 镜像加速
Docker 镜像加速 | 菜鸟教程
阿里云镜像获取地址:阿里云登录 - 欢迎登录阿里云,安全稳定的云计算服务平台
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://需要替换.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
检查加速器是否生效
thomas@J-35:~$ sudo docker info
Registry Mirrors:
https://owzy8hoh.mirror.aliyuncs.com/
如果想要顺利下载,还需要设置DNS,
sudo gedit /etc/resolv.conf
在打开的 /etc/resolv.conf 文件中,修改如下
# nameserver 127.0.0.53
# options edns0 trust-ad
# search localdomain
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 223.5.5.5
接下来可以拉取镜像了,
sudo docker pull openexplorer/ai_toolchain_centos_7_xj3:v2.3.3
由于镜像文件非常大,需要的时间会很长
thomas@J-35:~$ sudo docker pull openexplorer/ai_toolchain_centos_7_xj3:v2.3.3
[sudo] password for thomas:
v2.3.3: Pulling from openexplorer/ai_toolchain_centos_7_xj3
2d473b07cdd5: Pulling fs layer
fe1553a884e2: Pulling fs layer
c261b5a3ed6f: Pulling fs layer
e0a50bec6068: Pulling fs layer
b8f9004ba842: Pulling fs layer
da3f100e8139: Pulling fs layer
86c6394dc80d: Pull complete
77dfab50af93: Pull complete
11ad9bc2b57d: Pull complete
ea60e652960d: Pull complete
358249d1c41f: Pull complete
399e94555d0b: Pull complete
5a79f9ca312c: Pull complete
5c4200c51634: Pull complete
Digest: sha256:0e6b5e9d36e7cf6dbd8dfced9bb108b44e8d30ae77b6c4216ef5bf32c600eab4
Status: Downloaded newer image for openexplorer/ai_toolchain_centos_7_xj3:v2.3.3
docker.io/openexplorer/ai_toolchain_centos_7_xj3:v2.3.3
thomas@J-35:~$