---

# Can't count on nvidia_smi_log info from gpu_facts here because
# the driver may not be installed at all
- name: check for nvidia gpus
  shell: 'lspci | grep -q NVIDIA'
  register: has_nvidia_gpus
  changed_when: false
  failed_when: false

- include: nvidia.yml
  become: yes
  when: has_nvidia_gpus.rc == 0

- include: libcuda.yml
  become: yes
  when: (has_nvidia_gpus.rc != 0) or (force_install_cuda is defined)

- include: nvidia-container-runtime.yml
  become: yes
  when: has_nvidia_gpus.rc == 0

- include: nvidia-uvm-workaround.yml
  become: yes
  when:  gpus > 0 and ansible_distribution_version == "18.04"
  tags: uvm
