Skip to content
Snippets Groups Projects

Install cuDNN on Ubuntu

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Ahmed Amine Mchayaa

    Tested on

    • Ubuntu 22.04.3 LTS - x86_64

    Install cuDNN

    Download cuDNN .deb file

    You can download cuDNN file here. You will need an Nvidia account. Select the cuDNN version for the appropriate CUDA version, which is the version that appears when you run:

    nvcc --version

    Install cuDNN

    sudo apt install ./<filename.deb>
    sudo cp /var/cudnn-<something>.gpg /usr/share/keyrings/

    My cuDNN version is 8, adapt the following to your version:

    sudo apt update
    sudo apt install libcudnn8
    sudo apt install libcudnn8-dev
    sudo apt install libcudnn8-samples

    Test CUDA on Pytorch

    Create a virtualenv and activate it

    sudo apt-get install python3-pip
    sudo pip3 install virtualenv 
    virtualenv -p py3.10 venv
    source venv/bin/activate

    Install pytorch

    pip3 install torch torchvision torchaudio

    Open Python and execute a test

    import torch
    print(torch.cuda.is_available()) # should be True
    
    t = torch.rand(10, 10).cuda()
    print(t.device) # should be CUDA
    Edited
    cuDNN 1.03 KiB
    ## Install cuDNN
    
    ### Download cuDNN .deb file
    You can download cuDNN file [here](https://developer.nvidia.com/rdp/cudnn-download). You will need an Nvidia account.
    Select the cuDNN version for the appropriate CUDA version, which is the version that appears when you run:
    
    ```shell
    nvcc --version
    ```
    
    ### Install cuDNN
    ```shell
    sudo apt install ./<filename.deb>
    sudo cp /var/cudnn-<something>.gpg /usr/share/keyrings/
    ```
    
    My cuDNN version is 8, adapt the following to your version:
    
    ```shell
    sudo apt update
    sudo apt install libcudnn8
    sudo apt install libcudnn8-dev
    sudo apt install libcudnn8-samples
    ```
    
    ## Test CUDA on Pytorch
    
    
    ### Create a virtualenv and activate it
    ```shell
    sudo apt-get install python3-pip
    sudo pip3 install virtualenv 
    virtualenv -p py3.10 venv
    source venv/bin/activate
    ```
    
    ### Install pytorch
    ```shell
    pip3 install torch torchvision torchaudio
    ```
    
    ### Open Python and execute a test
    ```python
    import torch
    print(torch.cuda.is_available()) # should be True
    
    t = torch.rand(10, 10).cuda()
    print(t.device) # should be CUDA
    ```
    0% or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment