深度學習之CUDA——翻譯NVIDIA CUDA Installation Guide for Linux (1)__Linux

來源:互聯網
上載者:User
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 <file>
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)。有關詳細資料,請參閱以下圖表。

使用以下命令卸載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 <package_name>#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 包。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.