Skip to content
Snippets Groups Projects

CUDA 11.7 and PyTorch 1.13.1 for DGX machine

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by François Pelletier

    This script allow to load all requires modules, create a project with a virtual environment and install PyTorch and relevant dependancies on the DGX machine

    Edited
    cuda_pytorch_for_dgx_machine.sh 743 B
    #!/bin/bash
    
    # Charger les modules pour CernVM-FS
    module load StdEnv/2020
    module load cudacore/.11.7.0
    module load nvhpc/22.7
    module load python/3.8.10
    
    # Créer un projet avec un environnement virtuel
    mkdir -p projet_avec_cuda
    cd projet_avec_cuda
    virtualenv -p /usr/bin/python3.8 venv
    source venv/bin/activate
    
    # Installer la dernière version de PyTorch 1.* avec les dépendances qui fonctionnent avec CUDA 11.7
    pip3 install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1+cu117 -f https://download.pytorch.org/whl/torch_stable.html
    
    # Tester la détection du GPU par PyTorch
    python <<HEREDOC
    import torch
    print(torch.cuda.is_available()) # devrait afficher True
    print(torch.cuda.device_count()) # devrait afficher 8
    HEREDOC
    • Version avec Python 3.10 et CUDA 11.7

      #!/bin/bash
      
      # Charger les modules pour CernVM-FS
      
      module load StdEnv/2023  
      module load scipy-stack/2024a
      module load nvhpc/23.9
      module load python/3.10
      
      # Créer un projet avec un environnement virtuel
      
      mkdir -p projet_avec_cuda  
      cd projet_avec_cuda  
      virtualenv -p /cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/python/3.10.13/bin/python venv  
      source venv/bin/activate
      
      # Installer la dernière version de PyTorch 1.\* avec les dépendances qui fonctionnent avec CUDA 11.7
      
      pip3 install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1+cu117 -f https://download.pytorch.org/whl/torch_stable.html
      
      # Tester la détection du GPU par PyTorch
      
      python <<HEREDOC  
      import torch  
      print(torch.cuda.is_available()) # devrait afficher True  
      print(torch.cuda.device_count()) # devrait afficher 8  
      HEREDOC
      Edited by François Pelletier
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment