NVIDIA GPU Cloud SDK

4.17.0 · active · verified Thu Apr 16

The NVIDIA GPU Cloud (NGC) SDK is a Python library that enables developers to integrate their applications and utilities with NVIDIA GPU Cloud. It provides programmatic access to NGC services, allowing users to manage resources, run jobs, and interact with the NGC catalog. The library is currently at version 4.17.0 and sees active development with frequent releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize and configure the `ngcsdk` client using an API key. It's crucial to obtain an API key from the NVIDIA NGC website (ngc.nvidia.com/setup) and ideally store it as an environment variable (`NGC_API_KEY`) for secure access. The `configure` method persists these settings for subsequent SDK operations.

import os
from ngcsdk import Client

# Retrieve API key from environment variable for security and flexibility
NGC_API_KEY = os.environ.get('NGC_API_KEY', 'YOUR_NGC_API_KEY_HERE') # Replace with your actual key or set env var

if not NGC_API_KEY or NGC_API_KEY == 'YOUR_NGC_API_KEY_HERE':
    print("Warning: NGC_API_KEY environment variable not set or placeholder used. Please provide a valid API key from ngc.nvidia.com/setup.")
    exit(1)

try:
    # Initialize the NGC SDK client
    clt = Client()

    # Configure the client. This will set user settings for future operations.
    # Replace 'my_org' and 'my_team' with your actual NGC organization and team names.
    # 'ace_name' can often be 'no-ace' or a specific ACE if your organization uses one.
    clt.configure(api_key=NGC_API_KEY, org_name='nvidia', team_name='no-team', ace_name='no-ace')
    print("Successfully configured NGC SDK client.")

    # Verify current configuration
    current_config = clt.current_config()
    print("Current NGC configuration:")
    for item in current_config:
        print(f"  {item['key']}: {item['value']} (Source: {item['source']})")

    # Example: List available ACEs (Accelerated Compute Environments)
    # This assumes 'basecommand' is available and configured.
    # Note: Access to specific commands like 'aces' depends on your NGC permissions and setup.
    # try:
    #     aces_info = clt.basecommand.aces.list()
    #     print("\nAvailable ACEs:")
    #     for ace in aces_info.values():
    #         print(f"  - {ace['name']}")
    # except AttributeError:
    #     print("\nCould not access 'aces' command. Check permissions or client setup.")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →