Skip to content

Commit

Permalink
Simplify install
Browse files Browse the repository at this point in the history
  • Loading branch information
damonmaria committed Apr 2, 2019
1 parent ec18933 commit 6e21f44
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 130 deletions.
45 changes: 1 addition & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

# nvidia_docker_runtime

Welcome to your new module. A short overview of the generated parts can be found in the PDK documentation at https://puppet.com/pdk/latest/pdk_generating_modules.html .

The README template below provides a starting point with details about what information to include in your README.
This is a PDK based module https://puppet.com/pdk/latest/pdk_generating_modules.html .

#### Table of Contents

Expand All @@ -13,8 +11,6 @@ The README template below provides a starting point with details about what info
* [Setup requirements](#setup-requirements)
* [Beginning with nvidia_docker_runtime](#beginning-with-nvidia_docker_runtime)
3. [Usage - Configuration options and additional functionality](#usage)
4. [Limitations - OS compatibility, etc.](#limitations)
5. [Development - Guide for contributing to the module](#development)

## Description

Expand Down Expand Up @@ -47,42 +43,3 @@ The very basic steps needed for a user to get the module up and running. This ca
## Usage

Include usage examples for common use cases in the **Usage** section. Show your users how to use your module to solve problems, and be sure to include code examples. Include three to five examples of the most important or common tasks a user can accomplish with your module. Show users how to accomplish more complex tasks that involve different types, classes, and functions working in tandem.

## Reference

This section is deprecated. Instead, add reference information to your code as Puppet Strings comments, and then use Strings to generate a REFERENCE.md in your module. For details on how to add code comments and generate documentation with Strings, see the Puppet Strings [documentation](https://puppet.com/docs/puppet/latest/puppet_strings.html) and [style guide](https://puppet.com/docs/puppet/latest/puppet_strings_style.html)

If you aren't ready to use Strings yet, manually create a REFERENCE.md in the root of your module directory and list out each of your module's classes, defined types, facts, functions, Puppet tasks, task plans, and resource types and providers, along with the parameters for each.

For each element (class, defined type, function, and so on), list:

* The data type, if applicable.
* A description of what the element does.
* Valid values, if the data type doesn't make it obvious.
* Default value, if any.

For example:

```
### `pet::cat`
#### Parameters
##### `meow`
Enables vocalization in your cat. Valid options: 'string'.
Default: 'medium-loud'.
```

## Limitations

In the Limitations section, list any incompatibilities, known issues, or other warnings.

## Development

In the Development section, tell other users the ground rules for contributing to your project and how they should submit their work.

## Release Notes/Contributors/Etc. **Optional**

If you aren't using changelog, put your release notes here (though you should consider using changelog). You can also add any additional sections you feel are necessary or important to include here. Please use the `## ` header.
109 changes: 24 additions & 85 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,48 @@
# @example
# include nvidia_docker_runtime

# TODO: facts:
# $ docker inspect -f '{{index .Config.Labels "com.nvidia.volumes.needed"}}' nvidia/cuda
# nvidia_driver
# $ docker inspect -f '{{index .Config.Labels "com.nvidia.cuda.version"}}' nvidia/cuda
# 7.5

# TODO: facts of installed versions of meta packages

# TODO: set default runtime?
# /etc/docker/daemon.json:
# "default-runtime": "nvidia",

# TODO: specify package versions using ensure

class nvidia_docker_runtime (
String $nvidia_driver_version = '418', # Driver versions: https://www.nvidia.com/object/unix.html
String $cuda_version = '10.1',
# Driver versions for CUDA versions: https://docs.nvidia.com/deploy/cuda-compatibility/index.html
String $driver_version = latest,
String $nvidia_docker2_version = latest,
# Boolean $nvidia_utils = false,
) {

# TODO: Want to require docker but causes circular dependencies
# REVISIT: Want to require docker but causes circular dependencies
include apt

$distribution = "${$facts['operatingsystem'].downcase}${$facts['operatingsystemmajrelease']}"
$repo_url_prefix = "https://developer.download.nvidia.com/compute/cuda/repos/${regsubst($distribution, '\.', '', 'G')}/x86_64/"

# Fill this in from this page (or it's siblings): https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=debnetwork
# Links to the checksums can be found there too
# Driver / CUDA version compatibility: https://docs.nvidia.com/deploy/cuda-compatibility/index.html#binary-compatibility__table-toolkit-driver
$cuda_deb = {
'10.0' => {
url => "${repo_url_prefix}cuda-repo-ubuntu1804_10.0.130-1_amd64.deb",
checksum => '306fbaad179372f5f200c8d2c2c9b8bb',
},
'10.1' => {
url => "${repo_url_prefix}cuda-repo-ubuntu1804_10.1.105-1_amd64.deb",
checksum => '68e4203b3a99a292109758d481f6d331',
},
}[$cuda_version]
$cuda_repo = "https://developer.download.nvidia.com/compute/cuda/repos/${regsubst($distribution, '\.', '', 'G')}
/x86_64"

$linux_headers_package = "linux-headers-${$facts['kernelrelease']}"
$nvidia_driver_pkg = "nvidia-headless-${$nvidia_driver_version}"
$nvidia_key_id = 'C95B321B61E88C1809C4F759DDCAE044F796ECB0'

$cache_dir = '/var/cache/nvidia_docker_runtime'
$cuda_deb_path = "${$cache_dir}/cuda-${cuda_version}-network.deb"
$cuda_drivers_pkg = "cuda-runtime-${regsubst($cuda_version, '\.', '-', 'G')}"
$cuda_key_id = 'AE09FE4BBD223A84B2CCFCE3F60F4B3D7FA2AF80'

package { ['software-properties-common', 'build-essential', $linux_headers_package]:
package { ['build-essential', $linux_headers_package]:
ensure => latest
}

apt::ppa { 'ppa:graphics-drivers/ppa':
require => Package['software-properties-common'],
}

package { $nvidia_driver_pkg:
ensure => latest,
require => Apt::Ppa['ppa:graphics-drivers/ppa'],
}

# package { "nvidia-utils-${$nvidia_driver_version}":
# ensure => ($nvidia_utils ? latest: absent),
# require => Apt::Ppa['ppa:graphics-drivers/ppa'],
# }

file { $cache_dir:
ensure => directory,
}

# TODO: Throw error if CUDA version map lookup finds nothing

file { $cuda_deb_path:
ensure => present,
source => $cuda_deb['url'],
checksum_value => $cuda_deb['checksum'],
checksum => 'md5',
require => File[$cache_dir],
}

package { 'cuda-deb-install':
source => $cuda_deb_path,
provider => dpkg,
require => File[$cuda_deb_path],
$cuda_key_id = 'AE09FE4BBD223A84B2CCFCE3F60F4B3D7FA2AF80'
apt::key { $cuda_key_id:
source => "${cuda_repo}/7fa2af80.pub",
}

apt::key { $cuda_key_id:
source => "${repo_url_prefix}${$cuda_key_id[-8,8].downcase}.pub",
apt::source { 'cuda':
comment => 'Normally installed by the CUDA network deb installer',
location => $cuda_repo,
release => '/',
repos => '',
require => Apt::Key[$cuda_key_id],
}

package { $cuda_drivers_pkg:
package { 'cuda-drivers':
ensure => $driver_version,
require => [
Package['build-essential'],
Package[$linux_headers_package],
Package['cuda-deb-install'],
Apt::Key[$cuda_key_id],
Apt::Source['cuda'],
],
}

apt::key { $nvidia_key_id:
$nvidia_docker_key_id = 'C95B321B61E88C1809C4F759DDCAE044F796ECB0'
apt::key { $nvidia_docker_key_id:
source => 'https://nvidia.github.io/nvidia-docker/gpgkey',
}

Expand All @@ -117,23 +57,23 @@
location => "https://nvidia.github.io/libnvidia-container/${$distribution}/$(ARCH)",
release => '/',
repos => '',
require => Apt::Key[$nvidia_key_id],
require => Apt::Key[$nvidia_docker_key_id],
}
apt::source { 'nvidia-container-runtime':
comment => $nvidia_docker_sources_comment,
location => "https://nvidia.github.io/nvidia-container-runtime/${$distribution}/$(ARCH)",
release => '/',
repos => '',
require => Apt::Key[$nvidia_key_id],
require => Apt::Key[$nvidia_docker_key_id],
}
apt::source { 'nvidia-docker':
comment => $nvidia_docker_sources_comment,
location => "https://nvidia.github.io/nvidia-docker/${$distribution}/$(ARCH)",
release => '/',
repos => '',
require => Apt::Key[$nvidia_key_id],
require => Apt::Key[$nvidia_docker_key_id],
}
package { 'nvidia-docker2':
Expand All @@ -142,8 +82,7 @@
Apt::Source['libnvidia-container'],
Apt::Source['nvidia-container-runtime'],
Apt::Source['nvidia-docker'],
Package[$nvidia_driver_pkg],
Package[$cuda_drivers_pkg],
Package['cuda-drivers'],
],
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mindhive-nvidia_docker_runtime",
"version": "0.1.3",
"version": "0.2.0",
"author": "[email protected]",
"summary": "Manage NVIDIA Docker runtime",
"license": "MIT",
Expand Down

0 comments on commit 6e21f44

Please sign in to comment.