Cuda installation guide linux

Установка CUDA в Ubuntu

Видеокарты уже давно перестали быть только устройствами, способными рисовать красивую графику в играх. Перед ними всё чаще ставят задачи, связанные со сложными математическими вычислениями, расчётами и искусственным интеллектом. Видеокарты намного лучше справляются с такими заданиями, чем обычные процессоры. Именно для того, чтобы обеспечить работу своих карт в этой сфере, NVIDIA выпустила платформу CUDA (Compute Unified Device Architecture).

В этой статье мы рассмотрим, как выполняется установка Cuda Ubuntu, как установить библиотеки и окружение для разработки, а также необходимую версию программы.

Что такое Nvidia CUDA

Архитектура CUDA позволяет разработчикам использовать вычислительные возможности видеокарт Nvidia для параллельных расчётов. Это очень сильно повышает производительность программ, которым нужно решать много однообразных задач. Одни из самых популярных способов применения CUDA — это майнинг криптовалюты, а также разработки в сфере искусственного интеллекта.

Платформа позволяет программистам самим управлять доступными инструкциями видеоускорителя, а также распределять память. Все программы пишутся на Си-подобном языке программирования.

Какую версию CUDA выбрать

На данный момент самая свежая версия NVIDIA CUDA Ubuntu — девятая. Если вы собрались создавать собственное программное обеспечение на основе этой платформы, лучше всего начать с этой или восьмой версии. Но если вам нужно запустить в системе программу, которая уже собрана под определенный вариант CUDA, то вам придется ставить именно его. Потому что между более старыми и новыми вариациями есть серьезные отличия, и приложение может попросту не заработать. Попытайтесь запустить нужную вам программу и посмотрите, каких библиотек ей не хватает в сообщении об ошибке:

Или же эту информацию можно найти в описании программы. Обычно разработчики пишут, какая версия CUDA нужна для работы. А теперь давайте рассмотрим, как выполняется установка CUDA на Ubuntu 16.04, 17.10 и другие модификации этого дистрибутива.

Установка CUDA из репозиториев Ubuntu

Нужно отметить, что для успешной работы Nvidia, CUDA необходимо, чтобы уже был установлен драйвер NVIDIA. Сейчас в официальных репозиториях Ubuntu находится восьмая версия платформы. Вы можете без проблем её установить, выполнив всего несколько команд. Сначала обновите списки пакетов:

sudo apt update

Затем наберите такую команду, чтобы установить CUDA Ubuntu:

sudo apt install nvidia-cuda-toolkit

Если вам также нужны заголовочные файлы для разработки, то понадобится дополнительно установить пакет nvidia-cuda-dev:

sudo apt install nvidia-cuda-dev

Установка платформы может длиться достаточно много времени, поскольку все необходимые библиотеки занимают около одного гигабайта. После завершения установки вы можете проверить, всё ли работает, выполнив:

Установка CUDA 9 в Ubuntu

Самая свежая на данный момент, как уже упоминалось, версия — Nvidia Cuda 9.0. Она включает некоторые алгоритмы для ускорения вычислений в приложениях AI и HPC на видеокартах NVIDIA Volta. Кроме того, были исправлены некоторые ошибки и проблемы платформы. Но для девятки нужен свежий драйвер Nvidia 384. Установить его вы можете с официального сайта.

Тут вам необходимо выбрать операционную систему, архитектуру и дистрибутив Linux, а в самом конце — способ установки (deb-пакет).

Только после этого появиться ссылка на установщик. Скачайте его, нажав кнопку Download 1.2 GB, и запустите установку с помощью dpkg:

Перед тем, как будет выполнена установка CUDA 9 Ubuntu, вам необходимо добавить ключ репозитория:

sudo apt-key add /var/cuda-repo-ubuntu1704-9-1-local_9.1.85-1/7fa2af80.pub

И обновить список пакетов:

sudo apt update

Затем можно установить CUDA 9 в Ubuntu:

sudo apt install cuda cuda-libraries-9.1

Готово, теперь можете проверить версию:

Установка CUDA 6.5, 7 или другой версии

Для многих программ необходима определенная версия CUDA, например, многие майнеры были собраны только с версией 6.5, и поэтому вам нужно будет установить именно эти библиотеки, чтобы всё заработало. На сайте Nvidia есть архив со всеми предыдущими версиями платформы. Рассмотрим установку на примере версии 6.5. Первое, что вам нужно выбрать — версия:

Затем выберите операционную систему Linux x86:

А дальше установочный deb-пакет для Ubuntu 14.04. Проверено на Ubuntu 17.10: установка работает. После загрузки пакета репозитория выполните:

sudo apt install

Далее обновите список пакетов:

sudo apt update

Осталась установка CUDA Ubuntu нужной вам версии:

sudo apt install nvidia-cuda-6.5

Поскольку программа размещается в /usr/local, нужно добавить путь к её папке в переменную среды PATH и LD_PRELOAD:

/.bashrc
echo «export PATH=/usr/local/cuda-6.5/bin:$PATH» >>

/.bashrc
echo «export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH» >>

Готово, после этого можно проверять версию:

Удаление Cuda из Ubuntu

Удалить Nvidia CUDA вы можете также, как и устанавливали. Еесли вы ставили nvidia-cuda-toolkit, то для удаления достаточно набрать:

sudo apt purge nvidia-cuda-toolkit

Или для версии 6.5:

sudo apt purge nvidia-cuda-toolkit-6.5

Также не забудьте удалить репозиторий:

sudo apt purge cuda-repo-ubuntu1404

Имя пакета может отличаться в зависимости от версии. Если вы выполняли установку с помощью бинарного файла или из исходников, то для удаления нужно использовать скрипт, который вы применяли при инсталляции.

Выводы

В этой небольшой статье мы рассмотрели, как выполняется установка CUDA Ubuntu 17.10 и в других версиях этой операционной системы. Как видите, это не так сложно, и вы можете установить не только последнюю версию, но и ту, которая вам нужна.

Источник

Cuda installation guide linux

Minimal first-steps instructions to get CUDA running on a standard system.

1. Introduction

This guide covers the basic instructions needed to install CUDA and verify that a CUDA application can run on each supported platform.

Читайте также:  Средство передачи данных windows

These instructions are intended to be used on a clean installation of a supported platform. For questions which are not answered in this document, please refer to the Windows Installation Guide and Linux Installation Guide.

The CUDA installation packages can be found on the CUDA Downloads Page.

2. Windows

When installing CUDA on Windows, you can choose between the Network Installer and the Local Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. For more details, refer to the Windows Installation Guide.

2.1. Network Installer

Perform the following steps to install CUDA and verify the installation.

  1. Launch the downloaded installer package.
  2. Read and accept the EULA.
  3. Select «next» to download and install all components.
  4. Once the download completes, the installation will begin automatically.
  5. Once the installation completes, click «next» to acknowledge the Nsight Visual Studio Edition installation summary.
  6. Click «close» to close the installer.
  7. Navigate to the CUDA Samples’ nbody directory.
  8. Open the nbody Visual Studio solution file for the version of Visual Studio you have installed.

2.2. Local Installer

Perform the following steps to install CUDA and verify the installation.

  1. Launch the downloaded installer package.
  2. Read and accept the EULA.
  3. Select «next» to install all components.
  4. Once the installation completes, click «next» to acknowledge the Nsight Visual Studio Edition installation summary.
  5. Click «close» to close the installer.
  6. Navigate to the CUDA Samples’ nbody directory.
  7. Open the nbody Visual Studio solution file for the version of Visual Studio you have installed.

2.3. Pip Wheels — Windows

NVIDIA provides Python Wheels for installing CUDA through pip, primarily for using CUDA with Python. These packages are intended for runtime use and do not currently include developer tools (these can be installed separately).

Please note that with this installation method, CUDA installation environment is managed via pip and additional care must be taken to set up your host environment to use CUDA outside the pip environment.

2.4. 3.1.6. 3.2.3. Conda

The Conda packages are available at https://anaconda.org/nvidia.

To perform a basic install of all CUDA Toolkit components using Conda, run the following command:

To uninstall the CUDA Toolkit using Conda, run the following command:

3. Linux

CUDA on Linux can be installed using an RPM, Debian, Runfile, or Conda package, depending on the platform being installed on.

3.1. Linux x86_64

For development on the x86_64 architecture. In some cases, x86_64 systems may act as host platforms targeting other architectures. See the Linux Installation Guide for more details.

3.1.1. Redhat / CentOS

When installing CUDA on Redhat or CentOS, you can choose between the Runfile Installer and the RPM Installer. The Runfile Installer is only available as a Local Installer. The RPM Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. In the case of the RPM installers, the instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.

3.1.1.1. RPM Installer

Perform the following steps to install CUDA and verify the installation.

  1. Install EPEL to satisfy the DKMS dependency by following the instructions at EPEL’s website.
  2. Enable optional repos:

On RHEL 7 Linux only, execute the following steps to enable optional repositories.

  • On x86_64 workstation:
  • On POWER9 system:
  • On x86_64 server:
  • Install the repository meta-data, clean the yum cache, and install CUDA:
  • Reboot the system to load the NVIDIA drivers.
  • Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
  • Install a writable copy of the samples then build and run the nbody sample:

    3.1.1.2. Runfile Installer

    Perform the following steps to install CUDA and verify the installation.

    3.1.2. Fedora

    When installing CUDA on Fedora, you can choose between the Runfile Installer and the RPM Installer. The Runfile Installer is only available as a Local Installer. The RPM Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. In the case of the RPM installers, the instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.

    3.1.2.1. RPM Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Install the RPMFusion free repository to satisfy the Akmods dependency:
    2. Install the repository meta-data, clean the dnf cache, and install CUDA:
    3. Reboot the system to load the NVIDIA drivers.
    4. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    5. Install a writable copy of the samples then build and run the nbody sample:

    3.1.2.2. Runfile Installer

    Perform the following steps to install CUDA and verify the installation.

    3.1.3. SUSE Linux Enterprise Server

    When installing CUDA on SUSE Linux Enterprise Server, you can choose between the Runfile Installer and the RPM Installer. The Runfile Installer is only available as a Local Installer. The RPM Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. In the case of the RPM installers, the instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.

    3.1.3.1. RPM Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Install the repository meta-data, refresh the Zypper cache, and install CUDA:
    2. Add the user to the video group:
    3. Reboot the system to load the NVIDIA drivers.
    4. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    5. Install a writable copy of the samples then build and run the vectorAdd sample:

    3.1.3.2. Runfile Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Reboot into runlevel 3 by temporarily adding the number «3» and the word «nomodeset» to the end of the system’s kernel boot parameters.
    2. Run the installer silently to install with the default selections (implies acceptance of the EULA):
    3. Create an xorg.conf file to use the NVIDIA GPU for display:
    4. Reboot the system to load the graphical interface.
    5. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    6. Install a writable copy of the samples then build and run the vectorAdd sample:

    3.1.4. OpenSUSE

    When installing CUDA on OpenSUSE, you can choose between the Runfile Installer and the RPM Installer. The Runfile Installer is only available as a Local Installer. The RPM Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. In the case of the RPM installers, the instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.

    3.1.4.1. RPM Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Install the repository meta-data, refresh the Zypper cache, and install CUDA:
    2. Add the user to the video group:
    3. Reboot the system to load the NVIDIA drivers.
    4. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    5. Install a writable copy of the samples then build and run the nbody sample:

    3.1.4.2. Runfile Installer

    Perform the following steps to install CUDA and verify the installation.

    3.1.5. Pip Wheels — Linux

    NVIDIA provides Python Wheels for installing CUDA through pip, primarily for using CUDA with Python. These packages are intended for runtime use and do not currently include developer tools (these can be installed separately).

    Please note that with this installation method, CUDA installation environment is managed via pip and additional care must be taken to set up your host environment to use CUDA outside the pip environment.

    The following metapackages will install the latest version of the named component on Linux for the indicated CUDA version. «cu11» should be read as «cuda11».

    • nvidia-cuda-runtime-cu11
    • nvidia-cuda-cupti-cu11
    • nvidia-cuda-nvcc-cu11
    • nvidia-nvml-dev-cu11
    • nvidia-cuda-nvrtc-cu11
    • nvidia-nvtx-cu11
    • nvidia-cuda-sanitizer-api-cu11
    • nvidia-cublas-cu11
    • nvidia-cufft-cu11
    • nvidia-curand-cu11
    • nvidia-cusolver-cu11
    • nvidia-cusparse-cu11
    • nvidia-npp-cu11
    • nvidia-nvjpeg-cu11

    These metapackages install the following packages:

    • nvidia-nvml-dev-cu114
    • nvidia-cuda-nvcc-cu114
    • nvidia-cuda-runtime-cu114
    • nvidia-cuda-cupti-cu114
    • nvidia-cublas-cu114
    • nvidia-cuda-sanitizer-api-cu114
    • nvidia-nvtx-cu114
    • nvidia-cuda-nvrtc-cu114
    • nvidia-npp-cu114
    • nvidia-cusparse-cu114
    • nvidia-cusolver-cu114
    • nvidia-curand-cu114
    • nvidia-cufft-cu114
    • nvidia-nvjpeg-cu114

    Conda

    The Conda packages are available at https://anaconda.org/nvidia.

    To perform a basic install of all CUDA Toolkit components using Conda, run the following command:

    To uninstall the CUDA Toolkit using Conda, run the following command:

    3.1.7. WSL

    These instructions must be used if you are installing in a WSL environment. Do not use the Ubuntu instructions in this case.

      Install repository meta-data

    When installing using the local repo:

    When installing using the network repo:

    Pin file to prioritize CUDA repository:

    Update the Apt repository cache and install CUDA

    3.1.8. Ubuntu

    When installing CUDA on Ubuntu, you can choose between the Runfile Installer and the Debian Installer. The Runfile Installer is only available as a Local Installer. The Debian Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. In the case of the Debian installers, the instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.

    3.1.8.1. Debian Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Install the repository meta-data, install GPG key, update the apt-get cache, and install CUDA:
    2. Reboot the system to load the NVIDIA drivers.
    3. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    4. Install a writable copy of the samples then build and run the nbody sample:

    3.1.8.2. Runfile Installer

    Perform the following steps to install CUDA and verify the installation.

    3.1.9. Debian

    When installing CUDA on Debian 10, you can choose between the Runfile Installer and the Debian Installer. The Runfile Installer is only available as a Local Installer. The Debian Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. For more details, refer to the Linux Installation Guide.

    3.1.9.1. Debian Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Install the repository meta-data, install GPG key, update the apt-get cache, and install CUDA:
    2. Reboot the system to load the NVIDIA drivers.
    3. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    4. Install a writable copy of the samples then build and run the nbody sample:

    3.1.9.2. Runfile Installer

    Perform the following steps to install CUDA and verify the installation.

    3.2. Linux POWER8

    For development on the POWER8 architecture.

    3.2.1. Ubuntu

    When installing CUDA on Ubuntu on POWER8, you must use the Debian Installer. The Debian Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. The instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.

    3.2.1.1. Debian Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Install the repository meta-data, update the apt-get cache, and install CUDA:
    2. Reboot the system to load the NVIDIA drivers.
    3. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    4. Install a writable copy of the samples then build and run the vectorAdd sample:

    3.2.2. Redhat / CentOS

    When installing CUDA on Redhat on POWER8, you must use the RPM Installer. The RPM Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. The instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.

    3.2.2.1. RPM Installer

    Perform the following steps to install CUDA and verify the installation.

    1. Install EPEL to satisfy the DKMS dependency by following the instructions at EPEL’s website.
    2. Install the repository meta-data, clean the yum cache, and install CUDA:
    3. Reboot the system to load the NVIDIA drivers.
    4. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
    5. Install a writable copy of the samples then build and run the vectorAdd sample:

    Conda

    The Conda packages are available at https://anaconda.org/nvidia.

    To perform a basic install of all CUDA Toolkit components using Conda, run the following command:

    To uninstall the CUDA Toolkit using Conda, run the following command:

    Notices

    Notice

    This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. NVIDIA Corporation (“NVIDIA”) makes no representations or warranties, expressed or implied, as to the accuracy or completeness of the information contained in this document and assumes no responsibility for any errors contained herein. NVIDIA shall have no liability for the consequences or use of such information or for any infringement of patents or other rights of third parties that may result from its use. This document is not a commitment to develop, release, or deliver any Material (defined below), code, or functionality.

    NVIDIA reserves the right to make corrections, modifications, enhancements, improvements, and any other changes to this document, at any time without notice.

    Customer should obtain the latest relevant information before placing orders and should verify that such information is current and complete.

    NVIDIA products are sold subject to the NVIDIA standard terms and conditions of sale supplied at the time of order acknowledgement, unless otherwise agreed in an individual sales agreement signed by authorized representatives of NVIDIA and customer (“Terms of Sale”). NVIDIA hereby expressly objects to applying any customer general terms and conditions with regards to the purchase of the NVIDIA product referenced in this document. No contractual obligations are formed either directly or indirectly by this document.

    NVIDIA products are not designed, authorized, or warranted to be suitable for use in medical, military, aircraft, space, or life support equipment, nor in applications where failure or malfunction of the NVIDIA product can reasonably be expected to result in personal injury, death, or property or environmental damage. NVIDIA accepts no liability for inclusion and/or use of NVIDIA products in such equipment or applications and therefore such inclusion and/or use is at customer’s own risk.

    NVIDIA makes no representation or warranty that products based on this document will be suitable for any specified use. Testing of all parameters of each product is not necessarily performed by NVIDIA. It is customer’s sole responsibility to evaluate and determine the applicability of any information contained in this document, ensure the product is suitable and fit for the application planned by customer, and perform the necessary testing for the application in order to avoid a default of the application or the product. Weaknesses in customer’s product designs may affect the quality and reliability of the NVIDIA product and may result in additional or different conditions and/or requirements beyond those contained in this document. NVIDIA accepts no liability related to any default, damage, costs, or problem which may be based on or attributable to: (i) the use of the NVIDIA product in any manner that is contrary to this document or (ii) customer product designs.

    No license, either expressed or implied, is granted under any NVIDIA patent right, copyright, or other NVIDIA intellectual property right under this document. Information published by NVIDIA regarding third-party products or services does not constitute a license from NVIDIA to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property rights of the third party, or a license from NVIDIA under the patents or other intellectual property rights of NVIDIA.

    Reproduction of information in this document is permissible only if approved in advance by NVIDIA in writing, reproduced without alteration and in full compliance with all applicable export laws and regulations, and accompanied by all associated conditions, limitations, and notices.

    THIS DOCUMENT AND ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, “MATERIALS”) ARE BEING PROVIDED “AS IS.” NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL NVIDIA BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ANY USE OF THIS DOCUMENT, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Notwithstanding any damages that customer might incur for any reason whatsoever, NVIDIA’s aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms of Sale for the product.

    Источник

    Читайте также:  Что делать если нет windows sonic
  • Оцените статью