Skip to content

Commit

Permalink
Add nvidia-container-toolkit
Browse files Browse the repository at this point in the history
Signed-off-by: Furkan Türkal <[email protected]>
Co-authored-by: Batuhan <[email protected]>
  • Loading branch information
Dentrax and developer-guy committed May 2, 2024
1 parent 1475185 commit d148625
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 0 deletions.
9 changes: 9 additions & 0 deletions generated.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions images/nvidia-container-toolkit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--monopod:start-->
# nvidia-container-toolkit
| | |
| - | - |
| **OCI Reference** | `cgr.dev/chainguard/nvidia-container-toolkit` |


* [View Image in Chainguard Academy](https://edu.chainguard.dev/chainguard/chainguard-images/reference/nvidia-container-toolkit/overview/)
* [View Image Catalog](https://console.enforce.dev/images/catalog) for a full list of available tags.
* [Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*

---
<!--monopod:end-->

<!--overview:start-->
The NVIDIA Container Toolkit allows users to build and run GPU accelerated containers.
<!--overview:end-->

<!--getting:start-->
## Download this Image
The image is available on `cgr.dev`:

```
docker pull cgr.dev/chainguard/nvidia-container-toolkit:latest
```
<!--getting:end-->

<!--body:start--><!--body:end-->
59 changes: 59 additions & 0 deletions images/nvidia-container-toolkit/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
terraform {
required_providers {
apko = { source = "chainguard-dev/apko" }
}
}

module "accts" {
source = "../../../tflib/accts"
run-as = 0 # This image needs to run as root
}

variable "extra_repositories" {
description = "The additional repositores to install from (e.g. extras)."
default = ["https://packages.cgr.dev/extras"]
}

variable "extra_keyring" {
description = "The additional keys to use (e.g. extras)."
default = ["https://packages.cgr.dev/extras/chainguard-extras.rsa.pub"]
}

variable "extra_packages" {
description = "Additional packages to install."
type = list(string)
default = [
"nvidia-container-toolkit",
"nvidia-container-toolkit-nvidia-container-runtime",
"nvidia-container-toolkit-nvidia-container-runtime-cdi",
"nvidia-container-toolkit-nvidia-container-runtime-hook",
"nvidia-container-toolkit-nvidia-container-runtime-legacy",
"nvidia-container-toolkit-nvidia-ctk",
"libnvidia-container",
"nvidia-cuda-cudart-12",
"nvidia-cuda-nvml-dev-12",
]
}

output "config" {
value = jsonencode({
contents = {
packages = concat(var.extra_packages)
repositories = concat(var.extra_repositories)
keyring = concat(var.extra_keyring)
}
accounts = module.accts.block
environment = {
PATH = "/work:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/cuda-12.3/",
CUDA_VERSION = "12.3",
LD_LIBRARY_PATH = "/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/lib/:/usr/lib64:/usr/local/cuda-12.3/include:/usr/local/cuda-12.3/lib:/usr/local/cuda-12.3/lib64:/usr/local/cuda-12.3/lib64/stubs"
NVIDIA_VISIBLE_DEVICES = "all"
NVIDIA_DRIVER_CAPABILITIES = "utility"
NVIDIA_REQUIRE_CUDA = "cuda>=11.2 brand=tesla,driver>=418,driver<419 brand=tesla,driver>=440,driver<441 driver>=450"
NVIDIA_DISABLE_REQUIRE = "true"
},
entrypoint = {
command = "nvidia-toolkit"
}
})
}
13 changes: 13 additions & 0 deletions images/nvidia-container-toolkit/generated.tf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions images/nvidia-container-toolkit/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
}
}

variable "target_repository" {
description = "The docker repo into which the image and attestations should be published."
}

module "config" { source = "./config" }

module "nvidia-container-toolkit" {
source = "../../tflib/publisher"
name = basename(path.module)
target_repository = var.target_repository
config = module.config.config

# build-dev = true

}

# module "test" {
# source = "./tests"
# digest = module.nvidia-container-toolkit.image_ref
# }

resource "oci_tag" "latest" {
# depends_on = [module.test]
digest_ref = module.nvidia-container-toolkit.image_ref
tag = "latest"
}

# resource "oci_tag" "latest-dev" {
# depends_on = [module.test]
# digest_ref = module.nvidia-container-toolkit.dev_ref
# tag = "latest-dev"
# }

12 changes: 12 additions & 0 deletions images/nvidia-container-toolkit/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: nvidia-container-toolkit
image: cgr.dev/chainguard/nvidia-container-toolkit
logo: https://storage.googleapis.com/chainguard-academy/logos/nvidia-container-toolkit.svg
endoflife: ""
console_summary: "Build and run containers leveraging NVIDIA GPUs"
short_description: The NVIDIA Container Toolkit allows users to build and run GPU accelerated containers.
compatibility_notes: ""
readme_file: README.md
upstream_url: https://github.com/NVIDIA/nvidia-container-toolkit
keywords:
- nvidia
- gpu
5 changes: 5 additions & 0 deletions images/nvidia-container-toolkit/tests/EXAMPLE_TEST.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o errtrace -o pipefail -x

# TODO: Implement this test.
18 changes: 18 additions & 0 deletions images/nvidia-container-toolkit/tests/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}

// Invoke a script with the test.
// $IMAGE_NAME is populated with the image name by digest.
// TODO: Update or remove this test as appropriate.
data "oci_exec_test" "manifest" {
digest = var.digest
script = "./EXAMPLE_TEST.sh"
working_dir = path.module
}
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ module "maven" {
target_repository = "${var.target_repository}/maven"
}

module "nvidia-container-toolkit" {
source = "./images/nvidia-container-toolkit"
target_repository = "${var.target_repository}/nvidia-container-toolkit"
}

module "powershell" {
source = "./images/powershell"
target_repository = "${var.target_repository}/powershell"
Expand Down

0 comments on commit d148625

Please sign in to comment.