安装 CUDA9.0 + cuDNN8.0

再唠叨之前的准备:

  • 1.修改资源镜像,可用脚本 ubuntu修改资源镜像

  • 2.系统保持最新
    sudo apt-get update
    sudo apt-get upgrade

我的环境:

OS: ubuntu 16.04.3
uname -a
Linux scott-Z170X-UD3 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609

敲黑板!

  • tensorflow 有CPU 版,GPU 版。

  • 不是所有显卡都支持CUDA,可以在这里看到cuda评分,推荐GPU Compute Capability 最少 >3.0

该网址查看 cuda计算能力评分 GPU Compute Capability


CUDA官方网址

你可以选择下载自己的平台安装包

我我用的是deb[local]

CUDA9.0 deb local ubuntu x64 下载地址

Installation Instructions:
sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

Other installation options are available in the form of meta-packages. For example, to install all the library packages, replace "cuda" with the "cuda-libraries-9-0" meta package. For more information on all the available meta packages click here.

The CUDA Toolkit contains Open-Source Software. The source code can be found here.
The checksums for the installer and patches can be found in Installer Checksums.
For further information, see the Installation Guide for Linux and the CUDA Quick Start Guide.

敲黑板!

推荐先看pdf [Installation Guide for Linux] , [CUDA Quick Start Guide] ,里面介绍了 不同平台的操作区别。
我只介绍ubuntu的安装

nvcc --version
提示找不到命令.我当时很奇怪。 之后,我用ubantu16.04的apt 软件库去安装Cuda compilation tools
sudo apt install nvidia-cuda-toolkit

再查询,发现ubuntu库中的cuda是7.5的,不是我这次安装的版本。
果断删除
sudo apt remove nvidia-cuda-toolkit

  • 上网找了资料,发现原来是需要更新环境变量

    • 编辑.bashrc: sudo gedit .bashrc
    • 添加cuda文件路径
    export PATH=/usr/local/cuda-9.0/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda-9.0/bin/lib64:$LD_LIBRARY_PATH
    • 需要更新环境变量,终端中输入: source ~/.bashrc

原理点此链接 在 Ubuntu 系统中有三种设置环境变量 PATH 的方法

  • 再查询,是9.0!到此CUDA9.0 安装成功

NVIDIA cuDNN is a GPU-accelerated library of primitives for deep neural networks.

[Download cuDNN v7.0.3 (Sept 28, 2017), for CUDA 9.0] (https://developer.nvidia.com/rdp/cudnn-download)

不同平台操作看guide

windows:
安装完CUDA,直接复制zip包下的文件到 CUDA_PATH

CUDA_PATH C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

验证驱动版

cat /proc/driver/nvidia/version

查看 Cuda compilation tools版本

nvcc --version或者nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

查看GPU 当前信息

nvidia-smi

Fri Oct 20 16:21:13 2017
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.81 Driver Version: 384.81 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 950 Off | 00000000:01:00.0 On | N/A |
| 33% 33C P8 12W / 100W | 332MiB / 1995MiB | 6% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 985 G /usr/lib/xorg/Xorg 214MiB |
| 0 1593 G compiz 95MiB |
| 0 1973 G fcitx-qimpanel 9MiB |
| 0 9093 G /usr/bin/vlc 8MiB |
+-----------------------------------------------------------------------------+

PCI 接口信息

lspci |grep NVIDIA

GeForce GTX 950安装CUDA 9.0后,PCI显卡显示如下

01:00.0 VGA compatible controller: NVIDIA Corporation GM206 [GeForce GTX 950] (rev a1)
01:00.1 Audio device: NVIDIA Corporation Device 0fba (rev a1)
posted @   scott_h  阅读(1209)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示