Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion features/src/nvidia-cuda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 |
Expand Down
11 changes: 10 additions & 1 deletion features/src/nvidia-cuda/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions features/src/nvidia-cuda/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"./installer_$(detect_arch)" \
-version="${VERSION:-"latest"}" \
-keyringVersion="${KEYRINGVERSION:-""}" \
-installLibraries="${INSTALLLIBRARIES:-"true"}" \
-installDevLibraries="${INSTALLDEVLIBRARIES:-"true"}" \
-installCompiler="${INSTALLCOMPILER:-"true"}" \
Expand Down
22 changes: 15 additions & 7 deletions features/src/nvidia-cuda/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
"github.com/roemer/gover"
)

//////////
// Configuration
//////////

const nvidiaDownloadBaseURL = "https://developer.download.nvidia.com"

//////////
// Main
//////////
Expand All @@ -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, "")
Expand All @@ -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,
},
)
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
}
Expand Down
Loading