Ubuntu 18.04/20.04 CV环境配置(上):CUDA11.1 + cudnn安装配置

2023-05-16

 

 

目录

1. 版本对应

查看CUDA版本与NVIDIA驱动的关系

2. 下载安装

2.1 下载CUDA文件

Download Installer for Linux Ubuntu 20.04 x86_64

2.2 下载cudnn文件

3. 配置测试

参考连接:


1. 版本对应

无论采用哪一种方式,首先都需要更新 Ubuntu 软件源和升级到最新版本的软件包。由于国内从 Ubuntu 官方软件源下载速度比较慢,所以,建议采用国内 Ubuntu 镜像源,比如阿里 Ubuntu 软件源或清华大学 Ubuntu 软件源。具体的配置方式是修改配置文件 /etc/apt/sources.list,将其中的 archive.ubuntu.com 替换为 mirrors.alibaba.com 或 mirrors.tuna.tsinghua.edu.cn 。也可以在图形界面应用 "Software & Update" 中,修改 Ubuntu Software 标签页中的 Download from 后的软件源地址。

配置软件源后,采用如下命令进行软件源的更新和软件包的升级。

sudo apt update

查看CUDA版本与NVIDIA驱动的关系


也可以到官网查看,点击查看链接icon-default.png?t=M666https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html

2. 下载安装

2.1 下载CUDA文件

CUDA Toolkit 11.1 Update 1 Downloads | NVIDIA Developericon-default.png?t=M666https://developer.nvidia.com/cuda-11.1.1-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal

 

Download Installer for Linux Ubuntu 20.04 x86_64

The base installer is available for download below.

 Base Installer
Installation Instructions:
wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run

sudo sh cuda_11.1.1_455.32.00_linux.run

The CUDA Toolkit contains Open-Source Software. The source code can be found here.

  • 打开主目录下的 .bashrc文件添加如下路径,.bashrc文件在/home下,如果没有找到,则按Ctrl+H键显示隐藏文件。将以下命令添加至文件末尾,保存退出。
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
source ~/.bashrc

需要注意,安装时,选择不安装 CUDA 驱动,安装记录如下:


===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-11.0/
Samples:  Installed in /home/klchang/, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-11.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-11.0/lib64, or, add /usr/local/cuda-11.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.0/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least .00 is required for CUDA 11.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run --silent --driver

Logfile is /var/log/cuda-installer.log  

安装结束后,添加环境变量到 ~/.bashrc 文件的末尾,具体添加内容如下:


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda  

保存后退出。

在 Terminal 中,激活环境变量命令为 source ~/.bashrc 

注:上述命令中的cuda也可以改为cuda11.1,因为在系统目录中有cuda和cuda11.1两个文件夹,其中cuda文件夹是cuda11.1的链接,二者内容相同。

  • 检查:nvcc -V,查看cuda是否正确安装

 

2.2 下载cudnn文件

  • 在NVIDIA官网下载与cuda11.1版本对应的cudnn8.0.4,下载地址为:https://developer.nvidia.com/rdp/cudnn-archive。建议下载cuDNN Library for Linux (x86_64)安装包。
  • 安装cudnn v8.0.4
sudo cp cudnn-11.1-linux-x64-v8.0.4.30.solitairetheme8 cudnn-11.1-linux-x64-v8.0.4.30.tgz
tar -xzvf cudnn-11.1-linux-x64-v8.0.4.30.tgz
sudo cp cuda/include/* /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

注:此处必须使用sudo cp cuda/include/* /usr/local/cuda/include/,而不是sudo cp cuda/include/cudnn.h /usr/local/cuda/include/

3. 配置测试

测试 CUDA Toolkit 。 通过编译自带 Samples并执行, 以验证是否安装成功。具体命令如下所示:

cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

如果安装成功,则输出类似于如下信息:

3块 "NVIDIA A100 80GB PCIe"显卡,豪华套装

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 3 CUDA Capable device(s)

Device 0: "NVIDIA A100 80GB PCIe"
  CUDA Driver Version / Runtime Version          11.6 / 11.1
  CUDA Capability Major/Minor version number:    8.0
  Total amount of global memory:                 81070 MBytes (85007794176 bytes)
  (108) Multiprocessors, ( 64) CUDA Cores/MP:     6912 CUDA Cores
  GPU Max Clock rate:                            1410 MHz (1.41 GHz)
  Memory Clock rate:                             1512 Mhz
  Memory Bus Width:                              5120-bit
  L2 Cache Size:                                 41943040 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total shared memory per multiprocessor:        167936 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Enabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Managed Memory:                Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 33 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

Device 1: "NVIDIA A100 80GB PCIe"
  CUDA Driver Version / Runtime Version          11.6 / 11.1
  CUDA Capability Major/Minor version number:    8.0
  Total amount of global memory:                 81070 MBytes (85007794176 bytes)
  (108) Multiprocessors, ( 64) CUDA Cores/MP:     6912 CUDA Cores
  GPU Max Clock rate:                            1410 MHz (1.41 GHz)
  Memory Clock rate:                             1512 Mhz
  Memory Bus Width:                              5120-bit
  L2 Cache Size:                                 41943040 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total shared memory per multiprocessor:        167936 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Enabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Managed Memory:                Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 129 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

Device 2: "NVIDIA A100 80GB PCIe"
  CUDA Driver Version / Runtime Version          11.6 / 11.1
  CUDA Capability Major/Minor version number:    8.0
  Total amount of global memory:                 81070 MBytes (85007794176 bytes)
  (108) Multiprocessors, ( 64) CUDA Cores/MP:     6912 CUDA Cores
  GPU Max Clock rate:                            1410 MHz (1.41 GHz)
  Memory Clock rate:                             1512 Mhz
  Memory Bus Width:                              5120-bit
  L2 Cache Size:                                 41943040 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total shared memory per multiprocessor:        167936 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Enabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Managed Memory:                Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 226 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
> Peer access from NVIDIA A100 80GB PCIe (GPU0) -> NVIDIA A100 80GB PCIe (GPU1) : Yes
> Peer access from NVIDIA A100 80GB PCIe (GPU0) -> NVIDIA A100 80GB PCIe (GPU2) : Yes
> Peer access from NVIDIA A100 80GB PCIe (GPU1) -> NVIDIA A100 80GB PCIe (GPU0) : Yes
> Peer access from NVIDIA A100 80GB PCIe (GPU1) -> NVIDIA A100 80GB PCIe (GPU2) : Yes
> Peer access from NVIDIA A100 80GB PCIe (GPU2) -> NVIDIA A100 80GB PCIe (GPU0) : Yes
> Peer access from NVIDIA A100 80GB PCIe (GPU2) -> NVIDIA A100 80GB PCIe (GPU1) : Yes

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.6, CUDA Runtime Version = 11.1, NumDevs = 3
Result = PASS

 

参考连接:

Ubuntu 20.04 安装 CUDA Toolkit 的三种方式 - klchang - 博客园

Linux安装CUDA的正确姿势[通俗易懂] - 全栈程序员必看

cuda11.1 + cuDNN v8.0.4 for CUDA 11.1 配置流程 - 知乎

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Ubuntu 18.04/20.04 CV环境配置(上):CUDA11.1 + cudnn安装配置 的相关文章

  • STM32学习路线-长图

    最近好好整理了一下学习STM32的路程 xff0c 做成了一个长图 xff1a STM32学习路线 xff0c 供初学者们参考一下
  • ROS 教程之 vision: 摄像头标定camera calibration

    在上一个ROS教程视觉文章中 xff0c 我们使用usb cam包读入并发布了图像消息 xff0c 但是图像没有被标定 xff0c 因此存在畸变 ROS官方提供了用于单目或者双目标定的camera calibration包 这个包是使用op
  • ROS 基础: 在同一个节点里订阅和发布消息

    在一些应用中 xff0c 可能有的人需要在同一个节点中实现订阅一个消息 xff0c 然后在该消息的回调函数中处理一下这些数据后再发布到另一个topic上 ROS answers中也有人有相同的疑问 xff0c 这里贴出Martin Peri
  • ROS : 修改ROS源代码(overlaying package)

    ROS官方或者其他个人提供了很多package供大家使用 xff0c 但是随着学习的深入 xff0c 很多人可能想去修改这些package的源代码 xff0c ROS提供了一种称之为overlaying的机制 它允许 ROS原有安装的pac
  • graph slam tutorial :从推导到应用3

    为了更好地理解graph based slam的过程 xff0c 本文以二维平面的激光SLAM为例子 xff0c 先简单介绍如何根据传感器信息构建图 xff0c 即图优化的前端 xff08 front end xff09 然后再针对上篇博客
  • graph slam tutorial : 从推导到应用1

    前言 SLAM问题的处理方法主要分为滤波和图优化两类 滤波的方法中常见的是扩展卡尔曼滤波 粒子滤波 信息滤波等 xff0c 熟悉滤波思想的同学应该容易知道这类SLAM问题是递增的 实时的处理数据并矫正机器人位姿 比如基于粒子滤波的SLAM的
  • graph slam tutorial :从推导到应用2

    在上一部分中通过一个例子大致了解了graph based slam的优化过程 在本篇博客中将提升一个层次 xff0c 对图优化的求解过程进行推导 由于博文关注的在图构建好以后 xff0c 如何调整机器人位姿使误差最下 因此 xff0c 本文
  • graph slam tutorial : g2o 的使用

    g2o全称general graph optimization xff0c 是一个用来优化非线性误差函数的c 43 43 框架 如果阅读了前几篇graph slam tutorial的博客 xff0c 再去读 g2o xff1a a gen
  • Monocular slam 的理论基础(1)

    前言 LSD SLAM和ORB SLAM的出现 xff0c 使得单目slam最近成为了研究热点 单目SLAM一般处理流程包括track和map两部分 所谓的track是用来估计相机的位姿 而map部分就是计算pixel的深度 xff0c 如
  • Monocular slam 中的理论基础(2)

    三角法求深度 xff08 triangulation xff09 在知道了相机的轨迹以后 xff0c 使用三角法就能计算某个点的深度 xff0c 在Hartley的 Multiple view Geometry 一书中第10章 第12章都是
  • svo: semi-direct visual odometry 论文解析

    SVO 从名字来看 xff0c 是半直接视觉里程计 xff0c 所谓半直接是指通过对图像中的特征点图像块进行直接匹配来获取相机位姿 xff0c 而不像直接匹配法那样对整个图像使用直接匹配 整幅图像的直接匹配法常见于RGBD传感器 xff0c
  • 想精通单片机开发,这些必备基础知识不可不掌握

    总体谈一谈对单片机学习的看法 1 我从不说51是基础 xff0c 如果我这么说 xff0c 也请把这句话理解为微机原理是基础 2 对51单片机的操作本质上就是对寄存器的操作 xff0c 对其他单片机也是如此 库只是一个接口 xff0c 方便
  • 从零开始手写 VIO

    前言 最近和高博合作推出了一个关于 VIO 的课程 xff0c 借此博客推荐下 这个课程的图优化后端是我们自己写的 xff0c 仅依赖 Eigen 实现后系统的精度和 ceres 以及 g2o 不相上下 个人感觉这个课程还是能学到不少东西
  • 如何用示波器测量串口波特率

    例如波特率为9600理解为 xff1a 单位时间内传输9600个码元 xff08 位 xff09 1s内可以传输9600位数 假如要测量波特率为9600 xff0c 则每一比特位的时间为 xff1a 1 9600 61 104us 一般示波
  • PHPstorm2018汉化方法

    PhpStorm 2018汉化包下载地址 xff1a https pan baidu com s 1sAPfpPrN3IvZSyGU2kFWmQ 8 将安装目录lib下的resources en jar文件删除 xff0c 然后将压缩包中的
  • CMake学习(3)—— 使用add_subdirectory()添加外部项目文件夹

    一般情况下 xff0c 我们的项目各个子项目都在一个总的项目根目录下 xff0c 但有的时候 xff0c 我们需要使用外部的文件夹 xff0c 怎么办呢 xff1f 例如 xff0c 在目录cxx utility example内的CMak
  • docker高级篇

    docker高级篇 一 dockerfile解析 1 dockerfile是什么 dockerfile是用来构建docker镜像的文本文件 xff0c 是有一条条构建镜像所需的指令和参数构成的脚本 2 dockerfile常用保留字指令 F
  • 死锁

    死锁 xff1a 死锁是指两个或两个以上的进程进在执行过程中 xff0c 由于资源竞争或由于相互通信而造成的一种阻塞式现象 xff0c 如果没有外力影响 那么它们将永远的持续下去 xff0c 此事称系统产生死锁现象 xff0c 这种永远互相
  • pygame入门教程-基础篇

    1 画布surface 我们先启动一个窗口 span class token keyword import span pygame pygame span class token punctuation span init span cla
  • LeetCode刷题(废弃)

    重要提示 xff1a 该博客不再更新 xff01 最新文章请参考LeetCode系列 xff01 为了更好地巩固算法知识 xff0c 打下扎实的计算机基础 好吧 xff0c 实在编不下去了 其实是闲着没事儿做 xff0c 不如动动脑 xff

随机推荐