Skip to content

Commit

Permalink
Merge pull request #39 from tiagovrtr/use-tmp
Browse files Browse the repository at this point in the history
Skip download and copy of runfile if already present in tmp path
  • Loading branch information
VilleS1 authored Jul 8, 2021
2 parents 010ef7f + 7cebc50 commit e66eda6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ cuda_packages:
- cuda
cuda_use_runfile: False
cuda_runfile_url: "https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_460.32.03_linux.run"
cuda_runfile_checksum: True
cuda_runfile_checksum_url: "https://developer.download.nvidia.com/compute/cuda/11.2.2/docs/sidebar/md5sum.txt"
cuda_runfile_driver: True
cuda_runfile_toolkit: True
cuda_runfile_download: True
Expand Down
41 changes: 35 additions & 6 deletions tasks/install_runfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,41 @@
- "Driver installed: {{ cuda_driver_installed }}"
- "Toolkit installed: {{ cuda_toolkit_installed }}"

- name: "Create temporary directory for runfile"
file:
path: /tmp/cuda_runfile
state: directory
- name: Check runfile already exists
stat:
path: /tmp/cuda_runfile/{{ cuda_runfile_sh }}
checksum_algorithm: md5
register: cuda_runtime_file

- name: Download checksum file
get_url:
url: "{{ cuda_runfile_checksum_url }}"
dest: /tmp/cuda_checksum.tsv
when: cuda_runfile_checksum

- name: Get checksums from file
community.general.read_csv:
path: /tmp/cuda_checksum.tsv
delimiter: " "
fieldnames: checksum, file
key: file
register: checksums
when: cuda_runfile_checksum

- name: Get checksums from dict
set_fact:
cuda_runfile_valid_checksum: "{{checksums[ cuda_runfile_sh ].checksum}}" == cuda_runtime_file.stat.checksum
when: cuda_runtime_file.stat.exists


- name: "Obtain runfile"
block:

- name: "Create temporary directory for runfile"
file:
path: /tmp/cuda_runfile
state: directory

- name: "Copy pre-downloaded runfile"
copy:
src: "{{ cuda_runfile_sh }}"
Expand All @@ -74,8 +101,10 @@
dest: "/tmp/cuda_runfile/{{ cuda_runfile_sh }}"
when: cuda_runfile_download

when: (cuda_runfile_toolkit and not cuda_toolkit_installed) or
(cuda_runfile_driver and not cuda_driver_installed)
when: not (cuda_runtime_file.stat.exists and cuda_runfile_valid_checksum)
and ((cuda_runfile_toolkit and not cuda_toolkit_installed)
or (cuda_runfile_driver and not cuda_driver_installed))


- name: "Run installer for toolkit"
command: bash /tmp/cuda_runfile/{{ cuda_runfile_sh }} --silent --toolkit
Expand Down

0 comments on commit e66eda6

Please sign in to comment.