AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / ubuntu / Perguntas / 1077061
Accepted
Terrance
Terrance
Asked: 2018-09-21 14:11:25 +0800 CST2018-09-21 14:11:25 +0800 CST 2018-09-21 14:11:25 +0800 CST

Como instalo os drivers NVIDIA e CUDA no Ubuntu?

  • 772

EDIT: Adicionei uma nova resposta abaixo para Ubuntu 20.04 LTS e CUDA 11.1.1. Veja abaixo.


Eu tenho um sistema com uma placa NVIDIA com suporte de computação de 3,5+ em comparação com https://developer.nvidia.com/cuda-gpus . Como instalo os drivers CUDA e NVIDIA no Ubuntu sem baixar os arquivos .deb da NVIDIA?

nvidia cuda
  • 5 5 respostas
  • 134292 Views

5 respostas

  • Voted
  1. Terrance
    2018-09-21T14:13:21+08:002018-09-21T14:13:21+08:00

    Drivers Ubuntu 18.04, CUDA 10.1, libcudnn 7.5.1 e NVIDIA 418.67


    Notas

    • 07/01/2021 : Use a instalação 20.04 abaixo, pois as etapas são as mesmas para 18.04 e 20.04.

    • 23/06/2019 : As atualizações recentes com as versões CUDA 10.0 ou 10.1 do driver NVIDIA 418.67, instalado com ele, não possuem mais as bibliotecas de 32 bits incluídas e isso fará com que o Steam e a maioria dos jogos não funcionem mais. A versão de libnvidia-gl-418:i386instala apenas a versão 418.56 que não funcionará com o driver 418.67. Espero que a NVIDIA lance uma atualização para isso em breve. Eu adicionei as informações na parte inferior desta resposta na .run file installparte de como baixar apenas o arquivo de execução para o instalador CUDA, então você pode usar qualquer driver que desejar. O arquivo de execução tem 2,3 GB de tamanho, portanto, pode demorar um pouco para fazer o download.

    • CUDA 9.x não está disponível no repositório ubuntu1804 da NVIDIA. No entanto, escrevi uma resposta para CUDA 9.2 em https://askubuntu.com/a/1086993/231142


    Instalando o CUDA através do repositório (em vez da .debinstalação)

    As linhas a seguir você pode copiar e colar em uma janela de terminal. Pressione Ctrl+ Alt+ Tpara abrir uma janela de terminal.

    Remover e atualizar

    Remova todos os PPAs CUDA que possam ser configurados e também remova o nvidia-cuda-toolkitse instalado:

    sudo rm /etc/apt/sources.list.d/cuda*
    sudo apt remove --autoremove nvidia-cuda-toolkit
    

    Recomendado remover também todos os drivers NVIDIA antes de instalar novos drivers:

    sudo apt remove --autoremove nvidia-*
    

    Em seguida, atualize o sistema:

    sudo apt update
    

    Adicionar e instalar

    Recentemente, descobri que a instalação do CUDA funciona com o graphics-drivers ppaentão, se você não o adicionou, adicione-o agora:

    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt update
    

    A instalação do driver NVIDIA. Para isso vamos usar o driver 440

    sudo apt install nvidia-driver-440
    

    Agora, instale a chave:

    sudo apt-key adv --fetch-keys  http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
    

    Adicione os repositórios:

    sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
    
    sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda_learn.list'
    

    Atualize o sistema novamente:

    sudo apt update
    

    Instale o CUDA 10.1:

    sudo apt install cuda-10-1
    

    Ele deve instalar os drivers NVIDIA 418.40 com ele, pois são os listados no repositório. Consulte: http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/

    Instale libcudnn7 7.5.1:

    sudo apt install libcudnn7
    

    Ajuste o ambiente e reinicie

    Adicione as seguintes linhas ao seu ~/.profilearquivo para CUDA 10.1

    # set PATH for cuda 10.1 installation
    if [ -d "/usr/local/cuda-10.1/bin/" ]; then
        export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
        export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    fi
    

    Reinicie o computador.

    Verifique suas configurações

    Verifique o Compilador NVIDIA Cuda com nvcc --version:

    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2019 NVIDIA Corporation
    Built on Wed_Apr_24_19:10:27_PDT_2019
    Cuda compilation tools, release 10.1, V10.1.168
    

    Verifique a versão libcudnn /sbin/ldconfig -N -v $(sed 's/:/ /' <<< $LD_LIBRARY_PATH) 2>/dev/null | grep libcudnn:

    terrance@terrance-ubuntu:~$ /sbin/ldconfig -N -v $(sed 's/:/ /' <<< $LD_LIBRARY_PATH) 2>/dev/null | grep libcudnn
        libcudnn.so.7 -> libcudnn.so.7.5.1
    

    Verifique o driver NVIDIA com nvidia-smi:

    terrance@terrance-ubuntu:~$ nvidia-smi
    Wed Jan 29 12:41:02 2020       
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 440.48.02    Driver Version: 440.48.02    CUDA Version: 10.2     |
    |-------------------------------+----------------------+----------------------+
    | 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 750 Ti  Off  | 00000000:02:00.0  On |                  N/A |
    | 40%   34C    P0     1W /  38W |    163MiB /  2000MiB |      1%      Default |
    +-------------------------------+----------------------+----------------------+
                                                                                   
    +-----------------------------------------------------------------------------+
    | Processes:                                                       GPU Memory |
    |  GPU       PID   Type   Process name                             Usage      |
    |=============================================================================|
    |    0      1993      G   /usr/lib/xorg/Xorg                           158MiB |
    |    0      2502      G   compton                                        1MiB |
    +-----------------------------------------------------------------------------+
    

    .runarquivo de instalação

    Instalar driver

    Ao usar o sudo add-apt-repository ppa:graphics-drivers/ppa, você pode instalar o 430.26driver mais recente ou qualquer outro que se adeque a você.

    Instalar libcudnn7

    Adicione o repositório:

    sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda_learn.list'
    

    Instale a chave:

    sudo apt-key adv --fetch-keys  http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
    

    Atualize o sistema:

    sudo apt update
    

    Instale libcudnn7.5.1:

    sudo apt install libcudnn7
    

    Baixe o .runarquivo

    Agora baixe o cuda_10.1.105_418.39_linux.runde https://developer.nvidia.com/cuda-10.1-download-archive-base?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal

    Se você deseja o CUDA 10.2, as instruções de download estão aqui: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal Em seguida, siga as mesmas etapas abaixo, mas certifique-se de atualizar para 10.2 em vez de 10.1.

    Em seguida, execute o instalador:

    sudo sh cuda_10.1.105_418.39_linux.run
    

    Digite aceitar e pressione enter nesta tela:

    ┌──────────────────────────────────────────────────────────────────────────────┐
    │  End User License Agreement                                                  │
    │  --------------------------                                                  │
    │                                                                              │
    │                                                                              │
    │  Preface                                                                     │
    │  -------                                                                     │
    │                                                                              │
    │  The Software License Agreement in Chapter 1 and the Supplement              │
    │  in Chapter 2 contain license terms and conditions that govern               │
    │  the use of NVIDIA software. By accepting this agreement, you                │
    │  agree to comply with all the terms and conditions applicable                │
    │  to the product(s) included herein.                                          │
    │                                                                              │
    │                                                                              │
    │  NVIDIA Driver                                                               │
    │                                                                              │
    │                                                                              │
    │  Description                                                                 │
    │                                                                              │
    │  This package contains the operating system driver and                       │
    │──────────────────────────────────────────────────────────────────────────────│
    │ Do you accept the above EULA? (accept/decline/quit):                         │
    │ accept                                                                       
    

    Desmarque o driver e escolha Instalar usando as teclas de seta e a barra de espaço para mover e selecionar ou desmarcar:

    ┌──────────────────────────────────────────────────────────────────────────────┐
    │ CUDA Installer                                                               │
    │ - [ ] Driver                                                                 │
    │      [ ] 418.39                                                              │
    │ + [X] CUDA Toolkit 10.1                                                      │
    │   [X] CUDA Samples 10.1                                                      │
    │   [X] CUDA Demo Suite 10.1                                                   │
    │   [X] CUDA Documentation 10.1                                                │
    │   Install                                                                    │
    │   Options                                                                    │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │ Up/Down: Move | Left/Right: Expand | 'Enter': Select | 'A': Advanced options │
    

    Aguarde a conclusão da instalação, pode haver erros durante, mas não se preocupe.

    Ajuste o ambiente e reinicie

    Adicione as seguintes linhas ao seu ~/.profilearquivo para CUDA 10.1

    # set PATH for cuda 10.1 installation
    if [ -d "/usr/local/cuda-10.1/bin/" ]; then
        export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
        export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    fi
    

    Reinicie o sistema para que as alterações entrem em vigor.

    • 89
  2. Best Answer
    Terrance
    2020-10-31T12:53:27+08:002020-10-31T12:53:27+08:00

    Ubuntu 20.04 LTS, CUDA 11.5.0, NVIDIA 495 e libcudnn 8.0.4


    Não recomendo instalar os drivers NVIDIA que acompanham o CUDA, pois eles não contêm os drivers dkms que são transferidos para as novas atualizações do kernel.

    Os repositórios do Ubuntu agora contêm os mesmos drivers do graphics-driversPPA. Portanto, sinta-se à vontade para instalar os 495.44drivers.

    sudo apt install nvidia-driver-495
    

    Reinicie o sistema para que o novo driver entre em vigor.

    Agora, baixe o arquivo CUDA 11.5.0 .run da NVIDIA:

    wget https://developer.download.nvidia.com/compute/cuda/11.5.0/local_installers/cuda_11.5.0_495.29.05_linux.run
    

    Execute o .runarquivo como sudo:

    sudo sh ./cuda_11.5.0_495.29.05_linux.run
    

    Se você obtiver o seguinte, basta escolher Continue:

    ┌──────────────────────────────────────────────────────────────────────────────┐
    │ Existing package manager installation of the driver found. It is strongly    │
    │ recommended that you remove this before continuing.                          │
    │ Abort                                                                        │
    │ Continue                                                                     │
    │                                                                             
    

    Aceite o EULA:

    ┌──────────────────────────────────────────────────────────────────────────────┐
    │  End User License Agreement                                                  │
    │  --------------------------                                                  │
    │                                                                              │
    │  NVIDIA Software License Agreement and CUDA Supplement to                    │
    │  Software License Agreement. Last updated: October 8, 2021                   │
    │                                                                              │
    │  The CUDA Toolkit End User License Agreement applies to the                  │
    │  NVIDIA CUDA Toolkit, the NVIDIA CUDA Samples, the NVIDIA                    │
    │  Display Driver, NVIDIA Nsight tools (Visual Studio Edition),                │
    │  and the associated documentation on CUDA APIs, programming                  │
    │  model and development tools. If you do not agree with the                   │
    │  terms and conditions of the license agreement, then do not                  │
    │  download or use the software.                                               │
    │                                                                              │
    │  Last updated: October 8, 2021.                                              │
    │                                                                              │
    │                                                                              │
    │  Preface                                                                     │
    │  -------                                                                     │
    │                                                                              │
    │──────────────────────────────────────────────────────────────────────────────│
    │ Do you accept the above EULA? (accept/decline/quit):                         │
    │ accept                                                                       
    

    Desmarque o driver de vídeo pressionando a barra de espaço enquanto [X] Driverestiver realçado:

    ┌──────────────────────────────────────────────────────────────────────────────┐
    │ CUDA Installer                                                               │
    │ - [ ] Driver                                                                 │
    │      [ ] 495.29.05                                                           │
    │ + [X] CUDA Toolkit 11.5                                                      │
    │   [X] CUDA Samples 11.5                                                      │
    │   [X] CUDA Demo Suite 11.5                                                   │
    │   [X] CUDA Documentation 11.5                                                │
    │   Options                                                                    │
    │   Install                                                                    │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │ Up/Down: Move | Left/Right: Expand | 'Enter': Select | 'A': Advanced options │
    

    Em seguida, pressione a seta para baixo para Install. Pressione Entere aguarde a conclusão da instalação.

    After the installation is complete add the following to the bottom of your ~/.profile or add it to the /etc/profile.d/cuda.sh file which you might have to create for all users (global):

    # set PATH for cuda 11.5 installation
    if [ -d "/usr/local/cuda-11.5/bin/" ]; then
        export PATH=/usr/local/cuda-11.5/bin${PATH:+:${PATH}}
        export LD_LIBRARY_PATH=/usr/local/cuda-11.5/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    fi
    

    Install libcudnn8

    Add the Repo:

    NOTE: The 20.04 repo from NVIDIA does not supply libcudnn but the 18.04 repo does and installs just fine into 20.04.

    echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda_learn.list
    

    Install the key:

    sudo apt-key adv --fetch-keys  http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
    

    Update the system:

    sudo apt update
    

    Install libcudnn 8.0.4:

    sudo apt install libcudnn8
    

    I recommend now to reboot the system for the changes to take effect.

    After it reboots check the installations:

    ~$ nvidia-smi
    Thu Nov 18 07:31:31 2021       
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 495.44       Driver Version: 495.44       CUDA Version: 11.5     |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |                               |                      |               MIG M. |
    |===============================+======================+======================|
    |   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0  On |                  N/A |
    | 40%   38C    P8     1W /  38W |    310MiB /  2000MiB |      4%      Default |
    |                               |                      |                  N/A |
    +-------------------------------+----------------------+----------------------+
                                                                                   
    +-----------------------------------------------------------------------------+
    | Processes:                                                                  |
    |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
    |        ID   ID                                                   Usage      |
    |=============================================================================|
    |    0   N/A  N/A      2091      G   /usr/lib/xorg/Xorg                 46MiB |
    |    0   N/A  N/A      2680      G   /usr/lib/xorg/Xorg                163MiB |
    |    0   N/A  N/A      2906      G   compton                             1MiB |
    |    0   N/A  N/A      3262      G   /opt/waterfox/waterfox             85MiB |
    +-----------------------------------------------------------------------------+
    

    and check CUDA install:

    ~$ nvcc -V
    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2021 NVIDIA Corporation
    Built on Mon_Sep_13_19:13:29_PDT_2021
    Cuda compilation tools, release 11.5, V11.5.50
    Build cuda_11.5.r11.5/compiler.30411180_0
    

    and check libcudnn install:

    ~$ /sbin/ldconfig -N -v $(sed 's/:/ /' <<< $LD_LIBRARY_PATH) 2>/dev/null | grep libcudnn
        libcudnn_cnn_infer.so.8 -> libcudnn_cnn_infer.so.8.0.4
        libcudnn.so.8 -> libcudnn.so.8.0.4
        libcudnn_adv_train.so.8 -> libcudnn_adv_train.so.8.0.4
        libcudnn_ops_infer.so.8 -> libcudnn_ops_infer.so.8.0.4
        libcudnn_cnn_train.so.8 -> libcudnn_cnn_train.so.8.0.4
        libcudnn_adv_infer.so.8 -> libcudnn_adv_infer.so.8.0.4
        libcudnn_ops_train.so.8 -> libcudnn_ops_train.so.8.0.4
    
    • 15
  3. Eric Canton
    2021-10-26T09:40:14+08:002021-10-26T09:40:14+08:00

    I just want to add an alternative solution that ends up being much easier and modular, IMHO: use Nvidia's CUDA docker images!

    This does require a working (proprietary) driver on the host machine, which can be installed from Ubuntu repos (nvidia-driver-470 is the final supported driver version for CUDA compute 3.5).

    1. sudo apt install nvidia-driver-470
    2. Install Docker and nvidia-docker2. See this guide from Nvidia; if you're running Ubuntu 21+ you'll want to replace $distribution with ubuntu2004 in this step.
    3. Find the CUDA docker image you want on Nvidia's DockerHub page; for example, if you want CUDA 11.4.2 and cuDNN 8 you could run
      $ docker pull nvidia/cuda:11.4.2-cudnn8-devel-ubuntu20.04
      
    4. Now run a container from that image, attaching your GPUs:
      $ docker run -it --rm --gpus all nvidia/cuda:11.4.2-cudnn8-devel-ubuntu20.04
      
      You should verify the container can see your GPU by running nvidia-smi, which will show the same output you get from running nvidia-smi NOT inside of Docker.
    • 1
  4. MikeL
    2020-08-03T09:10:57+08:002020-08-03T09:10:57+08:00

    Para quem trabalha com AWS deep learning base AMI:
    A imagem vem com vários ambientes NVIDIA CUDA integrados e por padrão funciona com um deles (no meu caso 10), mas você pode alternar para qualquer outro, simplesmente alterando o link simbólico:

    $ sudo rm /usr/local/cuda
    $ sudo ln -s /usr/local/cuda-10.2 /usr/local/cuda
    

    Mais informações:
    https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-base.html

    • 0
  5. BarzanHayati
    2019-09-24T21:30:41+08:002019-09-24T21:30:41+08:00

    Não cometa um erro.

    Baixe o arquivo .deb de uma vez por todas.

    Baixei o arquivo .run e instalei. Mas, uma vez que tentei instalar o tensorrt, descobri que não poderia ser instalado com ele.

    Só consegui instalá-lo depois que um driver .deb nvidia foi instalado.

    • -1

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Existe um comando para listar todos os usuários? Também para adicionar, excluir, modificar usuários, no terminal?

    • 9 respostas
  • Marko Smith

    Como excluir um diretório não vazio no Terminal?

    • 4 respostas
  • Marko Smith

    Como descompactar um arquivo zip do Terminal?

    • 9 respostas
  • Marko Smith

    Como instalo um arquivo .deb por meio da linha de comando?

    • 11 respostas
  • Marko Smith

    Como instalo um arquivo .tar.gz (ou .tar.bz2)?

    • 14 respostas
  • Marko Smith

    Como listar todos os pacotes instalados

    • 24 respostas
  • Martin Hope
    Flimm Como posso usar o docker sem sudo? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    led-Zepp Como faço para salvar a saída do terminal em um arquivo? 2014-02-15 11:49:07 +0800 CST
  • Martin Hope
    ubuntu-nerd Como descompactar um arquivo zip do Terminal? 2011-12-11 20:37:54 +0800 CST
  • Martin Hope
    TheXed Como instalo um arquivo .deb por meio da linha de comando? 2011-05-07 09:40:28 +0800 CST
  • Martin Hope
    Ivan Como listar todos os pacotes instalados 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    David Barry Como determino o tamanho total de um diretório (pasta) na linha de comando? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher "Os seguintes pacotes foram retidos:" Por que e como resolvo isso? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford Como os PPAs podem ser removidos? 2010-07-30 01:09:42 +0800 CST

Hot tag

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve