Juju layer to install CUDA on a fresh Ubuntu image with at least a GPU
Clone or download
Pull request Compare This branch is 23 commits ahead of SaMnCo:master.
kwmonroe update to cuda 9.x (#17) (#18)
* update to cuda 9.x (#17)

- change default version to latest cuda-repo pkg from nvidia (9.1.85-1)
- refactor the install_nvidia_driver as purge_nvidia_driver
  - we do not need to install the nvidia driver anymore since the cuda
    meta package will pull in cuda-drivers, which does the right thing.
  - instead, purge any existing nvidia pkgs that are not held so the
    subsequent meta package installation puts all the right bits down.
- add the apt key in case it doesnt exist already
  - cuda 8.x does this automatically in the cuda-repo postinst
  - cuda 9.x does not
  - it does not hurt to run apt-key adv even if the key already exists
- install 'cuda-$VER' instead of 'cuda'
  - with the latter, we would always get the very latest cuda packages
  - using the specific cuda-$VER metapackage lets the user track the
    major-minor version they want.

* always purge nvidia pkgs (lxc status doesnt matter); update readme with new default version
Latest commit e11e2ed Apr 30, 2018


Nvidia CUDA Layer

Installs the configured CUDA version with Nvidia drivers when supported GPU hardware is detected.


The following states are set by this layer:

  • cuda.supported

    This state is set when supported GPU hardware is detected.

  • cuda.installed

    This state is set once CUDA-related packages are installed and configured.


To use this layer, include it in the layer.yaml of a charm:

  - 'layer:nvidia-cuda'

Build and deploy the charm to a machine with Nvidia GPUs, e.g. instance-type=p2.xlarge on AWS or instance-type=Standard_NC6 on Azure.


The following runtime configuration options are available in this layer:

  • cuda-version

    The cuda-repo package version to install. Defaults to 9.1.85-1.

    juju config <charm> cuda-version=9.1.85-1

    Note: This layer constructs a major-minor string from this value and installs the corresponding cuda-x-y meta package (cuda-9-1 by default). This package will install the latest available dependencies in this series.

  • install-cuda

    When True (the default), install and configure CUDA if capable hardware is present. Set this to False to prevent installation regardless of hardware support.

    juju config <charm> install-cuda=True


Disk Space

The packages installed by this layer require approximately 4GB of disk space. Specify a root-disk constraint if needed to ensure the machine has adequate disk space for installation. For example:

juju deploy <charm> --constraints "instance-type=p2.xlarge root-disk=16G"

Removing CUDA

When the install-cuda configuration option is set to True, required packages will be installed and the system will be configured to include CUDA paths. If install-cuda is subsequently set to False, the system configuration files created by this layer will be removed; however, the packages installed by this layer will remain on the system.

Restricted Networks

This layer installs packages from http://developer.download.nvidia.com/. Configure proxies for Juju models in restricted network environments as needed. See Configuring Models for information about available proxy options.