跳转到主要内容

NVIDIA GPU Cloud SDK

项目描述

NGC-SDK

NVIDIA NGC软件开发套件,用于交互和开发Python工具和应用程序,以便与NVIDIA GPU Cloud集成。

先决条件

Python version >= 3.9

从PyPI安装

通过运行以下命令从pypi.org安装该软件包

pip安装ngcsdk

此项目将下载并安装额外的第三方开源软件项目。在使用之前,请查阅这些开源项目的许可条款。

安装SDK后,第一步是创建和配置客户端。

创建和配置NGC SDK客户端

要设置配置,请运行以下函数。

提示

这需要一个API密钥。有关生成API密钥的信息,请参阅设置,https://ngc.nvidia.com/setup

from ngcsdk import Client

clt = Client()

clt.configure(api_key='****NkMQ', org_name='nvidia', team_name='no-team', ace_name='no-ace')
Validating configuration...
Successfully validated configuration.

clt.current_config()
[{'key': 'apikey', 'value': '****NkMQ', 'source': 'user settings'},
 {'key': 'format_type', 'value': 'ascii', 'source': 'user settings'},
 {'key': 'org', 'value': 'nvidia', 'source': 'user settings'},
 {'key': 'team', 'value': 'no-team', 'source': 'user settings'},
 {'key': 'ace', 'value': 'no-ace', 'source': 'user settings'}]

调试

使用Python的日志记录实用工具配置调试日志。

import logging

from ngcsdk import Client

logger = logging.getLogger()

logger.setLevel(logging.DEBUG)

clt = Client()

ace = clt.basecommand.aces.info("nv-us-west-2")
DEBUG:ngcbpc.api.connection:Requesting URL (GET): https://api.stg.ngc.nvidia.com/v2/org/nvidia/aces/ceph-sjc-4-dev
    payload: None
    params: None
DEBUG:ngcbpc.api.authentication:Retrieving API Key Token from cache....
DEBUG:ngcbpc.api.authentication:Token in use: ****hPWE
DEBUG:ngcbpc.api.authentication:Expiration time of token: '2024-03-07 16:36:03.849188'
DEBUG:ngcbpc.api.authentication:Fetched token from the cache. Expires 2024-03-07 16:36:03.849188
DEBUG:ngcbpc.api.utils:Headers:
DEBUG:ngcbpc.api.utils:{'Content-Type': 'application/json', ...}
DEBUG:ngcbpc.api.connection:Response status: 200 - Reason: OK
DEBUG:ngcbpc.api.connection:Time taken to process URL: https://api.stg.ngc.nvidia.com/v2/org/nvidia/aces/ceph-sjc-4-dev: 0.34587s
DEBUG:ngcbpc.api.connection:Response is: {"requestStatus":{"statusCode":"SUCCESS"}, ...}

有关如何配置日志记录的更多信息,请参阅Python官方日志记录教程。

输出

方法返回对象或JSON。对象可以检查并转换为Python字典或JSON格式。

from ngcsdk import Client

clt = Client()

ace = clt.basecommand.aces.info("nv-us-west-2")

help(ace)
Help on Ace in module ngccli.data.api.Ace object:

class Ace(builtins.object)
 |  Ace(propDict=None)
 |
 |  ACE is a collection of nodes that can run jobs
 |
 |  Methods defined here:
 |
 |  __init__(self, propDict=None)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  isValid(self)
 |
 |  toDict(self)
 |
 |  toJSON(self, pretty=False)

ace.toDict()
{'allowExposedPort': False, ...}

ace.toJSON()
'{"allowExposedPort": false, ...}

aces = clt.basecommand.aces.list()

help(aces)
Help on chain object:

class chain(builtins.object)
 |  chain(*iterables) --> chain object
 |
 |  Return a chain object whose .__next__() method returns elements from the
 |  first iterable until it is exhausted, then elements from the next
 |  iterable, until all of the iterables are exhausted.
 |
 |  Methods defined here:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __next__(self, /)
 |      Implement next(self).

[ace.name for ace in aces]
['ac-auth-debug-ace', ....]

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解安装软件包的更多信息。

源分布

本版本没有提供源代码分发文件。请参阅关于 生成分发归档 的教程。

构建的分发版

ngcsdk-3.51.0-py3-none-any.whl (1.6 MB 查看哈希值)

上传时间 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页