周凯,个人博客

  • 前端
  • 嵌入式
  • 工具
  • 后端
  • 随笔
个人记录
  1. 首页
  2. AI
  3. ai部署
  4. 正文

ubuntu nvidia安装驱动

2024年 2月 3日 941点热度 0人点赞 0条评论
  • 查看显卡信息

    # 查看驱动版本 drive version
    nvidia-smi
    
    # 定时刷新(每隔2秒刷新一次,每次只在固定位置刷新)
    watch -n 2 -d nvidia-smi
    
    # 定时查询(每隔2秒查询一下,但是每次的查询结果会接着上一个往下刷新,导致持续扩张terminal的历史log)
    nvidia-smi -l 2
  • nvidia 驱动安装

    • 方式1

    • 选择对应的显卡:NVIDIA GeForce 驱动程序 - N 卡驱动 | NVIDIA

    • 点击下载驱动 .run

    • 赋执行权限

      chmod +x NVIDIA-Linux-x86_64-550.40.07.run
    • 运行安装:./NVIDIA-Linux-x86_64-550.40.07.run

    • 验证是否安装

      nvidia-smi
    • 方式2

    • 卸载从文件安装的 NVIDIA 驱动程序或 CUDA 工具包的捆绑驱动程序.run

      sudo apt clean
      sudo apt update
      sudo apt purge nvidia-* 
      sudo apt autoremove
      
      ./NVIDIA-Linux-x86_64-550.40.07.run  --uninstall
    • 从 PPA 安装 NVIDIA 驱动程序

      • 添加 PPA :graphics-drivers
      sudo add-apt-repository ppa:graphics-drivers/ppa --yes
      sudo apt update
    • 从 PPA 安装 NVIDIA 驱动程序:

      sudo apt install nvidia-driver-550 # or nvidia-driver-550
    • (可选)将驱动程序标记为保留以防止自动升级(因为它是服务器)

      dpkg-query -W --showformat='${Package} ${Status}\n' | grep -v deinstall | awk '{ print $1 }' | \
        grep -E 'nvidia.*-[0-9]+$' | \
        xargs -r -L 1 sudo apt-mark hold
  • cuda toolkit

    • 为创建高性能、GPU 加速的应用程序提供了开发环境
    • sudo apt install nvidia-cuda-toolkit
  • cuda

    • NVIDIA 专为图形处理单元 (GPU) 上的通用计算开发的并行计算平台和编程模型,借助 CUDA,开发者能够利用 GPU 的强大性能显著加速计算应用

    • 安装:CUDA Toolkit Archive | NVIDIA Developer

    • 下载 .run文件

    • 运行安装,如果没有drive驱动,可以选择驱动一起安装

    • 配置环境变量

      cuda-11.8 为安装的版本号

      export PATH="/usr/local/cuda-11.8/bin:$PATH"
      export LD_LIBRARY_PATH="/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH"
    • 查看运行时版本 runtime version

    nvcc --version
  • cuDNN 是用于深度神经网络的 GPU 加速基元库

    • 下载对应的版本:cuDNN Download | NVIDIA Developer

    • dpkg安装:dpkg -i cudnn-local-repo-ubuntu2004-8.9.7.29_1.0-1_amd64.deb

    • 根据提示 安装GPT秘钥

      sudo cp /var/cudnn-local-repo-ubuntu2004-8.9.7.29/cudnn-local-CD2C2DD4-keyring.gpg /usr/share/keyrings/
    • sudo apt-get update

    • sudo apt-get install libcudnn8

    • 安装完成,测试

    dpkg -l | grep libcudnn

参考

  • 【记录】ubuntu20.04安装nvidia显卡驱动-CSDN博客

问题

  • CUDA 问题解决 —nvcc -V bash: /usr/bin/nvcc: No such file or directory

    CUDA 问题解决 —nvcc -V bash: /usr/bin/nvcc: No such file or directory_bash: /usr/bin/nvcc: 没有那个文件或目录-CSDN博客

    export PATH=/usr/local/cuda-12.3/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PA
  • NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

    • NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running - Graphics / Linux / Linux - NVIDIA Developer Forums

🎯 拓展阅读提示

本文涉及的内容已同步至公众号后台,我会在那里分享更多深度内容和实用技巧

→ 点击关注:一行梦境

公众号二维码
本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2024年 2月 3日

周凯

这个人很懒,什么都没留下

打赏 点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2022-现在 周凯,个人博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

蒙ICP备18004897号