Skip to content

Installing deep learning packages

Match builds to current GPUs

Choose framework builds that match the GPUs on the current clusters (A100 on Hopper; L40S and H100 on Easley), and check exact package versions before installing.

This step-by-step guide walks through installing deep learning and machine learning tools in a conda environment on CARC systems.

Set up the conda environment

  1. Load the Anaconda module to get the conda command:

    module load anaconda3
    
  2. Create a conda environment with a name:

    conda create --name <env_name> python==3.6
    
  3. Verify the environment was created:

    conda info --envs
    
  4. Activate the environment:

    source activate <env_name>
    

Install deep learning packages

Install one or more of the following, as your work requires.

conda install -c anaconda tensorflow-gpu
conda install -c anaconda keras-gpu
conda install pytorch torchvision -c pytorch

First make sure Python 3.7 is installed in your current environment:

conda create -n <env_name> python==3.7
source activate <env_name>

Then install the K40-compatible build that CARC staged in shared storage, plus the matching CUDA toolkit:

conda install /projects/shared/pytorch/PyTorch1.5-K40-Compatible/pytorch-1.5.0-py3.7_cuda10.1.243_cudnn7.6.3_0.tar.bz2
conda install cudatoolkit=10.1.243

Verify GPU access from PyTorch

Run the following Python code on a GPU node (request one first — see example Slurm scripts):

import torch
from torch import nn, tensor
from torch.cuda import device_count

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
x = torch.rand(5, 3)
print(x)
print("Is GPU Available?", torch.cuda.is_available(),
      " CUDA device count:", torch.cuda.device_count(),
      "current_device:", torch.cuda.current_device())
x = torch.tensor([1, 2, 3], device=device)
y = torch.tensor([1, 4, 9]).to(device)
print(x, y)
print(x + y)

Expected output:

tensor([[0.3220, 0.2174, 0.1226],
        [0.7249, 0.8111, 0.8414],
        [0.5974, 0.5169, 0.5242],
        [0.1436, 0.5150, 0.5688],
        [0.3298, 0.1289, 0.5349]])
Is GPU Available? True  CUDA device count: 1  current_device: 0
tensor([1, 2, 3], device='cuda:0') tensor([1, 4, 9], device='cuda:0')
tensor([ 2,  6, 12], device='cuda:0')

Additional machine learning packages

# OpenCV
conda install -c conda-forge opencv

# numpy, pandas, matplotlib, scikit-learn
conda install numpy pandas matplotlib scikit-learn

Migrated from UNM-CARC QuickBytes (last source update 2021-10-15), then restructured with fenced code blocks and curated in this repository. Spotted a problem? Open an issue or pull request.