nvidia.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - block:
  16. - name: Add libnvidia container Repo
  17. yum_repository:
  18. name: libnvidia-container
  19. description: libnvidia-container
  20. baseurl: https://nvidia.github.io/libnvidia-container/stable/centos7/$basearch
  21. repo_gpgcheck: no
  22. gpgcheck: no
  23. gpgkey: https://nvidia.github.io/libnvidia-container/gpgkey
  24. sslverify: yes
  25. sslcacert: /etc/pki/tls/certs/ca-bundle.crt
  26. enabled: yes
  27. tags: install
  28. - name: Add nvidia-container-runtime Repo
  29. yum_repository:
  30. name: nvidia-container-runtime
  31. description: nvidia-container-runtime
  32. baseurl: https://nvidia.github.io/nvidia-container-runtime/stable/centos7/$basearch
  33. repo_gpgcheck: no
  34. gpgcheck: no
  35. gpgkey: https://nvidia.github.io/nvidia-container-runtime/gpgkey
  36. sslverify: yes
  37. sslcacert: /etc/pki/tls/certs/ca-bundle.crt
  38. enabled: yes
  39. tags: install
  40. - name: Add nvidia-docker Repo
  41. yum_repository:
  42. name: nvidia-docker
  43. description: nvidia-docker
  44. baseurl: https://nvidia.github.io/nvidia-docker/centos7/$basearch
  45. repo_gpgcheck: no
  46. gpgcheck: no
  47. gpgkey: https://nvidia.github.io/nvidia-docker/gpgkey
  48. enabled: yes
  49. sslverify: yes
  50. sslcacert: /etc/pki/tls/certs/ca-bundle.crt
  51. tags: install
  52. - name: Install nvidia driver and nvidia-docker2
  53. package:
  54. name: "{{ nvidia_packages }}"
  55. enablerepo: libnvidia-container,nvidia-docker
  56. state: present
  57. tags: install
  58. - name: Reboot after installing GPU drivers
  59. reboot:
  60. tags: install
  61. when: ( os_supported_leap not in compute_os )
  62. - block:
  63. - name: Fetching list of repos from zypper
  64. command: /usr/bin/zypper lr --uri
  65. changed_when: false
  66. register: zypper_repos
  67. tags: install
  68. - name: Add nvidia repository for leap
  69. command: zypper --gpg-auto-import-keys addrepo {{ nvidia_docker_repo }}
  70. failed_when: false
  71. changed_when: false
  72. when: '"nvidia-docker" not in zypper_repos.stdout'
  73. tags: install
  74. - name: Install libnvidia container repo
  75. zypper:
  76. name: libnvidia-container1
  77. disable_gpg_check: yes
  78. state: present
  79. tags: install
  80. - name: Install nvidia-container-runtime repo
  81. zypper:
  82. name: nvidia-container-runtime
  83. disable_gpg_check: yes
  84. state: present
  85. tags: install
  86. - name: Install nvidia-docker
  87. zypper:
  88. name: nvidia-container-runtime
  89. disable_gpg_check: yes
  90. replacefiles: true
  91. state: present
  92. tags: install
  93. - name: Reboot after installing GPU drivers
  94. reboot:
  95. tags: install
  96. when: ( os_supported_leap in compute_os ) and ( ansible_distribution_version >= os_supported_leap_version )
  97. - name: Set nvidia as default runtime
  98. copy:
  99. src: daemon.json
  100. dest: "{{ daemon_file_dest }}"
  101. owner: root
  102. group: root
  103. mode: "{{ daemon_file_mode }}"
  104. tags: install
  105. - name: Restart and enable docker service
  106. service:
  107. name: docker
  108. state: restarted
  109. enabled: yes
  110. daemon_reload: yes
  111. tags: install