# PilotOSInit **Repository Path**: oemsys/pilotosinit ## Basic Information - **Project Name**: PilotOSInit - **Description**: openpilot操作系统配置 - **Primary Language**: Shell - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 8 - **Created**: 2025-12-23 - **Last Updated**: 2025-12-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # OP环境配置 ## **快速配置命令:** [安装视频](https://gitee.com/huheas/pilotosinit/raw/master/install.mp4) (视频不含GPU驱动安装,如果要使用GPU加速要先安装好驱动再编译OP,如果后装驱动**要重新编译**) ### 1、下载原码 链接: https://pan.baidu.com/s/1nAmXfgMTmYEtvFvFAtmNIw?pwd=dqq8 ``` Sunnypilot MM-X分支:sunnypilot-pc_src.tar.gz Sunnypilot yysnet分支:sunnypilot_yysnet_src.tar.gz Openpilot官方版本:openpilot_src.tar.gz ``` 将下载的压缩包解释到/data目录下,没有自行创建,如果放置在其他目录,后续操作文件的路径换成相应的路径即可。如果需要最新原码,使用git更新(要解决梯子问题)。 ### 2、替换操作系统为国内源 备份原始源文件 ``` sudo mv /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak ``` 以下为1条命令,全部一起复制粘贴到终端运行,该命令会提示输入当前用户的密码并确认用户有sudo权限和密码正确,否则会提示无权限。 ``` sudo bash -c 'cat < /etc/apt/sources.list.d/ubuntu.sources Types: deb URIs: https://mirrors.aliyun.com/ubuntu/ Suites: noble noble-updates noble-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIs: https://mirrors.aliyun.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg EOF' ``` ### 3、python配置 ``` export UV_Installer_GHE__Base_URL="https://ghfast.top/https://github.com" export UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple export EXTRA_INDEX_URL=https://mirrors.aliyun.com/pypi/simple export UV_HTTP_TIMEOUT=600 export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple export PIP_TRUSTED_HOST=mirrors.aliyun.com ``` ### 4、安装OpenCL驱动 Sunnypilot新版本的代码默认GPU推理,必须先安装对应GPU的OpenCL驱动,否则无法编译。 解决方法: - AMD的显卡按下面的第五步的方法安装驱动 - 其他显卡参考对应品牌的方法安装驱动 - 安装CPU OpenCL驱动pocl-opencl-icd(只是绕过编译,如果CPU算力不够最后还是无法使用的,会报skipping model eval.Dropped X frames或帧率低) ### 5、安装与运行op 从网盘下载的代码已包含了LFS对象,但安装时会执行git lfs pull进行更新,如果有网络问题将会导致安装失败,可以将更新代码注释,如果要更新先解决梯子问题 文件位置:/data/sunnypilot-pc/tools/op.sh ``` # echo "Pulling git lfs files..." # st="$(date +%s)" # if ! git lfs pull; then # echo -e " ↳ [${RED}✗${NC}] Pulling git lfs files failed!" # loge "ERROR_GIT_LFS" # return 1 # fi ``` ``` # 进入OP目录 cd openpilot(或sunnypilot、sunnypilot-pc) # 安装依赖环境 tools/op.sh setup # 报文件问题,需要修改UV.lock文件 # 进入OP虚拟环境 tools/op.sh venv # 编译OP tools/op.sh build # 启动OP,ROAD_CAM指定摄像头,NO_DM驾驶监控开关(注意安全驾驶,关闭驾驶监控仅用测试,正常驾驶请打开驾驶监控功能) USE_WEBCAM=1 ROAD_CAM=0 NO_DM=0 system/manager/manager.py ``` ### 5、剩下按下面第七步开始配置   # 想了解原理可以往下看   ### 一、UV安装和源配置 1. **设置UV环境变量**: ``` export UV_INSTALLER_GHE__Base_URL="https://ghfast.top/https://github.com" ``` - **说明**:指定UV工具使用GitHub代理地址安装。 2. **更换UV源**: ``` export UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple export EXTRA_INDEX_URL=https://mirrors.aliyun.com/pypi/simple ``` - **说明**:配置UV使用国内阿里云的PyPI镜像源,加速软件包下载。 3. **调整超时时间**: ``` export UV_HTTP_TIMEOUT=600 ``` - **说明**:将HTTP请求的超时时间设置为600秒,避免因网络延迟导致下载失败。 - **注意事项**:根据实际网络情况,可适当调整超时时间。 4. **手动安装**: 如果上述无法安装,可以从百度网盘下载uv-x86-64-unknown-linux-gnu-0.6.14.tar.gz,执行以下命令安装: ``` tar zxvf uv-x86-64-unknown-linux-gnu-0.6.14.tar.gz -C ~ ``` ### 二、更换APT源 1. **备份现有源文件**: ``` sudo mv /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak ``` - **说明**:备份当前的APT源配置,以防万一需要恢复。 2. **设置新的APT源**: 拷贝以下命令替换ubuntu.sources: ``` sudo bash -c 'cat < /etc/apt/sources.list.d/ubuntu.sources Types: deb URIs: https://mirrors.aliyun.com/ubuntu/ Suites: noble noble-updates noble-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIs: https://mirrors.aliyun.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg EOF' ``` - **说明**:使用阿里云镜像站作为新的APT源,加速软件包下载。 3. **更新APT缓存列表索引**: ``` apt update -y ``` - **说明**:更新APT包列表缓存。 ### 三、设置pip镜像源 1. **配置pip使用国内镜像**: ``` export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple export PIP_TRUSTED_HOST=mirrors.aliyun.com ``` - **说明**:更换pip默认使用阿里云的PyPI镜像,加速第三方包的安装。 - **注意事项**:可以通过`pip config list`检查配置是否生效。 ### 四、环境变量(永久配置) 除了APT配置外,其他环境变量(如UV和pip的配置)在关闭当前终端或者切换用户后会失效。如果希望这些设置长期有效,可以将它们添加到对应用户的~/.bashrc文件中: ``` echo 'export UV_Installer_GHE__Base_URL="https://ghfast.top/https://github.com"' >> ~/.bashrc echo 'export UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple' >> ~/.bashrc echo 'export EXTRA_INDEX_URL=https://mirrors.aliyun.com/pypi/simple' >> ~/.bashrc echo 'export UV_HTTP_TIMEOUT=600' >> ~/.bashrc echo 'export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple' >> ~/.bashrc echo 'export PIP_TRUSTED_HOST=mirrors.aliyun.com' >> ~/.bashrc source ~/.bashrc ``` ### 五、GPU驱动安装 - AMD ``` # 下载安装包: wget https://repo.radeon.com/amdgpu-install/6.3.4/ubuntu/noble/amdgpu-install_6.3.60304-1_all.deb # 安装驱动: sudo dpkg -i amdgpu-install_6.3.60304-1_all.deb # usecase不要使用默认,避免导致显卡异常 sudo amdgpu-install --usecase=opencl --accept-eula sudo apt install clinfo darktable # 增加当前用户到render和video组 sudo usermod -a -G render $LOGNAME sudo usermod -a -G video $LOGNAME # 检查opencl是否正确 clinfo -l Platform #0: AMD Accelerated Parallel Processing -- Device #0: gfx90c:xnack+ #Device必须要看到有设备 # 参考文档:https://amdgpu-install.readthedocs.io/en/latest/ ``` - Intel ``` #Gen12以前的CPU只能24.35.30872.22以前的版本 #下载Intel compute-runtime安装包: mkdir neo && cd neo wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17537.20/intel-igc-core_1.0.17537.20_amd64.deb wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.17537.20/intel-igc-opencl_1.0.17537.20_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/24.35.30872.22/intel-level-zero-gpu-legacy1_1.3.30872.22_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/24.35.30872.22/intel-level-zero-gpu_1.3.30872.22_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/24.35.30872.22/intel-opencl-icd-legacy1_24.35.30872.22_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/24.35.30872.22/intel-opencl-icd_24.35.30872.22_amd64.deb wget https://github.com/intel/compute-runtime/releases/download/24.35.30872.22/libigdgmm12_22.5.0_amd64.deb #安装软件包: sudo dpkg -i *.deb sudo apt install ocl-icd-libopencl1 clinfo darktable #检查opencl是否正确 #可通过clinfo或darktable-cltest检查opencl是否正常 #参考文档 #https://github.com/intel/compute-runtime/releases ``` - Nvidia ``` #下载安装包 wget https://us.download.nvidia.com/XFree86/Linux-x86_64/570.133.07/NVIDIA-Linux-x86_64-570.133.07.run #安装驱动 chmod +x NVIDIA-Linux-x86_64-570.133.07.run ./NVIDIA-Linux-x86_64-570.133.07.run --accept-license --silent --no-nouveau-check --disable-nouveau sudo apt install clinfo darktable #检查opencl是否正确 #可通过clinfo或darktable-cltest检查opencl是否正常 #参考文档: #https://docs.nvidia.com/datacenter/tesla/pdf/NVIDIA_Driver_Installation_Quickstart.pdf ``` - **不要安装```pocl-opencl-icd```** - 如果安排错驱动一定要把对应厂家OpenCL相关卸载干净,不然会有相互影响导致OP无法正确识别哪个是可用的OpenCL设备 - 修改CPU或GPU推理类型后要**重新编译代码,重新编译代码,重新编译代码** - 如果无法确认新驱动是否生效可以尝试先**重启**再进行验证 ### 六、安装Openpilot 从网盘下载的代码已包含了LFS对象,但安装时会执行git lfs pull进行更新,如果有网络问题将会导致安装失败,可以将更新代码注释,如果要更新先解决梯子问题 文件位置:/data/sunnypilot-pc/tools/op.sh ``` # echo "Pulling git lfs files..." # st="$(date +%s)" # if ! git lfs pull; then # echo -e " ↳ [${RED}✗${NC}] Pulling git lfs files failed!" # loge "ERROR_GIT_LFS" # return 1 # fi ``` ``` # 进入OP目录 cd openpilot(或sunnypilot、sunnypilot-pc) # 安装依赖环境 tools/op.sh setup # 进入OP虚拟环境 tools/op.sh venv # 编译OP tools/op.sh build ``` 参考链接: - https://bgithub.xyz/commaai/openpilot/blob/master/tools/README.md ### 七、启动Openpilot ``` # 进入OP目录 cd openpilot(或sunnypilot、sunnypilot-pc) # 进入OP虚拟环境 tools/op.sh venv # 启动OP,ROAD_CAM指定摄像头,NO_DM驾驶监控开关(注意安全驾驶,关闭驾驶监控仅用测试,正常驾驶请打开驾驶监控功能) USE_WEBCAM=1 ROAD_CAM=0 NO_DM=0 system/manager/manager.py ``` 参考链接: - https://bgithub.xyz/commaai/openpilot/tree/master/tools/webcam ### 八、GPU配置 注:最新的代码默认是GPU(opencl)不需要修改 文件位置:/data/sunnypilot-pc/selfdrive/modeld/modeld.py ``` if TICI: from openpilot.selfdrive.modeld.runners.tinygrad_helpers import qcom_tensor_from_opencl_address os.environ['QCOM'] = '1' else: os.environ['GPU'] = '1' # 启用GPU(opencl)加速 ``` 文件位置:/data/sunnypilot-pc/selfdrive/modeld/SConscript ``` if arch == 'larch64': device_string = 'QCOM=1' elif arch == 'Darwin': device_string = 'CLANG=1 IMAGE=0' else: device_string = 'GPU=1 BEAM=0 IMAGE=0' # 确保使用GPU(opencl) ``` 参考文档:https://github.com/commaai/tinygrad/tree/70266e9f94d5a247ccbb2f3a46e72a2fbdaf7a8e ### 九、摄像头校对 GMLCCalibration for Win摄像头标定查看焦距,可以从百度网盘下载:GMLCCalibration.zip 用摄像头拍棋盘的标定照片,从8个方向(上下、左右、4个角)拍摄的照片用于焦距标定 ![输入图片说明](a06f62e86a2e8d2e861447e6a070328b.png) ### 十、调整OP摄像头画面 文件位置:/data/sunnypilot-pc/tools/webcam/camera.py ``` def _configure_camera_format(self, target_fourcc): """尝试设置摄像头的FourCC格式""" fourcc = cv2.VideoWriter_fourcc(*target_fourcc) self.cap.set(cv2.CAP_PROP_FOURCC, fourcc) self.cap.set(cv2.CAP_PROP_FOURCC, fourcc) self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920) # 分辨率,宽度 self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080) # 分辨率,高度 self.cap.set(cv2.CAP_PROP_FPS, 20) # 帧率 ``` 文件位置:/data/sunnypilot-pc/common/transformations/camera.py ``` _ar_ox_config = DeviceCameraConfig(CameraConfig(1920, 1080, 2740.503.0), _ar_ox_fisheye, _ar_ox_fisheye) #(宽,高,焦距) ``` ### 十一、调整UI画面显示 文件位置:/data/sunnypilot-pc/selfdrive/ui/ui.h ``` const Eigen::Matrix3f FCAM_INTRINSIC_MATRIX = (Eigen::Matrix3f() << 2648.0, 0.0, 1920.0 / 2, # 分辨率宽度 0.0, 2470.503, 1080.0 / 2, # 分辨率高度 0.0, 0.0, 1.0).finished(); ``` **重新编译代码****重新编译代码****重新编译代码** ``` # 进入OP虚拟环境 tools/op.sh venv # 编译OP tools/op.sh build ``` ### 十二、快捷栏图标及自启动 启动脚本在网盘里面:sunnypilot.desktop,autostart_lauch_pc.sh.desktop,lauch_pc.sh,logo.ico 将上面4个文件拷贝到相应的位置,其他用户和OP路径不一样请自行替换 ``` #增加快捷栏图标 cp logo.ico /home/$LOGNAME/ cp sunnypilot.desktop /usr/share/applications/ chmod +x /usr/share/applications/sunnypilot.desktop #增加启动脚本 cp lauch_pc.sh /home/$LOGNAME/ chmod +x /home/$LOGNAME/lauch_pc.sh #增加开机启动脚本 cp autostart_launch_pc.sh.desktop /home/$LOGNAME/.config/autostart/ chmod +x /home/$LOGNAME/.config/autostart/autostart_lauch_pc.sh.desktop #去掉sudo密码认证 echo "$LOGNAME ALL=NOPASSWD: ALL" |sudo tee -a /etc/sudoers ```