diff --git a/features/src/nvidia-cuda/README.md b/features/src/nvidia-cuda/README.md index 2a915a4..7666108 100755 --- a/features/src/nvidia-cuda/README.md +++ b/features/src/nvidia-cuda/README.md @@ -6,8 +6,9 @@ A package which installs NVIDIA CUDA. ```json "features": { - "ghcr.io/postfinance/devcontainer-features/nvidia-cuda:0.1.0": { + "ghcr.io/postfinance/devcontainer-features/nvidia-cuda:0.1.1": { "version": "latest", + "keyringVersion": "1.1-1", "installLibraries": true, "installDevLibraries": true, "installCompiler": true, @@ -23,6 +24,7 @@ A package which installs NVIDIA CUDA. | Option | Description | Type | Default Value | Proposals | |-----|-----|-----|-----|-----| | version | The version of NVIDIA CUDA to install. | string | latest | latest, 12.9, 13.1 | +| keyringVersion | The version of the NVIDIA CUDA keyring to install. | string | 1.1-1 | latest, 1.1-1 | | installLibraries | Installs all runtime CUDA Library packages. | boolean | true | true, false | | installDevLibraries | Installs all development CUDA Library packages. | boolean | true | true, false | | installCompiler | Installs all CUDA compiler packages. | boolean | true | true, false | diff --git a/features/src/nvidia-cuda/devcontainer-feature.json b/features/src/nvidia-cuda/devcontainer-feature.json index 1789750..18bca85 100644 --- a/features/src/nvidia-cuda/devcontainer-feature.json +++ b/features/src/nvidia-cuda/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "nvidia-cuda", - "version": "0.1.0", + "version": "0.1.1", "name": "NVIDIA CUDA", "description": "A package which installs NVIDIA CUDA.", "options": { @@ -14,6 +14,15 @@ "default": "latest", "description": "The version of NVIDIA CUDA to install." }, + "keyringVersion": { + "type": "string", + "proposals": [ + "latest", + "1.1-1" + ], + "default": "1.1-1", + "description": "The version of the NVIDIA CUDA keyring to install." + }, "installLibraries": { "type": "boolean", "default": true, diff --git a/features/src/nvidia-cuda/install.sh b/features/src/nvidia-cuda/install.sh index 3908771..2625523 100755 --- a/features/src/nvidia-cuda/install.sh +++ b/features/src/nvidia-cuda/install.sh @@ -2,6 +2,7 @@ "./installer_$(detect_arch)" \ -version="${VERSION:-"latest"}" \ + -keyringVersion="${KEYRINGVERSION:-""}" \ -installLibraries="${INSTALLLIBRARIES:-"true"}" \ -installDevLibraries="${INSTALLDEVLIBRARIES:-"true"}" \ -installCompiler="${INSTALLCOMPILER:-"true"}" \ diff --git a/features/src/nvidia-cuda/installer.go b/features/src/nvidia-cuda/installer.go index 620329c..cd086e5 100644 --- a/features/src/nvidia-cuda/installer.go +++ b/features/src/nvidia-cuda/installer.go @@ -15,6 +15,12 @@ import ( "github.com/roemer/gover" ) +////////// +// Configuration +////////// + +const nvidiaDownloadBaseURL = "https://developer.download.nvidia.com" + ////////// // Main ////////// @@ -29,6 +35,7 @@ func main() { func runMain() error { // Handle the flags version := flag.String("version", "latest", "") + keyringVersion := flag.String("keyringVersion", "", "") installLibraries := flag.Bool("installLibraries", true, "") installDevLibraries := flag.Bool("installDevLibraries", true, "") installCompiler := flag.Bool("installCompiler", true, "") @@ -42,12 +49,12 @@ func runMain() error { return err } - installer.HandleOverride(downloadUrl, "https://developer.download.nvidia.com", "nvidia-cuda-download-url") + installer.HandleOverride(downloadUrl, nvidiaDownloadBaseURL, "nvidia-cuda-download-url") // Create and process the feature feature := installer.NewFeature("NVIDIA CUDA", false, &cudaKeyringComponent{ - ComponentBase: installer.NewComponentBase("Keyring", installer.VERSION_LATEST), + ComponentBase: installer.NewComponentBase("Keyring", *keyringVersion), DownloadUrl: *downloadUrl, }, ) @@ -96,7 +103,7 @@ type cudaKeyringComponent struct { DownloadUrl string } -func (c *cudaKeyringComponent) getCudaRepo() (string, error) { +func (c *cudaKeyringComponent) getCudaRepo(baseUrl string) (string, error) { osInfo, err := installer.Tools.System.GetOsInfo() if err != nil { return "", err @@ -114,19 +121,20 @@ func (c *cudaKeyringComponent) getCudaRepo() (string, error) { if archPart == "arm64" { return "", fmt.Errorf("No CUDA binaries are available for ARM64") } - return fmt.Sprintf("%s/compute/cuda/repos/%s%d/%s/", c.DownloadUrl, osInfo.Vendor, osInfo.MajorVersion(), archPart), nil + return fmt.Sprintf("%s/compute/cuda/repos/%s%d/%s/", baseUrl, osInfo.Vendor, osInfo.MajorVersion(), archPart), nil } if osInfo.IsUbuntu() { - return fmt.Sprintf("%s/compute/cuda/repos/%s%s/%s/", c.DownloadUrl, osInfo.Vendor, strings.ReplaceAll(osInfo.VersionId, ".", ""), archPart), nil + return fmt.Sprintf("%s/compute/cuda/repos/%s%s/%s/", baseUrl, osInfo.Vendor, strings.ReplaceAll(osInfo.VersionId, ".", ""), archPart), nil } return "", fmt.Errorf("unsupported OS: %s", osInfo.Vendor) } func (c *cudaKeyringComponent) GetAllVersions() ([]*gover.Version, error) { - indexUrl, err := c.getCudaRepo() + cudaRepo, err := c.getCudaRepo(nvidiaDownloadBaseURL) if err != nil { return nil, err } + indexUrl := fmt.Sprintf("%s%s", cudaRepo, "index.html") allVersions, err := installer.Tools.Http.GetVersionsFromHtmlIndex( indexUrl, @@ -140,7 +148,7 @@ func (c *cudaKeyringComponent) GetAllVersions() ([]*gover.Version, error) { func (c *cudaKeyringComponent) InstallVersion(version *gover.Version) error { // Download the file - cudaRepo, err := c.getCudaRepo() + cudaRepo, err := c.getCudaRepo(c.DownloadUrl) if err != nil { return err }