hunk.code_window:           which python
             python --version
             which hipcc
             hipcc --version
             python -c "import torch; print('torch:', torch.__version__, torch)"
             python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
             sudo apt-get update
             sudo apt-get install -y libaio-dev
  
hunk.labels: keep keep keep add keep keep keep keep
hunk.after_edit:           pip install --upgrade pip
             pip uninstall --yes torch torchvision
             pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1
  
hunk.file_path: .github/workflows/amd.yml
hunk.type: add
file: import torch
  from deepspeed.git_version_info import torch_info
  
  
  def required_torch_version():
      TORCH_MAJOR = int(torch.__version__.split('.')[0])
      TORCH_MINOR = int(torch.__version__.split('.')[1])
  
      if TORCH_MAJOR >= 1 and TORCH_MINOR >= 8:
          return True
      else:
          return False
  
  
  def bf16_required_version_check():
      split_version = lambda x: map(int, x.split('.')[:2])
      TORCH_MAJOR, TORCH_MINOR = split_version(torch_info['version'])
      NCCL_MAJOR, NCCL_MINOR = split_version(torch_info['nccl_version'])
      CUDA_MAJOR, CUDA_MINOR = split_version(torch_info['cuda_version'])
  
      if (TORCH_MAJOR > 1 or
          (TORCH_MAJOR == 1 and TORCH_MINOR >= 10)) and (CUDA_MAJOR >= 11) and (
              NCCL_MAJOR > 2 or
              (NCCL_MAJOR == 2 and NCCL_MINOR >= 10)) and torch_info['bf16_support']:
          return True
      else:
          return False
  
  
  def required_minimum_torch_version(major_version, minor_version):
      TORCH_MAJOR = int(torch.__version__.split('.')[0])
      TORCH_MINOR = int(torch.__version__.split('.')[1])
  
      if TORCH_MAJOR < major_version:
          return False
  
      return TORCH_MAJOR > major_version or TORCH_MINOR >= minor_version
  
  
  def required_maximum_torch_version(major_version, minor_version):
      TORCH_MAJOR = int(torch.__version__.split('.')[0])
      TORCH_MINOR = int(torch.__version__.split('.')[1])
  
      if TORCH_MAJOR > major_version:
          return False
  
      return TORCH_MAJOR < major_version or TORCH_MINOR <= minor_version
  