在Ubuntu 18上安装cuDNN

本文详细介绍了在Linux系统上安装NVIDIA cuDNN的步骤,包括解压cuDNN包、复制文件到CUDA Toolkit目录并更改权限,以及通过编译和运行mnistCUDNN样本验证cuDNN是否正确安装和运行。
部署运行你感兴趣的模型镜像

INSTALL

  1. Navigate to your <cudnnpath> directory containing the cuDNN Tar file.
  2. Unzip the cuDNN package.
    $ tar -xzvf cudnn-9.0-linux-x64-v7.tgz
  3. Copy the following files into the CUDA Toolkit directory, and change the file permissions.
    $ 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

Verifying

To verify that cuDNN is installed and is running properly, compile the mnistCUDNN sample located in the /usr/src/cudnn_samples_v7 directory in the debian file.

  1. Copy the cuDNN sample to a writable path.
    $cp -r /usr/src/cudnn_samples_v7/ $HOME
  2. Go to the writable path.
    $ cd  $HOME/cudnn_samples_v7/mnistCUDNN
  3. Compile the mnistCUDNN sample.
    $make clean && make
  4. Run the mnistCUDNN sample.
    $ ./mnistCUDNN
    If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following:
    Test passed!

参考资料:https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#download

cuDNN下载地址:https://developer.nvidia.com/cudnn

您可能感兴趣的与本文相关的镜像

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

### 如何在 Ubuntu安装 CuDNN #### 准备工作 确保已成功安装 CUDA 工具包。这一步骤至关重要,因为 CuDNN 是作为 CUDA 的扩展而设计的。 #### 获取 CuDNN 文件 访问 NVIDIA 官方网站,在 cuDNN 页面注册并登录账户后下载适用于所使用的 CUDA 版本的 cuDNN 库文件[^5]。 #### 解压缩与复制文件 对于 `.tgz` 类型的 cuDNN 压缩包,使用如下命令解压: ```bash tar -xvzf cudnn-<version>-linux-x64-v<revision>.tgz ``` 接着将解压出来的 `include/` 和 `lib64/` 中的内容拷贝至对应的 CUDA 路径下: ```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 sudo chmod a+r /usr/local/cuda/lib64/libcudnn* ``` 上述操作会把头文件放置于 `/usr/local/cuda/include/` 目录,并赋予读权限;同时也会处理动态链接库文件,将其置于 `/usr/local/cuda/lib64/` 并设置适当权限。 #### 更新环境变量 (如果需要) 有时为了使新添加的路径生效可能需更新 `$PATH` 及 `$LD_LIBRARY_PATH` 环境变量。可以通过编辑用户的 shell 配置文件来实现这一点,比如 `.bashrc` 或者 `.zshrc`: ```bash export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH source ~/.bashrc # 刷新配置使之立即生效 ``` #### 校验安装情况 完成以上步骤之后,可通过运行简单的测试程序验证 cuDNN 是否被正确加载以及其功能是否正常运作。也可以通过特定工具查询当前系统的 cuDNN 版本号以确认安装无误[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

THMAIL

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值