当前位置: 首页 > news >正文

NVidia 的 gpu 开源 Linux Kernel Module Driver 编译 安装 使用

 见面礼,动态查看gpu使用情况,每隔2秒钟自动执行一次 nvidia-smi

$ watch -n 2 nvidia-smi

1,找一台nv kmd列表中支持的 GPU 的电脑,安装ubuntu22.04

列表见 github of the kmd source code。

因为 cuda sdk 12.3支持最高到 ubuntu 22.04,故

下载 ubuntu 22.04...iso

rufus 刷U盘

重启电脑,F2F8F10F12一起按

进入 setup,修改启动顺序,选U盘第一

一步步安装好,

reboot

修改apt 国内源
为编译Linux kernel 安装软件:

sudo apt updatesudo apt upgradesudo apt install build-essential
sudo apt-get update && sudo apt-get install libncurses-dev && sudo apt-get install build-essential  && sudo apt-get install flex bison && sudo apt-get install libssl-dev && sudo apt-get install binutils && sudo apt-get install libelf-dev && sudo apt-get install openssh-server && sudo apt-get install vim && sudo apt-get install bc && sudo apt-get install dwarves && sudo apt-get install zstd
  sudo apt-get updatesudo apt-get install libssl-devsudo apt-get install binutilssudo apt-get install libelf-devsudo apt-get install dwarves

2,重新编译安装Linux kernel

sudo apt install linux-source-6.5.0

sudo apt install linux-source-6.5.0 
ls
mkdir ex_kernel_linux_debug
cd ex_kernel_linux_debug/
ls
cp /usr/src/linux-source-6.5.0.tar.bz2 ./
tar -xvjf linux-source-6.5.0.tar.bz2 
cd linux-source-6.5.0/cp /boot/config-6.5.0-44-generic ./.config
make oldconfig

编译 kernel :

$ make -j

安装 kernel :

  $ sudo make modules_install$ sudo make install$ sudo reboot

3, 安装 cuda sdk 12.3 但保留最后两步

按照nv官方步骤,先执行step1的安装

3.1 安装之前需要设置黑名单,官方指导

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#removing-cuda-toolkit-and-driver

具体操作:

复制如下:

 8.3.6. UbuntuCreate a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents:blacklist nouveauoptions nouveau modeset=0Regenerate the kernel initramfs:sudo update-initramfs -u

3.2 安装 cuda sdk step 1

操作链接:

https://developer.nvidia.com/cuda-12-3-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_local
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pinsudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600wget https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda-repo-ubuntu2204-12-3-local_12.3.0-545.23.06-1_amd64.debsudo dpkg -i cuda-repo-ubuntu2204-12-3-local_12.3.0-545.23.06-1_amd64.debsudo cp /var/cuda-repo-ubuntu2204-12-3-local/cuda-*-keyring.gpg /usr/share/keyrings/sudo apt-get updatesudo apt-get -y install cuda-toolkit-12-3

4, 使用开源代码替代step2

4.1 下载编译 NV gpu 的开源 kmd

下载:

https://github.com/NVIDIA/open-gpu-kernel-modules

git clone https://github.com/NVIDIA/open-gpu-kernel-modules.gitcd open-gpu-kernel-modulesgit checkout 545.23.06git branch

有时候下载会失败,下载下来后做好备份。或者 fork 到自己的github 账号后再clone

4.2 编译安装

make clean
make -j12
sudo make modules_install
sudo make install
sudo reboot

5,执行step 3 安装 cuda

sudo apt-get install -y cuda-drivers-545

测试:

$ nvidia-smi

$ ./vectorAdd

6,怎么验证这个kmd是从 源码安装的呢?

在开源代码中 加点printk等代码看看:

重新编译安装

$ make modules -j

$ make modules_install -j

重启电脑

$ sudo reboot

然后执行:

$ sudo dmesg

这名加载的是开源代码的ko文件。

运行APP:

备忘个链接:

Index of /XFree86/FreeBSD-x86_64/520.56.06

https://images.nvidia.com/content/pdf/nvswitch-technical-overview.pdf

https://www.amax.com/unleashing-next-level-gpu-performance-with-nvidia-nvlink/
https://www.nvidia.com/en-us/data-center/nvlink/

https://hc34.hotchips.org/assets/program/conference/day2/Network%20and%20Switches/NVSwitch%20HotChips%202022%20r5.pdf

http://www.lryc.cn/news/404395.html

相关文章:

  • win7显卡驱动更新后msvcp140.dll丢失的解决方法
  • (11)Python引领金融前沿:投资组合优化实战案例
  • git删除本地远程分支
  • 前端-04-VScode敲击键盘有键入音效,怎么关闭
  • JMeter数据库连接操作及断言
  • Maven settings.xml 私服上传和拉取配置
  • 【STM32】MPU内存保护单元
  • 用Python爬虫能实现什么?
  • 【QT】label中添加QImage图片并旋转(水平翻转、垂直翻转、顺时针旋转、逆时针旋转)
  • CSP-J模拟赛day1
  • Docker构建LNMP环境并运行Wordpress平台
  • 《峡谷小狐仙-多模态角色扮演游戏助手》复现流程
  • Qt 使用Installer Framework制作安装包
  • Typora 1.5.8 版本安装下载教程 (轻量级 Markdown 编辑器),图文步骤详解,免费领取(软件可激活使用)
  • linux代填密码切换用户
  • 防火墙的经典体系结构及其具体结构
  • 【BUG】已解决:note: This is an issue with the package mentioned above,not pip.
  • 【ARM】SMMU系统虚拟化整理
  • PYQT按键长按机制
  • SAPUI5基础知识15 - 理解控件的本质
  • 十七、【机器学习】【非监督学习】- K-均值 (K-Means)
  • 算法力扣刷题记录 五十六【501.二叉搜索树中的众数】
  • 分布式搜索引擎ES-Elasticsearch进阶
  • 低代码与传统编程:快速高质量构建系统的比较与方法
  • WebRTC音视频-环境搭建
  • Memcached开发(八):使用PHP进行操作
  • [Spring Boot]Protobuf解析MQTT消息体
  • 什么是Mappers?Mappers的作用是什么?
  • python-多任务编程
  • IDEA创建Java工程、Maven安装与建立工程、Web工程、Tomcat配置