cudnn Installation in Linux

本文详细介绍如何在Ubuntu和Debian等Linux系统中安装cuDNN。包括从官方网站下载cuDNN压缩包、解压并复制到CUDA安装目录的具体步骤。此外还提供了通过.deb文件在Debian下安装的方法及安装后的测试方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cudnn Installation in Linux

安装教程相对简单,实际原理就是将 cudnn的库加入 cudaincludelib 文件夹中

0.前提

  1. 此方法适用于Linux 系统,常见的 Ubuntu ,Debian 等等
  2. 首先你的系统已经成功安装好 CUDA toolkit
  3. 从官方网站上下载 cudnn 的压缩包(很多版本,下载你需要的),需要登录账户

1. Ubuntu 下安装

  1. 进入存在 cudnn**.tgz 的文件夹

  2. 解压

    $ tar -xzvf cudnn-9.0-linux-x64-v7.tgz
  3. 将解压过的文件,复制到你cuda的安装目录即可

    $ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
    $ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
    $ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

2. Debian 下安装

Debian下的安装方法跟简单,直接安装打包好的.deb就可以了.

  1. 进入debian版本cudnn的文件夹下

  2. 安装运行时的库

    sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb
  3. 安装开发者的库

    sudo dpkg -i libcudnn7-dev_7.0.3.11-1+cuda9.0_amd64.deb
  4. 安装 例程和用户指南

    sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.deb

3.测试一下是否安装成功

运行一个小Demo即可.

如果安装了 例程和用户指南 这个包的话,我们可以找到位于 /usr/src/cudnn_samples_v7mnistCUDNN这个小例子.

  1. 拷贝到 你的home/yourdir 任意文件夹下

    $cp -r /usr/src/cudnn_samples_v7/ $HOME
  2. 进入 mnistCUDNN

    $ cd $HOME/cudnn_samples_v7/mnistCUDNN
  3. 编译

    $make clean && make
  4. 运行

    $ ./mnistCUDNN
  5. 如果安装成功了,你会看到这样结果

    Test passed!

其实还可以cmake 一下你的caffe/build,也能很快测试是否安装成功

Reference

https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/Doc/cuDNN-Installation-Guide

### CUDNN Version 7.4 Installation and Compatibility CUDNN (CUDA Deep Neural Network library) is a GPU-accelerated deep learning library developed by NVIDIA to enhance performance of neural network applications on CUDA-enabled GPUs. When installing CUDNN version 7.4, it's important to ensure that all dependencies are correctly configured. #### System Requirements To successfully install CUDNN 7.4, the system must meet specific requirements regarding operating systems and CUDA versions: - **Operating Systems**: Oracle Linux 7.4 supports various kernel packages as part of its update release[^2]. Similarly, Ubuntu 16.04 has been widely used alongside CUDA installations for machine learning frameworks such as TensorFlow or PyTorch. - **CUDA Versions**: For optimal compatibility, CUDNN 7.4 works best with CUDA 9.0 or later versions. In some configurations involving newer hardware like GTX 1080 Ti under Ubuntu 16.04, users have reported successful setups using both CUDA 10.0 combined with either CUDNN 7.4.2 or 7.6.4[^5]. #### Steps for Installing CUDNN 7.4 The process involves downloading appropriate binaries from NVIDIA’s official site based upon your architecture type—whether you're working within an environment utilizing `libcudnn.so.5` versus `.so.7`. Ensure these match exactly what was downloaded earlier before proceeding further into linking steps outlined below. ```bash sudo cp cuda/include/cudnn*.h /usr/local/cuda/include/ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn* ``` Additionally, modify `/etc/profile`, adding paths necessary so they can be recognized during compilation phases without manual intervention each time invoking commands related thereto via shell scripting methods shown hereafter : ```bash export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=<cudnn-install-path>:$LD_LIBRARY_PATH source ~/.bashrc ``` This ensures proper linkage between installed libraries including those provided through Anaconda distributions where potential conflicts may arise due HDF5 discrepancies which could otherwise impede functionality unless addressed accordingly per instructions given previously concerning downgrading said component specifically targeting Python environments managed thusly ^[3]^ . Finally verify everything functions properly executing command line utility designed explicitly towards monitoring status information pertinent graphical processing units present inside host machines running Linux-based kernels mentioned throughout this document while ensuring drivers themselves were indeed set up according manufacturer guidelines stipulated elsewhere hereinabove too^ [5]^ .
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值