在Ubuntu上安装CUDA和cuDNN以及验证安装步骤

在Ubuntu上安装CUDA和cuDNN以及验证安装步骤

本教程详细介绍了如何在Ubuntu操作系统上安装CUDA(NVIDIA的并行计算平台)和cuDNN(深度神经网络库),以及如何验证安装是否成功。通过按照这些步骤操作,您将能够配置您的系统以利用GPU加速深度学习和其他计算密集型任务。此外,还包括如何设置环境变量和编译运行示例代码以验证CUDA和cuDNN的正常运行。

  • 安装 CUDA
  • 通过网络仓库安装CUDA(适用于Ubuntu)
  • 配置环境变量
  • 验证安装
  • 安装 cuDNN
  • 验证 cuDNN

安装 CUDA

在安装CUDA之前,我们需要进行一些预安装操作。首先,您需要安装当前正在运行的内核的头文件和开发包。打开终端并执行以下命令:

sudo apt-get install linux-headers-$(uname -r)

接下来,您需要删除过时的签名密钥:

sudo apt-key del 7fa2af80

通过网络仓库安装CUDA(适用于Ubuntu)

新的CUDA存储库的GPG公钥是3bf863cc。您可以通过cuda-keyring包或手动方法将其添加到系统中,不建议使用apt-key命令。执行以下步骤:

  1. 安装新的cuda-keyring包。根据您的系统版本替换$distro/$arch
wget https://developer.download.nvidia.com/compute/cuda/repos/$distro/$arch/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb

$distro/$arch 应该根据以下选项之一进行替换:

  • ubuntu1604/x86_64:适用于 Ubuntu 16.04 64位版本。
  • ubuntu1804/cross-linux-sbsa:适用于 Ubuntu 18.04 交叉编译版本(SBSA 架构)。
  • ubuntu1804/ppc64el:适用于 Ubuntu 18.04 64位 PowerPC 架构版本。
    * ubuntu1804/sbsa:适用于 Ubuntu 18.04 SBSA 架构版本。
  • ubuntu1804/x86_64:适用于 Ubuntu 18.04 64位版本。
  • ubuntu2004/cross-linux-aarch64:适用于 Ubuntu 20.04 交叉编译版本(AArch64 架构)。
  • ubuntu2004/arm64:适用于 Ubuntu 20.04 64位 ARM 架构版本。
  • ubuntu2004/cross-linux-sbsa:适用于 Ubuntu 20.04 交叉编译版本(SBSA 架构)。
  • ubuntu2004/sbsa:适用于 Ubuntu 20.04 SBSA 架构版本。
  • ubuntu2004/x86_64:适用于 Ubuntu 20.04 64位版本。
  • ubuntu2204/sbsa:适用于 Ubuntu 22.04 SBSA 架构版本。
  • ubuntu2204/x86_64:适用于 Ubuntu 22.04 64位版本。
    根据您的Ubuntu版本和架构选择适当的替代项来执行相应的安装步骤。
  1. 更新Apt仓库缓存:
sudo apt-get update
  1. 安装 CUDA SDK:
    您可以使用以下命令获取可用的CUDA包列表:
cat /var/lib/apt/lists/*cuda*Packages | grep "Package:"

或查看下方列表:

Meta PackagePurpose
cudaInstalls all CUDA Toolkit and Driver packages. Handles upgrading to the next version of the cuda package when it’s released.
cuda-12-2Installs all CUDA Toolkit and Driver packages. Remains at version 12.1 until an additional version of CUDA is installed.
cuda-toolkit-12-2Installs all CUDA Toolkit packages required to develop CUDA applications. Does not include the driver.
cuda-toolkit-12Installs all CUDA Toolkit packages required to develop applications. Will not upgrade beyond the 12.x series toolkits. Does not include the driver.
cuda-toolkitInstalls all CUDA Toolkit packages required to develop applications. Handles upgrading to the next 12.x version of CUDA when it’s released. Does not include the driver.
cuda-tools-12-2Installs all CUDA command line and visual tools.
cuda-runtime-12-2Installs all CUDA Toolkit packages required to run CUDA applications, as well as the Driver packages.
cuda-compiler-12-2Installs all CUDA compiler packages.
cuda-libraries-12-2Installs all runtime CUDA Library packages.
cuda-libraries-dev-12-2Installs all development CUDA Library packages.
cuda-driversInstalls all Driver packages. Handles upgrading to the next version of the Driver packages when they’re released.

选择你需要的包进行安装,这里选择 cuda-11.8

sudo apt-get install cuda-11-8

此安装包中包含显卡驱动,安装过程中,会让你输入密码,请记住该密码,后面重启电脑进入 Perform MOK managment 会使用到。

  1. 安装完成后,重新启动系统:
sudo reboot

配置 Perform MOK managment
MOK management
选择 Enroll MOK (注册)-> 选择 Continue -> 选择 Enroll the key -> 选择 Yes -> 键入步骤3中输入的密码->选择 Reboot 重启电脑,完成英伟达显卡驱动安装。

配置环境变量

  1. 使用 vim 编辑 ~/.bashrc 文件。
sudo vim ~/.bashrc
  1. 在文件结尾添加以下内容:
export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

${PATH:+:${PATH}} 是一个用于设置环境变量的 Bash Shell 中的特殊语法。它的作用是在添加新路径到环境变量时,确保如果原始变量(在这种情况下是 $PATH)已经包含一些路径,那么新路径会添加在原有路径的末尾,而且它们之间会用冒号 : 分隔。
具体来说,${PATH:+:${PATH}} 的含义是:
如果 $PATH 已经定义(非空),那么它会在新路径之前加上一个冒号 :,然后再添加新路径。
如果 $PATH 未定义或为空,那么它只会添加新路径,不会加冒号。
这个语法的目的是确保在向 $PATH 添加新路径时,保持路径之间用冒号分隔,以确保环境变量的正确格式。这在很多环境变量的设置中都很有用,因为它避免了路径之间缺少分隔符而导致的错误。

LD_LIBRARY_PATH 是一个环境变量,用于指定动态链接器(dynamic linker)在运行可执行文件时搜索共享库文件(动态链接库或共享对象文件)的路径。在 Linux 和类Unix系统中,共享库文件包含在各种程序中,允许多个程序共享相同的库,从而减少内存占用并提高系统的效率。

  1. 刷新配置
    在终端中运行以下命令,以使新的环境变量设置生效:
source ~/.bashrc

验证安装

首先,我们需要安装一些CUDA示例所需的第三方库。这些示例通常会在构建过程中检测所需的库,但如果未检测到,您需要手动安装它们。打开终端并执行以下命令:

sudo apt-get install g++ freeglut3-dev build-essential libx11-dev \libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev libfreeimage-dev

完成第三方库依赖安装后,从 github 下载 https://github.com/nvidia/cuda-samples 源代码。

下载完成后,可以使用以下命令编译:

cd cuda-sample
sudo make

注意切换到你安装 cuda 版本的分支,这里是 v11.8。

可以完成整个编译,那么说明安装过程没有问题了。

在源代码目录执行 ./bin/x86_64/linux/release/deviceQuery 命令,结果如下所示:

cheungxiongwei@root:~/Source/cuda-samples$ ./bin/x86_64/linux/release/deviceQuery
./bin/x86_64/linux/release/deviceQuery Starting...CUDA Device Query (Runtime API) version (CUDART static linking)Detected 1 CUDA Capable device(s)Device 0: "NVIDIA GeForce RTX 4060 Laptop GPU"CUDA Driver Version / Runtime Version          12.2 / 11.8CUDA Capability Major/Minor version number:    8.9Total amount of global memory:                 7940 MBytes (8325824512 bytes)
MapSMtoCores for SM 8.9 is undefined.  Default to use 128 Cores/SM
MapSMtoCores for SM 8.9 is undefined.  Default to use 128 Cores/SM(024) Multiprocessors, (128) CUDA Cores/MP:    3072 CUDA CoresGPU Max Clock rate:                            2250 MHz (2.25 GHz)Memory Clock rate:                             8001 MhzMemory Bus Width:                              128-bitL2 Cache Size:                                 33554432 bytesMaximum 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 layersMaximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layersTotal amount of constant memory:               65536 bytesTotal amount of shared memory per block:       49152 bytesTotal shared memory per multiprocessor:        102400 bytesTotal number of registers available per block: 65536Warp size:                                     32Maximum number of threads per multiprocessor:  1536Maximum number of threads per block:           1024Max 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 bytesTexture alignment:                             512 bytesConcurrent copy and kernel execution:          Yes with 2 copy engine(s)Run time limit on kernels:                     YesIntegrated GPU sharing Host Memory:            NoSupport host page-locked memory mapping:       YesAlignment requirement for Surfaces:            YesDevice has ECC support:                        DisabledDevice supports Unified Addressing (UVA):      YesDevice supports Managed Memory:                YesDevice supports Compute Preemption:            YesSupports Cooperative Kernel Launch:            YesSupports MultiDevice Co-op Kernel Launch:      YesDevice PCI Domain ID / Bus ID / location ID:   0 / 1 / 0Compute Mode:< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 12.2, CUDA Runtime Version = 11.8, NumDevs = 1
Result = PASS

安装 cuDNN

安装 cuDNN库和 cuDNN 示例

sudo apt-get install libcudnn8=${cudnn_version}-1+${cuda_version}
sudo apt-get install libcudnn8-dev=${cudnn_version}-1+${cuda_version}
sudo apt-get install libcudnn8-samples=${cudnn_version}-1+${cuda_version}

根据以下内容进行替换:
${cudnn_version} is 8.9.4.*
${cuda_version} is cuda12.2 or cuda11.8

使用以下命令查找与 cuDNN 版本 “libcudnn8” 相关的软件包信息

cat /var/lib/apt/lists/*cuda*Packages | grep "./libcudnn8"

输出结果如下所示:

cheungxiongwei@root:~/cudnn_samples_v8/mnistCUDNN$ cat /var/lib/apt/lists/*cuda*Packages | grep "./libcudnn8"
Filename: ./libcudnn8_8.5.0.96-1+cuda11.7_amd64.deb
Filename: ./libcudnn8-dev_8.5.0.96-1+cuda11.7_amd64.deb
Filename: ./libcudnn8_8.6.0.163-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.6.0.163-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.7.0.84-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.7.0.84-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.8.0.121-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.8.0.121-1+cuda12.0_amd64.deb
Filename: ./libcudnn8-dev_8.8.0.121-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.8.0.121-1+cuda12.0_amd64.deb
Filename: ./libcudnn8_8.8.1.3-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.8.1.3-1+cuda12.0_amd64.deb
Filename: ./libcudnn8-dev_8.8.1.3-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.8.1.3-1+cuda12.0_amd64.deb
Filename: ./libcudnn8_8.9.0.131-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.9.0.131-1+cuda12.1_amd64.deb
Filename: ./libcudnn8-dev_8.9.0.131-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.9.0.131-1+cuda12.1_amd64.deb
Filename: ./libcudnn8_8.9.1.23-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.9.1.23-1+cuda12.1_amd64.deb
Filename: ./libcudnn8-dev_8.9.1.23-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.9.1.23-1+cuda12.1_amd64.deb
Filename: ./libcudnn8-samples_8.9.1.23-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-samples_8.9.1.23-1+cuda12.1_amd64.deb
Filename: ./libcudnn8_8.9.2.26-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.9.2.26-1+cuda12.1_amd64.deb
Filename: ./libcudnn8-dev_8.9.2.26-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.9.2.26-1+cuda12.1_amd64.deb
Filename: ./libcudnn8-samples_8.9.2.26-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-samples_8.9.2.26-1+cuda12.1_amd64.deb
Filename: ./libcudnn8_8.9.3.28-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.9.3.28-1+cuda12.1_amd64.deb
Filename: ./libcudnn8-dev_8.9.3.28-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.9.3.28-1+cuda12.1_amd64.deb
Filename: ./libcudnn8-samples_8.9.3.28-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-samples_8.9.3.28-1+cuda12.1_amd64.deb
Filename: ./libcudnn8_8.9.4.25-1+cuda11.8_amd64.deb
Filename: ./libcudnn8_8.9.4.25-1+cuda12.2_amd64.deb
Filename: ./libcudnn8-dev_8.9.4.25-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-dev_8.9.4.25-1+cuda12.2_amd64.deb
Filename: ./libcudnn8-samples_8.9.4.25-1+cuda11.8_amd64.deb
Filename: ./libcudnn8-samples_8.9.4.25-1+cuda12.2_amd64.deb

这里选择最新的 cudnn 8.9.4.25,和 cuda 11.8 进行替换,替换后的完整指令如下所示:

sudo apt-get install libcudnn8=8.9.4.25-1+cuda11.8
sudo apt-get install libcudnn8-dev=8.9.4.25-1+cuda11.8
sudo apt-get install libcudnn8-samples=8.9.4.25-1+cuda11.8

验证 cuDNN

要验证 cuDNN 是否已安装并正常运行,请编译 `/usr/src/cudnn_samples_v8`` 目录中的 mnistCUDNN 示例。

  1. 复制 cuDNN 示例到当前用户目录
cp -r /usr/src/cudnn_samples_v8/ $HOME
  1. 移动到 cuDNN 示例目录中
cd  $HOME/cudnn_samples_v8/mnistCUDNN
  1. 编译 cuDNN mnisiCUDNN 示例
$make clean && make

如报错没有找到 FreeImage.h 文件,请执行 `sudo apt-get install libfreeimage-dev`` 指令安装该依赖。

  1. 运行 mnistCUDNN 示例
 ./mnistCUDNN

如果 cuDNN 在您的 Linux 系统上正确安装并编译&运行,您将看到类似以下内容的消息:

heungxiongwei@root:~/cudnn_samples_v8/mnistCUDNN$ ./mnistCUDNN
Executing: mnistCUDNN
cudnnGetVersion() : 8904 , CUDNN_VERSION from cudnn.h : 8904 (8.9.4)
Host compiler version : GCC 11.4.0There are 1 CUDA capable devices on your machine :
device 0 : sms 24  Capabilities 8.9, SmClock 2250.0 Mhz, MemSize (Mb) 7940, MemClock 8001.0 Mhz, Ecc=0, boardGroupID=0
Using device 0Testing single precision
Loading binary file data/conv1.bin
Loading binary file data/conv1.bias.bin
Loading binary file data/conv2.bin
Loading binary file data/conv2.bias.bin
Loading binary file data/ip1.bin
Loading binary file data/ip1.bias.bin
Loading binary file data/ip2.bin
Loading binary file data/ip2.bias.bin
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.010240 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.010240 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.018432 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.032992 time requiring 178432 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.047104 time requiring 2057744 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.051200 time requiring 184784 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 128848 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 128000 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.049152 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.051200 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.058368 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.063648 time requiring 1433120 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.065536 time requiring 128000 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.130112 time requiring 128848 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Resulting weights from Softmax:
0.0000000 0.9999399 0.0000000 0.0000000 0.0000561 0.0000000 0.0000012 0.0000017 0.0000010 0.0000000 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.007328 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.010240 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.011264 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.024576 time requiring 2057744 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.025600 time requiring 184784 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.026624 time requiring 178432 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 128848 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 128000 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.025376 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.030720 time requiring 128848 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.036864 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.051200 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.063488 time requiring 1433120 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.065536 time requiring 128000 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 0.9999288 0.0000000 0.0000711 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 0.9999820 0.0000154 0.0000000 0.0000012 0.0000006 Result of classification: 1 3 5Test passed!Testing half precision (math in single precision)
Loading binary file data/conv1.bin
Loading binary file data/conv1.bias.bin
Loading binary file data/conv2.bin
Loading binary file data/conv2.bias.bin
Loading binary file data/ip1.bin
Loading binary file data/ip1.bias.bin
Loading binary file data/ip2.bin
Loading binary file data/ip2.bias.bin
Loading image data/one_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 4608 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 28800 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.011264 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.021504 time requiring 28800 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.022592 time requiring 184784 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.025600 time requiring 178432 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.033792 time requiring 2057744 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.074752 time requiring 4608 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 1536 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 64000 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.031744 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.040960 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.051168 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.060416 time requiring 1433120 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.064512 time requiring 64000 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.069632 time requiring 1536 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Resulting weights from Softmax:
0.0000001 1.0000000 0.0000001 0.0000000 0.0000563 0.0000001 0.0000012 0.0000017 0.0000010 0.0000001 
Loading image data/three_28x28.pgm
Performing forward propagation ...
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 4608 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 28800 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.009216 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.012288 time requiring 28800 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.021312 time requiring 184784 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.023552 time requiring 4608 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.024352 time requiring 178432 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.029696 time requiring 2057744 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 1536 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 64000 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Testing cudnnFindConvolutionForwardAlgorithm ...
^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.025600 time requiring 2450080 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.035840 time requiring 4656640 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.051200 time requiring 0 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.060416 time requiring 1433120 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.064512 time requiring 64000 memory
^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.065536 time requiring 1536 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
Resulting weights from Softmax:
0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000714 0.0000000 0.0000000 0.0000000 0.0000000 
Loading image data/five_28x28.pgm
Performing forward propagation ...
Resulting weights from Softmax:
0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 1.0000000 0.0000154 0.0000000 0.0000012 0.0000006 Result of classification: 1 3 5Test passed!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/98085.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

知识储备--基础算法篇-矩阵

2.矩阵 2.1第54题螺旋矩阵 第一题上来就跪了&#xff0c;看了官方答案感觉不是很好理解&#xff0c;找了一个比较容易理解的。 class Solution(object):def spiralOrder(self, matrix):""":type matrix: List[List[int]]:rtype: List[int]"""…

微服务之架构演变

随着互联网的发展&#xff0c;网站应用规模不断扩大&#xff0c;网站架构随之不断演变&#xff0c;演变历史大致分为单体应用架构-垂直应用架构-分布式架构-SOA架构-微服务架构-云原生架构 架构演变 单体应用架构 以前网站流量小&#xff0c;只需要一个应用就可以把所有功能…

理解FPGA中的亚稳态

一、前言 大家应该经常能听说到亚稳态这个词&#xff0c;亚稳态主要是指触发器的输出在一段时间内不能达到一个确定的状态&#xff0c;过了这段时间触发器的输出随机选择输出0/1&#xff0c;这是我们在设计时需要避免的。本文主要讲述了FPGA中的亚稳态问题&#xff0c;可以帮助…

某物联网数智化园区行业基于 KubeSphere 的云原生实践

公司简介 作为物联网 数智化园区一体化解决方案提供商&#xff0c;我们致力于为大中型园区、停车场提供软硬件平台&#xff0c;帮助园区运营者实现数字化、智能化运营。 在使用 K8s 之前我们使用传统的方式部署上线&#xff0c;使用 spug&#xff08;一款轻量级无 Agent 的自…

书单制作方法详细步骤,需要的小伙伴快来看看~

随着网络的发展&#xff0c;视频已经成为了人们获取信息的主要途径之一。书单视频作为一种特殊类型的视频&#xff0c;既能为观众提供阅读建议&#xff0c;又能为制作者带来收益&#xff0c;因此备受欢迎。本文将分享书单视频制作的详细步骤&#xff0c;帮助有兴趣的朋友们快速…

Flink基础实操-计算单词出现次数

&#x1f947;&#x1f947;【大数据学习记录篇】-持续更新中~&#x1f947;&#x1f947; 个人主页&#xff1a;beixi 本文章收录于专栏&#xff08;点击传送&#xff09;&#xff1a;【大数据学习】 &#x1f493;&#x1f493;持续更新中&#xff0c;感谢各位前辈朋友们支持…

用Qt自制一个小闹钟

小闹钟 功能 当按下启动按钮时&#xff0c;停止按钮可用&#xff0c;启动按钮不可用&#xff0c;闹钟无法设置&#xff0c;无法输入自定义内容 当按下停止按钮时&#xff0c;暂停播报&#xff0c;启动按钮可用&#xff0c;闹钟可以设置&#xff0c;可以输入自定义内容 .pro文…

Weblogic SSRF【漏洞复现】

文章目录 漏洞测试注入HTTP头&#xff0c;利用Redis反弹shell redis不能启动问题解决 Path : vulhub/weblogic/ssrf 编译及启动测试环境 docker compose up -dWeblogic中存在一个SSRF漏洞&#xff0c;利用该漏洞可以发送任意HTTP请求&#xff0c;进而攻击内网中redis、fastcgi…

企业架构LNMP学习笔记12

1、Server配置&#xff1a; Server虚拟主机的配置&#xff1a; 在实际生产业务环境中&#xff0c;一台web服务器&#xff0c;需要使用多个网站部署。搭建vhost虚拟主机实现不同域名&#xff0c;解析绑定到不同的目录。 #基于http的web服务 server{#监听端口listen 80#配置虚…

微服务[Nacos]

CAP 1&#xff09;一致性(Consistency) (所有节点在同一时间具有相同的数据) 2&#xff09;可用性(Availability)(保证每个请求不管成功或者失败都有响应) 3&#xff09;分区容错(Partition tolerance)(系统中任意信息的丢失或失败不会影响系统的继续运作) 一、虚拟机镜像准备 …

vue3中TCplayer应用

环境win10:vitevue3elementUI 1 安装 npm install tcplayer.js2 使用 <template><div><video id"player-container-id" width"414" height"270" preload"auto" playsinline webkit-playsinline></video>&l…

Excel·VBA二维数组组合函数的应用实例

看到一个问题《关于#穷举#的问题&#xff0c;如何解决&#xff1f;(语言-开发语言)》&#xff0c;对同一个数据存在“是/否”2种状态&#xff0c;判断其是否参与计算&#xff0c;并输出一系列数据的“是/否”状态的结果 目录 方法1&#xff1a;二维数组组合函数结果 方法2&am…