深度学习之CUDA——翻译NVIDIA CUDA Installation Guide for Linux (1)

NVIDIA CUDA Installation Guide for Linux

Linux系统下的NVIDIA CUDA 安装指南

1. Introduction

CUDA® is a parallel computing platform and programming model invented by NVIDIA. It enables dramatic increases in computing performance by harnessing the power of the graphics processing unit (GPU).

CUDA ®是由NVIDIA发明了一种并行计算平台和编程模型。它通过利用图形处理单元(GPU)的能力,可以显着提高计算性能。

CUDA was developed with several design goals in mind:
CUDA开发时考虑了几个设计目标:
Provide a small set of extensions to standard programming languages, like C, that enable a straightforward implementation of parallel algorithms. With CUDA C/C++, programmers can focus on the task of parallelization of the algorithms rather than spending time on their implementation.
Support heterogeneous computation where applications use both the CPU and GPU. Serial portions of applications are run on the CPU, and parallel portions are offloaded to the GPU. As such, CUDA can be incrementally applied to existing applications. The CPU and GPU are treated as separate devices that have their own memory spaces. This configuration also allows simultaneous computation on the CPU and GPU without contention for memory resources.
为标准编程语言(如C)提供一小组扩展,使得能够直接实现并行算法。使用CUDA C / C ++,程序员可以专注于算法的并行化任务,而不是花时间在它们的实现上。
支持异构计算,其中应用程序使用CPU和GPU。应用程序的串行部分在CPU上运行,并且并行部分被卸载到GPU。因此,CUDA可以递增地应用于现有应用程序。CPU和GPU被视为具有自己的存储空间的单独设备。此配置还允许在CPU和GPU上同时计算,而不争用存储器资源。
CUDA-capable GPUs have hundreds of cores that can collectively run thousands of computing threads. These cores have shared resources including a register file and a shared memory. The on-chip shared memory allows parallel tasks running on these cores to share data without sending it over the system memory bus.
This guide will show you how to install and check the correct operation of the CUDA development tools.
支持CUDA的GPU具有数百个内核,可以共同运行数千个计算线程。这些核具有共享资源,包括寄存器文件和共享存储器。片上共享内存允许在这些内核上运行的并行任务共享数据,而不通过系统内存总线发送数据。
本指南将向您展示如何安装和检查CUDA开发工具的正确操作。

1.1. System Requirements系统要求

To use CUDA on your system, you will need the following installed:
1、CUDA-capable GPU
2、A supported version of Linux with a gcc compiler and toolchain
3、NVIDIA CUDA Toolkit (available at http://developer.nvidia.com/cuda-downloads)
要在系统上使用CUDA,您需要安装以下软件:
1、支持CUDA的GPU
2、支持的Linux版本,带有gcc编译器和工具链
3、NVIDIA CUDA工具包

The CUDA development environment relies on tight integration with the host development environment, including the host compiler and C runtime libraries, and is therefore only supported on distribution versions that have been qualified for this CUDA Toolkit release.
CUDA开发环境依赖于与主机开发环境(包括主机编译器和C运行时库)的紧密集成,因此仅支持已获得此CUDA Toolkit版本的发行版本。

在CUDA表1原生Linux发行版支持8.0

系统 核心 GCC GLIBC
x86_64
Ubuntu 16.04 4.4.0 5.3.1 2.23
Ubuntu 14.04 3.13 4.8.2 2.19
(仅列出了Ubuntu系统,其余的略去)

1.2. About This Document

This document is intended for readers familiar with the Linux environment and the compilation of C programs from the command line. You do not need previous experience with CUDA or experience with parallel computation. Note: This guide covers installation only on systems with X Windows installed.
本文档供读者熟悉Linux环境和从命令行编译C程序。你不需要提前具备CUDA经验或并行计算经验。注意:本指南仅介绍安装X Windows的系统上的安装。
Note: Many commands in this document might require superuser privileges. On most distributions of Linux, this will require you to log in as root. For systems that have enabled the sudo package, use the sudo prefix for all necessary commands.
注:本文中的许多命令可能需要超级用户权限。在大多数Linux发行版上,这将要求您以root用户身份登录。对于已启用sudo包的系统,请对所有必要的命令使用sudo前缀。

2.Pre-installation Actions预安装操作

Some actions must be taken before the CUDA Toolkit and Driver can be installed on Linux:
要在系统上使用CUDA,您需要安装以下软件:

1、Verify the system has a CUDA-capable GPU.
2、Verify the system is running a supported version of Linux.
3、Verify the system has gcc installed.
4、Verify the system has the correct kernel headers and development packages installed.
5、Download the NVIDIA CUDA Toolkit.
6、Handle conflicting installation methods.

1、验证系统是否具有支持CUDA的GPU.
2、验证系统是否正在运行受支持的Linux版本
3、验证系统已经安装了gcc
4、验证系统是否安装了正确的内核头和开发包
5、下载NVIDIA CUDA工具包
6、处理冲突的安装方法
Note: You can override the install-time prerequisite checks by running the installer with the -override flag.Remember that the prerequisites will still be required to use the NVIDIA CUDA Toolkit.
注意:您可以通过使用-override标志运行安装程序来覆盖安装时间先决条件检查。请记住,仍然需要先决条件才能使用NVIDIA CUDA工具包。

2.1. Verify You Have a CUDA-Capable GPU 验证您是否具有支持CUDA的GPU

To verify that your GPU is CUDA-capable, go to your distribution’s equivalent of System Properties, or, from the command line, enter:
要验证您的GPU是否支持CUDA,请转到您的分布的等效系统属性,或从命令行输入:
$ lspci | grep -i nvidia

If you do not see any settings, update the PCI hardware database that Linux maintains by entering update-pciids (generally found in /sbin) at the command line and rerun the previous lspci command.
如果没有看到任何设置,请通过输入更新Linux维护的PCI硬件数据库 update-pciids (一般见于 / sbin)在命令行并重新运行前一个 lspci 命令。
If your graphics card is from NVIDIA and it is listed in http://developer.nvidia.com/cuda-gpus, your GPU is CUDA-capable.
The Release Notes for the CUDA Toolkit also contain a list of supported products.
如果你的显卡是来自NVIDIA的,它列在http://developer.nvidia.com/cuda-gpus,你的GPU是支持CUDA的。
CUDA工具包的版本说明还包含支持的产品列表。

2.2. Verify You Have a Supported Version of Linux 验证您是否具有受支持的Linux版本

The CUDA Development Tools are only supported on some specific distributions of Linux. These are listed in the CUDA Toolkit release notes.
CUDA开发工具仅支持某些特定的Linux发行版。这些在CUDA工具包版本注释中列出。
To determine which distribution and release number you’re running, type the following at the command line:
要确定您正在运行的分配和发行版号,请在命令行中键入以下内容:

$ uname -m && cat / etc / * release

You should see output similar to the following, modified for your particular system:
您应该看到类似于以下的输出,为您的特定系统修改:

x86_64 Red Hat Enterprise Linux Workstation release 6.0 (Santiago)
The x86_64 line indicates you are running on a 64-bit system. The remainder gives information about your distribution.
x86_64表示您正在64位操作系统上运行。剩余部分提供有关分发的信息。

2.3. Verify the System Has gcc Installed 验证系统是否已安装gcc

The gcc compiler is required for development using the CUDA Toolkit. It is not required for running CUDA applications. It is generally installed as part of the Linux installation, and in most cases the version of gcc installed with a supported version of Linux will work correctly.
gcc编译器是使用CUDA Toolkit进行开发所必需的。运行CUDA应用程序不需要它。它通常作为Linux安装的一部分安装,在大多数情况下,使用受支持版本的Linux安装的gcc版本将正常工作。

To verify the version of gcc installed on your system, type the following on the command line:

要验证系统上安装的gcc的版本,请在命令行中键入以下命令:
$ gcc –version

If an error message displays, you need to install the development tools from your Linux distribution or obtain a version of gcc and its accompanying toolchain from the Web.
如果显示错误消息,则需要从Linux发行版安装开发工具或获取版本gcc 和其伴随的工具链从Web。

2.4. Verify the System has the Correct Kernel Headers and Development Packages Installed 验证系统是否安装了正确的内核标头和开发包

The CUDA Driver requires that the kernel headers and development packages for the running version of the kernel be installed at the time of the driver installation, as well whenever the driver is rebuilt. For example, if your system is running kernel version 3.17.4-301, the 3.17.4-301 kernel headers and development packages must also be installed.
CUDA驱动程序要求在驱动程序安装时,以及在重新构建驱动程序时,安装运行版本内核的内核头文件和开发包。例如,如果您的系统运行的是内核版本3.17.4-301,则还必须安装3.17.4-301内核头文件和开发包。

While the Runfile installation performs no package validation, the RPM and Deb installations of the driver will make an attempt to install the kernel header and development packages if no version of these packages is currently installed.However, it will install the latest version of these packages, which may or may not match the version of the kernel your system is using.Therefore, it is best to manually ensure the correct version of the kernel headers and development packages are installed prior to installing the CUDA Drivers, as well as whenever you change the kernel version.
虽然Runfile安装不执行软件包验证,但如果当前未安装这些软件包的版本,驱动程序的RPM和Deb安装将尝试安装内核头文件和开发软件包。但是,它将安装这些软件包的最新版本,这可能与您的系统使用的内核版本不匹配。 因此,最好在安装CUDA驱动程序之前,以及每当更改内核版本时,手动确保安装正确版本的内核头文件和开发包。
The version of the kernel your system is running can be found by running the following command:
$ uname -r

This is the version of the kernel headers and development packages that must be installed prior to installing the CUDA Drivers.This command will be used multiple times below to specify the version of the packages to install.Note that below are the common-case scenarios for kernel usage.More advanced cases, such as custom kernel branches, should ensure that their kernel headers and sources match the kernel build they are running.
这是在安装CUDA驱动程序之前必须安装的内核头文件和开发包的版本。此命令将在下面多次使用,以指定要安装的软件包的版本。请注意,以下是内核使用的常见情况。更高级的情况,例如自定义内核分支,应该确保它们的内核头和源与它们正在运行的内核构建匹配。

RHEL/CentOS系统、Fedora系统、OpenSUSE/SLES系统 略

Ubuntu
The kernel headers and development packages for the currently running kernel can be installed with:
当前运行的内核的内核头文件和开发包可以安装:

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

Choose an Installation Method 选择安装方法

The CUDA Toolkit can be installed using either of two different installation mechanisms: distribution-specific packages, or a distribution-independent package.The distribution-independent package has the advantage of working across a wider set of Linux distributions, but does not update the distribution’s native package management system.The distribution-specific packages interface with the distribution’s native package management system.
CUDA工具包可以使用两种不同的安装机制安装:特定于发行版的包或与发行版无关的包。独立于分发的包具有跨越更广泛的Linux发行版的优点,但是不更新分发的本地包管理系统。特定于分发的包与分发的本地包管理系统接口。建议在可能的情况下使用特定于分发的软件包。

注意:不为x86_64版本以外的体系结构提供独立安装程序。对于本机以及交叉开发,必须使用特定于分发的安装程序安装工具包。有关更多详细信息,请参阅CUDA跨平台安装部分。

Download the NVIDIA CUDA Toolkit 下载NVIDIA CUDA工具包

NVIDIA CUDA工具包位于http://developer.nvidia.com/cuda-downloads

选择您正在使用的平台,并下载NVIDIA CUDA工具包。

The CUDA Toolkit contains the CUDA driver and tools needed to create, build and run a CUDA application as well as libraries, header files, CUDA samples source code, and other resources.
CUDA工具包包含创建,构建和运行CUDA应用程序所需的CUDA驱动程序和工具,以及库,头文件,CUDA示例源代码和其他资源。

下载验证
The download can be verified by comparing the MD5 checksum posted at http://developer.nvidia.com/cuda-downloads/checksums with that of the downloaded file.
下载可以通过比较发布的MD5校验核实http://developer.nvidia.com/cuda-downloads/checksums与下载文件。如果任一校验和不同,则下载的文件已损坏,需要重新下载。

要计算下载文件的MD5校验和,请运行以下命令:

$ md5sum 

Handle Conflicting Installation Methods 处理冲突的方法

Before installing CUDA, any previously installations that could conflict should be uninstalled.This will not affect systems which have not had CUDA installed previously, or systems where the installation method has been preserved (RPM/Deb vs. Runfile).See the following charts for specifics.
在安装CUDA之前,应该卸载任何以前可能发生冲突的安装。这不会影响以前没有安装CUDA的系统,或者保留安装方法的系统(RPM / Deb vs. Runfile)。有关详细信息,请参阅以下图表。
深度学习之CUDA——翻译NVIDIA CUDA Installation Guide for Linux (1)_第1张图片
使用以下命令卸载Toolkit runfile安装:

$ sudo /usr/local/cuda-XY/bin/uninstall_cuda_X.Y.pl

使用以下命令卸载驱动程序runfile安装:

$ sudo / usr / bin / nvidia-uninstall

使用以下命令卸载RPM / Deb安装:

 $ sudo apt-get --purge remove for Ubuntu

3. Package Manager Installation 软件包管理器安装

3.1Overview 概述

The Package Manager installation interfaces with your system’s package management system.When using RPM or Deb, the downloaded package is a repository package.Such a package only informs the package manager where to find the actual installation packages, but will not install them.
软件包管理器安装与系统软件包管理系统接口。当使用RPM或Deb时,下载的包是存储库包。这样的包只通知包管理器在哪里找到实际的安装包,但不会安装它们。
If those packages are available in an online repository, they will be automatically downloaded in a later step.Otherwise, the repository package also installs a local repository containing the installation packages on the system.Whether the repository is available online or installed locally, the installation procedure is identical and made of several steps.
如果这些软件包在联机存储库中可用,它们将在以后的步骤中自动下载。否则,存储库包还会在系统上安装包含安装包的本地存储库。无论存储库是联机可用还是本地安装,安装过程都是相同的,由几个步骤组成。

Distribution-specific instructions detail how to install CUDA:
分发特定说明详细说明如何安装CUDA:

RHEL/CentOS系统、Fedora系统、OpenSUSE/SLES系统 略

在最后注明了一些有用的安装包管理器功能。

3.6 Ubuntu

1、执行安装前操作
2、安装存储库元数据(Install repository meta-data)
Note: When using a proxy server with aptitude, ensure that wget is set up to use the same proxy settings before installing the cuda-repo package.

$ sudo dpkg -i cuda-repo- <distro> _ <version> _ <architecture> .deb

3、更新Apt存储库高速缓存
(Update the Apt repository cache)

$ sudo apt-get update

4、安装CUDA

$ sudo apt-get install cuda

5、执行安装后操作(下文将介绍)

3.7 Additional Package Manager Capabilities 附加软件包管理器功能

下面是包管理器的一些额外的功能。

3.7.1 可用安装包

The recommended installation package is the cuda package.This package will install the full set of other CUDA packages required for native development and should cover most scenarios.
推荐的安装包是 cuda包。此软件包将安装本机开发所需的所有其他CUDA软件包,并应涵盖大多数情况。
The cuda package installs all the available packages for native developments.That includes the compiler, the debugger, the profiler, the math libraries,… For x86_64 patforms, this also include NSight Eclipse Edition and the visual profiler It also includes the NVIDIA driver package.
cuda package安装所有可用的本地开发包。这包括编译器,调试器,分析器,数学库,对于x86_64 平台,这还包括NSight Eclipse版本和可视化分析器它还包括NVIDIA驱动程序包
On supported platforms, the cuda-cross-armhf, cuda-cross-aarch64,and cuda-cross-ppc64el packages install all the packages required for cross-platform development to ARMv7, ARMv8, and POWER8, respectively.The libraries and header files of the target architecture’s display driver package are also installed to enable the cross compilation of driver applications.The arch packages do not install the native display driver.
在支持的平台上 cuda-cross-armhf, cuda-cross-aarch64,和 cuda-cross-ppc64el 软件包将跨平台开发所需的所有软件包分别安装到ARMv7,ARMv8和POWER8。还安装了目标体系结构的显示驱动程序包的库和头文件,以实现驱动程序应用程序的交叉编译。arch 软件包不安装本机显示驱动程序。

The packages installed by the packages above can also be installed individually by specifying their names explicitly.
由上面的软件包安装的软件包也可以通过明确指定它们的名称来单独安装。可用包的列表可以获得:

$ cat / var / lib / apt / lists / * cuda * Packages | grep“Package:”#Ubuntu

3.7.2软件包升级

cuda包指向最新的CUDA工具包的稳定版本。当有新版本时,使用以下命令升级工具包和驱动程序:
$ sudo apt-get install cuda

cuda-drivers包指向CUDA存储库中提供的最新驱动程序版本。当有新版本时,使用以下命令升级驱动程序:

$ sudo apt-get install cuda-drivers

为了避免任何自动升级,并将工具箱安装锁定到XY版本,请安装 cuda-XY 要么 cuda-cross--X-Y 包。

你可能感兴趣的:(深度学习)