Skip to main content

cann-cann

一行代码快速检查环境上的 NPU 与 CANN 参数

看看你的 UB 有多大😎

安装

pip install cann-cann

支持 Python >= 3.10;需要安装 CANN 并加载环境变量

Python 接口

import cann_cann

cann_cann.ub_size()  # 253952
cann_cann.ub_size(unit="kb")  # 248
cann_cann.memory_size(unit="gb")  # 128

cann_cann.npu_name()  # "Ascend950PR_XXXX"
cann_cann.all_npu_names()  # ["Ascend910A",...]

cann_cann.memory_size(npu_name="Ascend910_9392", unit="gb")  # 64

也可先获取单独的配置对象,方便连续读取同一份配置中的多个参数:

config = cann_cann.platform_config(npu_name="Ascend910B2")

config.ub_size(unit="kb")  # 192
config.l1_size(unit="kb")  # 512
config.memory_size(unit="gb")  # 64

# 读取配置文件中的原始值
config.ai_core_spec.ub_size  # 196608
config.soc_info.ai_core_count  # 24
config.soc_info.memory_size  # 68719476736

命令行

提供 cann-cann 与作为简称的 ccann 命令,使用任一命令均可

cann-cann UB  # 253952
cann-cann UB --kb  # 248
ccann L0A --unit kb  # 64
ccann L1 --kb --npu-name Ascend910_9392  # 512
ccann ai-cores  # 24
ccann memory --gb  # 128

cann-cann npu-name  # Ascend950PR_XXXX
ccann all-npu-names  # Ascend910A...

查询名称不区分大小写

当前支持 UBL0AL0BL0CL1L2memoryai-cores

参与开发

参与开发时,先安装开发依赖并启用提交前检查:

uv sync --dev
uv run pre-commit install

启用后,每次提交前都会使用 Ruff 自动检查并格式化 Python 代码。也可手动检查所有文件:

uv run pre-commit run --all-files

完整检查、测试与构建:

uv run ruff format --check .
uv run ruff check .
uv run pytest
uv build

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cann_cann-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cann_cann-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file cann_cann-0.1.0.tar.gz.

File metadata

  • Download URL: cann_cann-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cann_cann-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b27be7eec13eee8d8045943df0676fb574aa8e21e51492096ffd7ff0131636b
MD5 ad0f9a79699bbf7a66d7d4149853f42d
BLAKE2b-256 2034961b9403dbecc9c78c7c4ccb8de5a6c2e9d54fa3d64ea2bfaf51b96191fd

See more details on using hashes here.

File details

Details for the file cann_cann-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cann_cann-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cann_cann-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1414ed6d8dfc9ff5faff8f03288a3f07e10cc732d7971dd238051b84e622835
MD5 106eccead2bef44900647134a1b7c827
BLAKE2b-256 1020bae9ef1b5df5d50957e5a52a5b14a20f619269ce2cc47430ffae9e45c640

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page