Installation【免费下载链接】asnumpy-docs项目地址: https://gitcode.com/cann/asnumpy-docsThis guide covers how to install AsNumpy on your system.RequirementsHardware RequirementsRequirementSpecificationCPUAArch64 or X86_64NPUAscend 910BOSLinux (Ubuntu 20.04 recommended)Software RequirementsRequirementVersionGCC 11.2CMake 3.26ninja-build 1.12 (recommended)Python 3.9CANN 8.2.RC1.alpha003Prerequisites1. Install CANNEnsure CANN is installed on your system. You can verify the installation:cat /usr/local/Ascend/ascend-toolkit/latest/version.cfg2. Set Environment VariablesSet the CANN environment variable before building:export ASCEND_TOOLKIT_HOME/usr/local/Ascend/ascend-toolkit/latestFor convenience, add this to your~/.bashrc:echo export ASCEND_TOOLKIT_HOME/usr/local/Ascend/ascend-toolkit/latest ~/.bashrc source ~/.bashrc3. Verify Build Tools# Check GCC version gcc --version # Should be 11.2 # Check CMake version cmake --version # Should be 3.26 # Check Python version python --version # Should be 3.9Installation MethodsOption 1: Using uv (Recommended)uv is a fast Python package manager:# Clone the repository git clone --recursive https://gitcode.com/cann/asnumpy.git cd asnumpy # Install with uv uv syncOption 2: Using pip# Clone the repository git clone --recursive https://gitcode.com/cann/asnumpy.git cd asnumpy # Upgrade pip, setuptools, and wheel to their latest versions pip install --upgrade pip setuptools wheel # Install the build package, which provides a simple build front-end for Python packages pip install build # Build the current Python project (create source distribution and wheel) python -m build # Install all generated wheel (.whl) files from the dist/ directory pip install dist/*.whlOption 3: Development ModeFor development, install in editable mode:# Clone the repository git clone --recursive https://gitcode.com/cann/asnumpy.git cd asnumpy # Install in development mode pip install -e .This allows code changes to take effect immediately without reinstallation.Verify InstallationBasic Verificationimport asnumpy as ap # Create an array on NPU arr ap.ones((1000, 1000), dtypeap.float32) print(fShape: {arr.shape}) # Shape: (1000, 1000) print(✓ AsNumpy installed successfully!)Complete Verificationimport asnumpy as ap import numpy as np # Create a numpy array np_array np.array([1, 2, 3, 4, 5], dtypenp.float32) # Convert to AsNumpy array (transfer to NPU) npu_array ap.ndarray.from_numpy(np_array) # Perform operations on NPU result ap.sum(npu_array) print(fSum of array: {result.to_numpy()}) # Verify result assert result.to_numpy() 15.0 print(✓ Installation verified successfully!)TroubleshootingCommon IssuesImport ErrorSymptom:ModuleNotFoundError: No module named asnumpySolution:Ensure AsNumpy is installed:pip list | grep asnumpyCheck youre using the correct Python environmentTry reinstalling:pip install -e . --no-build-isolationCompilation ErrorSymptom:Build fails with CMake or GCC errorsSolution:Check CMake version:cmake --version(need 3.26)Check GCC version:gcc --version(need 11.2)Verify environment variable:echo $ASCEND_TOOLKIT_HOMEClean rebuild:pip install -e . --no-build-isolationRuntime ErrorSymptom:RuntimeError: ACL error ...Solution:Verify NPU is available:npu-smi infoCheck CANN installationEnsure youre running on a machine with Ascend 910B NPUPerformance IssuesSymptom:AsNumpy is slower than NumPySolution:For small arrays ( 1000×1000), CPU may be faster due to NPU launch overheadTry larger arrays to see NPU acceleration benefitsSee Benchmarks for expected performanceGetting HelpIf you encounter issues not covered here:Check the FAQSearch existing issuesOpen a new issue with:Your system information (OS, Python version, CANN version)Complete error messageSteps to reproduce【免费下载链接】asnumpy-docs项目地址: https://gitcode.com/cann/asnumpy-docs创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
CANN AsNumpy安装指南
Installation【免费下载链接】asnumpy-docs项目地址: https://gitcode.com/cann/asnumpy-docsThis guide covers how to install AsNumpy on your system.RequirementsHardware RequirementsRequirementSpecificationCPUAArch64 or X86_64NPUAscend 910BOSLinux (Ubuntu 20.04 recommended)Software RequirementsRequirementVersionGCC 11.2CMake 3.26ninja-build 1.12 (recommended)Python 3.9CANN 8.2.RC1.alpha003Prerequisites1. Install CANNEnsure CANN is installed on your system. You can verify the installation:cat /usr/local/Ascend/ascend-toolkit/latest/version.cfg2. Set Environment VariablesSet the CANN environment variable before building:export ASCEND_TOOLKIT_HOME/usr/local/Ascend/ascend-toolkit/latestFor convenience, add this to your~/.bashrc:echo export ASCEND_TOOLKIT_HOME/usr/local/Ascend/ascend-toolkit/latest ~/.bashrc source ~/.bashrc3. Verify Build Tools# Check GCC version gcc --version # Should be 11.2 # Check CMake version cmake --version # Should be 3.26 # Check Python version python --version # Should be 3.9Installation MethodsOption 1: Using uv (Recommended)uv is a fast Python package manager:# Clone the repository git clone --recursive https://gitcode.com/cann/asnumpy.git cd asnumpy # Install with uv uv syncOption 2: Using pip# Clone the repository git clone --recursive https://gitcode.com/cann/asnumpy.git cd asnumpy # Upgrade pip, setuptools, and wheel to their latest versions pip install --upgrade pip setuptools wheel # Install the build package, which provides a simple build front-end for Python packages pip install build # Build the current Python project (create source distribution and wheel) python -m build # Install all generated wheel (.whl) files from the dist/ directory pip install dist/*.whlOption 3: Development ModeFor development, install in editable mode:# Clone the repository git clone --recursive https://gitcode.com/cann/asnumpy.git cd asnumpy # Install in development mode pip install -e .This allows code changes to take effect immediately without reinstallation.Verify InstallationBasic Verificationimport asnumpy as ap # Create an array on NPU arr ap.ones((1000, 1000), dtypeap.float32) print(fShape: {arr.shape}) # Shape: (1000, 1000) print(✓ AsNumpy installed successfully!)Complete Verificationimport asnumpy as ap import numpy as np # Create a numpy array np_array np.array([1, 2, 3, 4, 5], dtypenp.float32) # Convert to AsNumpy array (transfer to NPU) npu_array ap.ndarray.from_numpy(np_array) # Perform operations on NPU result ap.sum(npu_array) print(fSum of array: {result.to_numpy()}) # Verify result assert result.to_numpy() 15.0 print(✓ Installation verified successfully!)TroubleshootingCommon IssuesImport ErrorSymptom:ModuleNotFoundError: No module named asnumpySolution:Ensure AsNumpy is installed:pip list | grep asnumpyCheck youre using the correct Python environmentTry reinstalling:pip install -e . --no-build-isolationCompilation ErrorSymptom:Build fails with CMake or GCC errorsSolution:Check CMake version:cmake --version(need 3.26)Check GCC version:gcc --version(need 11.2)Verify environment variable:echo $ASCEND_TOOLKIT_HOMEClean rebuild:pip install -e . --no-build-isolationRuntime ErrorSymptom:RuntimeError: ACL error ...Solution:Verify NPU is available:npu-smi infoCheck CANN installationEnsure youre running on a machine with Ascend 910B NPUPerformance IssuesSymptom:AsNumpy is slower than NumPySolution:For small arrays ( 1000×1000), CPU may be faster due to NPU launch overheadTry larger arrays to see NPU acceleration benefitsSee Benchmarks for expected performanceGetting HelpIf you encounter issues not covered here:Check the FAQSearch existing issuesOpen a new issue with:Your system information (OS, Python version, CANN version)Complete error messageSteps to reproduce【免费下载链接】asnumpy-docs项目地址: https://gitcode.com/cann/asnumpy-docs创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考