|
| 1 | +- name: Read cuda version file |
| 2 | + slurp: |
| 3 | + src: /usr/local/cuda/version.json |
| 4 | + register: _cuda_samples_version |
| 5 | + |
| 6 | +- name: Set fact for discovered cuda version |
| 7 | + set_fact: |
| 8 | + cuda_version_tuple: "{{ (_cuda_samples_version.content | b64decode | from_json).cuda.version | split('.') }}" # e.g. '12.1.0' |
| 9 | + |
| 10 | +- name: Ensure cuda_samples_path exists |
| 11 | + file: |
| 12 | + state: directory |
| 13 | + path: "{{ cuda_samples_path }}" |
| 14 | + owner: "{{ ansible_user }}" |
| 15 | + group: "{{ ansible_user }}" |
| 16 | + |
| 17 | +- name: Download cuda sample release |
| 18 | + unarchive: |
| 19 | + remote_src: yes |
| 20 | + src: "{{ cuda_samples_release_url }}" |
| 21 | + dest: "{{ cuda_samples_path }}" |
| 22 | + owner: "{{ ansible_user }}" |
| 23 | + group: "{{ ansible_user }}" |
| 24 | + |
| 25 | +- name: Build cuda samples |
| 26 | + shell: |
| 27 | + cmd: make |
| 28 | + chdir: "{{ cuda_samples_path }}/cuda-samples-{{ cuda_version_short }}/Samples/1_Utilities/{{ item }}" |
| 29 | + creates: "{{ cuda_samples_path }}/cuda-samples-{{ cuda_version_short }}/bin/x86_64/linux/release/{{ item }}" |
| 30 | + loop: "{{ cuda_samples_programs }}" |
| 31 | + |
| 32 | +- name: Run cuda deviceQuery |
| 33 | + command: |
| 34 | + cmd: "{{ cuda_samples_path }}/cuda-samples-{{ cuda_version_short }}/bin/x86_64/linux/release/deviceQuery" |
| 35 | + register: _cuda_devicequery |
| 36 | + |
| 37 | +- name: Set fact for cuda devices |
| 38 | + set_fact: |
| 39 | + cuda_devices: "{{ _cuda_devicequery.stdout | regex_findall('Device (\\d+):') }}" |
| 40 | + |
| 41 | +- name: Run cuda bandwidth test |
| 42 | + command: |
| 43 | + cmd: "{{ cuda_samples_path }}/cuda-samples-{{ cuda_version_short }}/bin/x86_64/linux/release/bandwidthTest --device={{ item }}" |
| 44 | + register: _cuda_bandwidthtest |
| 45 | + loop: "{{ cuda_devices }}" |
| 46 | + loop_control: |
| 47 | + label: "Device {{ item }}" # e.g '0' |
| 48 | + |
| 49 | +- name: Summarise bandwidth test output |
| 50 | + debug: |
| 51 | + msg: | |
| 52 | + {{ _parts[1].splitlines()[0] | trim }} |
| 53 | + Bandwidths: (Gb/s) |
| 54 | + Host to Device: {{ _parts[2].split()[-1] }} |
| 55 | + Device to Host: {{ _parts[3].split()[-1] }} |
| 56 | + Device to Device: {{ _parts[4].split()[-1] }} |
| 57 | + {{ ': '.join(_parts[5].split('=') | map('trim')) }} |
| 58 | + {{ _parts[6] }} |
| 59 | + loop: "{{ _cuda_bandwidthtest.results }}" |
| 60 | + vars: |
| 61 | + _parts: "{{ item.stdout.split('\n\n') }}" |
| 62 | + loop_control: |
| 63 | + label: "Device {{ item.item }}" # e.g '0' |
0 commit comments