前言
- 试用ubuntu20.04安装昇腾的驱动和cann的时,出现如下问题:
(base) root@ubuntu:/home/work# ./Ascend-hdk-910-npu-driver_23.0.rc3_linux-aarch64.run --full
Verifying archive integrity... 100% SHA256 checksums are OK. All good.
Uncompressing ASCEND DRIVER RUN PACKAGE 100%
[Driver] [2023-12-11 08:07:46] [INFO]Start time: 2023-12-11 08:07:46
[Driver] [2023-12-11 08:07:46] [INFO]LogFile: /var/log/ascend_seclog/ascend_install.log
[Driver] [2023-12-11 08:07:46] [INFO]OperationLogFile: /var/log/ascend_seclog/operation.log
[Driver] [2023-12-11 08:07:46] [INFO]base version is none.
[Driver] [2023-12-11 08:07:46] [WARNING]Do not power off or restart the system during the installation/upgrade
[Driver] [2023-12-11 08:07:47] [INFO]set username and usergroup, HwHiAiUser:HwHiAiUser
[Driver] [2023-12-11 08:07:49] [INFO]driver install type: DKMS
[Driver] [2023-12-11 08:07:49] [INFO]upgradePercentage:10%
[Driver] [2023-12-11 08:07:54] [INFO]upgradePercentage:30%
[Driver] [2023-12-11 08:07:54] [INFO]upgradePercentage:40%
[Driver] [2023-12-11 08:09:56] [ERROR]Dkms install failed, details in : /var/log/ascend_seclog/ascend_install.log
[Driver] [2023-12-11 08:09:56] [ERROR]Driver_ko_install failed, details in : /var/log/ascend_seclog/ascend_install.log
[Driver] [2023-12-11 08:09:56] [INFO]Failed to install driver package, please retry after uninstall and reboot!
[Driver] [2023-12-11 08:09:56] [INFO]End time: 2023-12-11 08:09:56
大概率是内核版本不对导致。目前昇腾的底层驱动和应用程序的配套如下图所示:
使用uname -r 命令查看当前的内核版本
root@ubuntu:~# uname -r
5.4.0-169-generic
不满足5.4.0-26-generic的要求,如果强行安装驱动,会出现第一步的报错问题。
安装内核
- 首先使用如下命令安装内核:
apt-get install linux-image-5.4.0-26-generic linux-headers-5.4.0-26-generic linux-modules-5.4.0-26-generic
- 使用命令: dpkg --get-selections | grep linux- 查看已经安装的内核:
linux-base install
linux-firmware install
linux-generic install
linux-headers-5.4.0-169 install
linux-headers-5.4.0-169-generic install
linux-headers-5.4.0-26 install #已安装
linux-headers-5.4.0-26-generic install
linux-headers-generic install
linux-image-5.4.0-169-generic install
linux-image-5.4.0-26-generic install #已安装
linux-image-generic install
linux-modules-5.4.0-169-generic install
linux-modules-5.4.0-26-generic install #已安装
linux-modules-extra-5.4.0-169-generic install
- 设置不更新该版本的内核:
希望以后不再更新内核,则使用命令将此内核锁住,保证以后不再自动升级内核
命令:apt-mark hold linux-image-5.4.0-26-generic linux-headers-5.4.0-26-generic linux-modules-5.4.0-26-generic
结果:
root@ubuntu:~# dpkg --get-selections | grep linux-
linux-base install
linux-firmware install
linux-generic install
linux-headers-5.4.0-169 install
linux-headers-5.4.0-169-generic install
linux-headers-5.4.0-26 install
linux-headers-5.4.0-26-generic hold # hold
linux-headers-generic install
linux-image-5.4.0-169-generic install
linux-image-5.4.0-26-generic hold
linux-image-generic install
linux-modules-5.4.0-169-generic install
linux-modules-5.4.0-26-generic hold
linux-modules-extra-5.4.0-169-generic install
修改启动项
- 使用命令grep ‘menuentry’ /boot/grub/grub.cfg 查看现有已安装的内核
结果:
root@ubuntu:~# grep 'menuentry' /boot/grub/grub.cfg
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-64b5492d-6f43-4560-9d6e-0ada8fb69264' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-64b5492d-6f43-4560-9d6e-0ada8fb69264' {
menuentry 'Ubuntu, with Linux 5.4.0-169-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-169-generic-advanced-64b5492d-6f43-4560-9d6e-0ada8fb69264' {
menuentry 'Ubuntu, with Linux 5.4.0-169-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-169-generic-recovery-64b5492d-6f43-4560-9d6e-0ada8fb69264' {
$menuentry_id_option 'gnulinux-5.4.0-26-generic-advanced-64b5492d-6f43-4560-9d6e-0ada8fb69264' {
menuentry 'Ubuntu, with Linux 5.4.0-26-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-26-generic-recovery-64b5492d-6f43-4560-9d6e-0ada8fb69264' {
menuentry 'Ubuntu 20.04 LTS (20.04) (on /dev/sdb2)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-0eb7b5f0-729d-4b4c-8ed7-48b8e6189ed6' {
submenu 'Advanced options for Ubuntu 20.04 LTS (20.04) (on /dev/sdb2)' $menuentry_id_option 'osprober-gnulinux-advanced-0eb7b5f0-729d-4b4c-8ed7-48b8e6189ed6' {
menuentry 'Ubuntu (on /dev/sdb2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-5.4.0-169-generic--0eb7b5f0-729d-4b4c-8ed7-48b8e6189ed6' {
menuentry 'Ubuntu, with Linux 5.4.0-169-generic (on /dev/sdb2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-5.4.0-169-generic--0eb7b5f0-729d-4b4c-8ed7-48b8e6189ed6' {
menuentry 'Ubuntu, with Linux 5.4.0-169-generic (recovery mode) (on /dev/sdb2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-5.4.0-169-generic-root=UUID=0eb7b5f0-729d-4b4c-8ed7-48b8e6189ed6 ro recovery nomodeset-0eb7b5f0-729d-4b4c-8ed7-48b8e6189ed6' {
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
root@ubuntu:~#
查到从menuentry ‘Ubuntu, with Linux 5.4.0-26-generic’ --class ubuntu --class gnu-linux --class gnu --class os ,获取到’Ubuntu, with Linux 5.4.0-26-generic
- 修改启动项
打开 vi /etc/default/grub
# GRUB_DEFAULT=0 # 注释这行
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-26-generic" # Ubuntu, with Linux 5.4.0-26-generic由上一个查出的
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
- 更新grub设置
执行命令:update-grub
结果:
root@ubuntu:~# sudo update-grub
\Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-169-generic
Found initrd image: /boot/initrd.img-5.4.0-169-generic
Found linux image: /boot/vmlinuz-5.4.0-26-generic ## 这行执行成功
Found initrd image: /boot/initrd.img-5.4.0-26-generic ## 这行成功
Found Ubuntu 20.04 LTS (20.04) on /dev/sdb2
Adding boot menu entry for UEFI Firmware Settings
done
安装昇腾驱动和CANN包
相关下载网站:
昇腾社区:www.hiascend.com
驱动下载:https://www.hiascend.com/hardware/firmware-drivers
CANN下载:https://www.hiascend.com/software/cann
CANN安装指导文档:https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/700alpha001/softwareinstall/instg/instg_000021.html
清华软件源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/ # 下载开源的依赖软件(python)
1、安装依赖环境
软件环境依赖安装:
apt-get install -y gcc g++ make cmake zlib1g zlib1g-dev openssl libsqlite3-dev libssl-dev libffi-dev libbz2-dev libxslt1-dev unzip pciutils net-tools libblas-dev gfortran libblas3
apt-get install libgl1-mesa-glx
2、按住Python3.9.x
# 执行下载的miniconda脚本进行安装:
bash ./Miniconda3-py39_23.9.0-0-Linux-aarch64.sh
安装python依赖:
pip3 install attrs pandas numpy decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py pyyaml opencv-python setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple/
3、安装HwHiAiUser用户
在命令行分别执行如下命令:
groupadd HwHiAiUser
useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash
4、安装驱动
bash ./Ascend-hdk-910-npu-driver_23.0.rc3_linux-aarch64.run --full
安装成功提示:
(base) root@ubuntu:/home/work/dri# bash ./Ascend-hdk-910-npu-driver_23.0.rc3_linux-aarch64.run --full
Verifying archive integrity... 100% SHA256 checksums are OK. All good.
Uncompressing ASCEND DRIVER RUN PACKAGE 100%
[Driver] [2023-12-11 15:08:52] [INFO]Start time: 2023-12-11 15:08:52
[Driver] [2023-12-11 15:08:52] [INFO]LogFile: /var/log/ascend_seclog/ascend_install.log
[Driver] [2023-12-11 15:08:52] [INFO]OperationLogFile: /var/log/ascend_seclog/operation.log
[Driver] [2023-12-11 15:08:52] [WARNING]Do not power off or restart the system during the installation/upgrade
[Driver] [2023-12-11 15:08:52] [INFO]set username and usergroup, HwHiAiUser:HwHiAiUser
[Driver] [2023-12-11 15:08:54] [INFO]driver install type: Direct
[Driver] [2023-12-11 15:08:54] [INFO]upgradePercentage:10%
[Driver] [2023-12-11 15:08:59] [INFO]upgradePercentage:30%
[Driver] [2023-12-11 15:08:59] [INFO]upgradePercentage:40%
[Driver] [2023-12-11 15:09:01] [INFO]upgradePercentage:90%
[Driver] [2023-12-11 15:09:01] [INFO]Waiting for device startup...
[Driver] [2023-12-11 15:09:08] [INFO]Device startup success
[Driver] [2023-12-11 15:09:18] [INFO]upgradePercentage:100%
[Driver] [2023-12-11 15:09:18] [INFO]Driver package installed successfully! The new version takes effect immediately.
[Driver] [2023-12-11 15:09:18] [INFO]End time: 2023-12-11 15:09:18
5、安装固件
bash ./Ascend-hdk-910-npu-firmware_7.0.0.5.242.run --full
安装成功提示:
Verifying archive integrity... 100% SHA256 checksums are OK. All good.
Uncompressing ASCEND-HDK-910-NPU FIRMWARE RUN PACKAGE 100%
[Firmware] [2023-12-11 15:09:34] [INFO]Start time: 2023-12-11 15:09:34
[Firmware] [2023-12-11 15:09:34] [INFO]LogFile: /var/log/ascend_seclog/ascend_install.log
[Firmware] [2023-12-11 15:09:34] [INFO]OperationLogFile: /var/log/ascend_seclog/operation.log
[Firmware] [2023-12-11 15:09:34] [WARNING]Do not power off or restart the system during the installation/upgrade
[Firmware] [2023-12-11 15:09:38] [INFO]upgradePercentage: 0%
[Firmware] [2023-12-11 15:09:46] [INFO]upgradePercentage: 100%
[Firmware] [2023-12-11 15:09:46] [INFO]The firmware of [1] chips are successfully upgraded.
[Firmware] [2023-12-11 15:09:47] [INFO]Firmware package installed successfully! Reboot now or after driver installation for the installation/upgrade to take effect.
6、安装CANN
bash Ascend-cann-toolkit_7.0.0.alpha002_linux-aarch64.run --install --install-for-all
7、环境变量配置
配置vi /root/.bashrc 最后一行加入:文章来源:https://www.toymoban.com/news/detail-780886.html
source /usr/local/Ascend/ascend-toolkit/set_env.sh
export LD_PRELOAD=/lib/aarch64-linux-gnu/libGLdispatch.so.0
8、安装kernel-opp算子包
bash Ascend-cann-kernel_7.0.0.alpha002_linux-aarch64.run --install --install-for-all
安装MindSpore框架
参考:mindspore.cn官网进行安装;文章来源地址https://www.toymoban.com/news/detail-780886.html
到了这里,关于Ubuntu20.04降低linux版本到5.4.0-26-generic的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!