Skip to content

Commit

Permalink
Merge pull request #1 from felix-russell/intitalcommit
Browse files Browse the repository at this point in the history
Uploading the working version
  • Loading branch information
felix-russell authored Oct 30, 2017
2 parents 0b092ef + 6faf087 commit 807975d
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 674 deletions.
875 changes: 201 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
nvidia Salt formula
========

This formula is intended to download and install the nvidia drivers for your operating system for use with the CUDA libraries.

See the full Salt Formulas installation and usage instructions
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>

Authors
----
(c)2017 University of Washington, Institute for Health Metrics and Evaluation
- Andrew Ernst (ernstae@github.com)
- Felix Russell (felix-russell@github.com)


Available states
================

```
nvidia.install
```
This formula can be called as `salt-call state.sls nvidia` and relies on the presence of either a salt grain for gpus (see https://docs.saltstack.com/en/latest/ref/configuration/master.html for the `ENABLE_GPU_GRAINS` feature.)


Tested Operating Systems
----
* Ubuntu 14.04 16.04
* Centos 6.x 7.x
* RedHat 6.x 7.x
4 changes: 4 additions & 0 deletions nvidia/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
nvidia:
base_url: http://developer.download.nvidia.com/compute/cuda/repos
24 changes: 24 additions & 0 deletions nvidia/files/GPGKEY
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.9 (GNU/Linux)

mQGiBFFoeGMRBACjjvkdqqBafo0msmm9251rB7ocN4Es4cCq6O/8eOVoPx8fFrAK
LHExbZODXp7eKJMkKHIlGwmG9SZR02wJO2bvnqn3AdbRydRsNPGlb0+8Xl9uvRyc
2feeDLYQfbUW/8D2nKkAhbZ8EiUvezDZYG6hs24bMpPFmn+fTqdtmSfMHwCg7X+q
v1EJl25niTiQVb3F2qvj950D/ib0LQWMHDiPCc2NhCfXjaDJ9QrNaF+z083I4xMk
GS/7jLWuM07+8izyaThePJbFad2KyK6csN7AFH54VIqHerLsy9xCS4xd5aX0UXmp
uiae8XyWdj8kvJ9ujWxx5xgPABaDGIGxW6Bifiy75mI6okV4GwrAg5QW81/agm+k
NqZ+BACRNIw3w+wNLk5kLfbyK01fMr5UhgBWDKKIbyXxnmonSdpcvl1jF47/r59u
XMfRmyVnW5qepKN3sO2jQcySh713t+Oc23/vHeQNDoET8/FDpyqRq/zXIfS8KZg7
7mIrzdfohRyj8hjBGS3XBT4OaSk1Kp2ecK/oECsUleJXWGYgPLQgY3VkYXRvb2xz
IDxjdWRhdG9vbHNAbnZpZGlhLmNvbT6IYAQTEQIAIAUCUWh4YwIbAwYLCQgHAwIE
FQIIAwQWAgMBAh4BAheAAAoJENiMPThcN9O+M2EAoI/q1YTdia8WMdcoJxQKhuWl
0dxLAJ0YMMLZywIU8XJX3GkscXbn/LerOrkBDQRRaHhjEAQArb/oDncYCzLzHZEp
mXA9EKx/MLXfyammV4Yb9gFrpmVbcMGYqakSnSwimqp/Rc94pGNBekkddUw36eCo
Tww2mWKbHhXQ5fAMInrfbkbqqNl2rlf/fllej6vLI1yOFbAR4OIY8RMMVmTW38kk
RTQIHsiPDv4FRkjdT5jQgCfjtNsAAwYD/0yEUdGDLxCygyPQERsYZOxA4loN8Ts0
2zSkhaRW4oLPedMdwEqHLIU1xXypq41Oc/vwggQo2Nuf5l4iclZf9KGaMkTDqnOS
4PaLN+h3g76pqprdfbj8XwvUL1fp59m4E7zrPmFEC77mN5juL0G0Vd2hATc/tHtn
JE1twuU/z0M9iEkEGBECAAkFAlFoeGMCGwwACgkQ2Iw9OFw3075WiQCePaId+3oa
Gxt50E+HszCx9nLtSIUAoIeoy/nWEJqX/uYHglHBLe4qdfcH
=lRUP
-----END PGP PUBLIC KEY BLOCK-----
2 changes: 2 additions & 0 deletions nvidia/files/blacklist-nuveau.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
blacklist nouveau
options nouveau modeset=0
3 changes: 3 additions & 0 deletions nvidia/files/cuda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

export PATH=${PATH}:/usr/local/cuda/bin
4 changes: 4 additions & 0 deletions nvidia/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
include:
- .install
51 changes: 51 additions & 0 deletions nvidia/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{% from "nvidia/map.jinja" import nvidia with context %}
{## Configure package managers for repository information ##}
nvidia-repo:
pkgrepo.managed:
- humanname: cuda
- gpgcheck: 1
{% if salt['grains.get']('os_family', 'RedHat') == 'RedHat' %}
- gpgkey: {{ nvidia.base_url }}/GPGKEY
- baseurl: {{ nvidia.base_url }}/rhel$releasever/$basearch
{% elif salt['grains.get']('os_family') == 'Debian' or 'Ubuntu' %}
- file: /etc/apt/sources.list.d/nvidia.list
- key_url: {{ nvidia.base_url }}/GPGKEY
- name: deb {{ nvidia.base_url }}/ubuntu{{ salt['grains.get']('osrelease', '1404') | replace('.','') }}/{{ salt['grains.get']('osarch','x86_64') | replace('amd64','x86_64') }}
{% endif %}
{## Install cuda drivers ##}
install_cuda_package:
pkg.installed:
- name: cuda
{%- if nvidia.version is defined %}
- version: {{ nvidia.version }}
{% endif %}
{## Disable Nouveau ##}
/etc/modprobe.d/blacklist-nouveau.conf:
file.managed:
- source: salt://nvidia/files/blacklist-nuveau.conf
- user: root
- group: root
- mode: 644
{## Rebuild Initramfs ##}
{% if nvidia.rebuild_initrd_cmd is defined %}
nvidia_rebuild_inird_cmd:
cmd.run:
- name: {{ nvidia.rebuild_initrd_cmd }}
- creates:
- /lib/modules/{{ salt['grains.get']('kernelrelease', '') }}/extras/nvidia.ko
{% endif %}
# This is to set up the cuda path variable sourced by users.
/etc/profile.d/cuda.sh:
file.managed:
- mode: 755
- user: root
- group: root
- source: salt://nvidia/files/cuda.sh
26 changes: 26 additions & 0 deletions nvidia/map.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

{## Start with defaults from defaults.sls ##}
{% import_yaml 'nvidia/defaults.yaml' as default_settings %}

{## Setup variable using grains['os_family'] based logic, only add key:values here that differ from whats in defaults.yaml ##}
{% set os_family_map = salt['grains.filter_by']({
'Debian': {
"rebuild_initrd_cmd": 'update-initramfs -u'
},
'RedHat': {
"rebuild_initrd_cmd" : 'dracut --force'
},
}, grain="os_family", merge=salt['pillar.get']('nvidia', [])) %}

{## Merge the default settings with the OS-specific changes that were merged with pillar ##}
{% do default_settings.nvidia.update(os_family_map) %}

{## Merge in nvidia:lookup pillar ##}
{% set nvidia = salt['pillar.get'](
'nvidia',
default=default_settings.nvidia,
merge=True
)
%}
4 changes: 4 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nvidia:
force_install: False # installs cuda driver even if no grains detect it.
base_url: https://your-own-mirror.local/cuda
version: '8.*'

0 comments on commit 807975d

Please sign in to comment.