安装
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...
查询名称不区分大小写
当前支持
UB、L0A、L0B、L0C、L1、L2、memory和ai-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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
cann_cann-0.1.0-py3-none-any.whl
(13.1 kB
view details)
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b27be7eec13eee8d8045943df0676fb574aa8e21e51492096ffd7ff0131636b
|
|
| MD5 |
ad0f9a79699bbf7a66d7d4149853f42d
|
|
| BLAKE2b-256 |
2034961b9403dbecc9c78c7c4ccb8de5a6c2e9d54fa3d64ea2bfaf51b96191fd
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1414ed6d8dfc9ff5faff8f03288a3f07e10cc732d7971dd238051b84e622835
|
|
| MD5 |
106eccead2bef44900647134a1b7c827
|
|
| BLAKE2b-256 |
1020bae9ef1b5df5d50957e5a52a5b14a20f619269ce2cc47430ffae9e45c640
|