Get Started
Select preferences and run the command to install PyTorch locally, or get started quickly with one of the supported cloud platforms.
XPU device backend brings native Intel GPU support to PyTorch, enabling performant training and inference on both Linux and Windows.<\/p>\n
The system with configured Intel GPU card is required. For detailed list of supported devices and driver install instructions refer to Getting Started on Intel GPU<\/a>.<\/p>\n Use the pip package manager to install PyTorch with XPU support. Select your preferred options in the selector above to get the installation command.<\/p>\n To ensure that PyTorch was installed correctly with XPU support, run the following code:<\/p>\n The following, or a similar output, indicates successful installation:<\/p>\n For more information, please visit the torch.xpu<\/a>.<\/p>","ascend_npu":" Ascend for PyTorch (TorchNPU)<\/strong> is a deep learning adaptation framework built on Ascend. It enables Ascend NPUs to support the PyTorch framework, delivering the powerful computing capabilities of Ascend AI processors to PyTorch developers and users.<\/p>\n Before installing PyTorch with Ascend NPU support, you must install the CANN toolkit. Download it from the Ascend Community<\/a> and follow the CANN Installation Guide<\/a>.<\/p>\n Use the pip package manager to install PyTorch with Ascend NPU support. Please refer to the installation page<\/a> and select your preferred options in the selector above to get the installation command.<\/p>\n To ensure that PyTorch was installed correctly with Ascend NPU support, run the following code:<\/p>\n The following, or a similar output, indicates successful installation:<\/p>\n For more information, please visit:<\/p>\n Select preferences and run the command to install PyTorch locally, or get started quickly with one of the supported cloud platforms. In the selector below, you will find compute platforms and configurations provided by our partners and community members. Choose your preferences and run the provided command. Note: More platform-specific details will appear below upon selection. Please scroll down.Installation<\/h2>\n
pip<\/h3>\n
Verification<\/h2>\n
<\/span>import<\/span> <\/span>torch<\/span>\nprint<\/span>(<\/span>torch<\/span>.<\/span>__version__<\/span>)<\/span>\n\n# Check XPU availability<\/span>\nif<\/span> torch<\/span>.<\/span>xpu<\/span>.<\/span>is_available<\/span>():<\/span>\n print<\/span>(<\/span>"XPU is available!"<\/span>)<\/span>\n print<\/span>(<\/span>f<\/span>"XPU devices: <\/span>{<\/span>torch<\/span>.<\/span>xpu<\/span>.<\/span>device_count<\/span>()<\/span>}<\/span>"<\/span>)<\/span>\nelse<\/span>:<\/span>\n print<\/span>(<\/span>"XPU is not available."<\/span>)<\/span>\n<\/code><\/pre><\/div>\n\n<\/span>2<\/span>.13.0+xpu\nXPU <\/span>is <\/span>available!\nXPU <\/span>devices: <\/span>4<\/span>\n<\/code><\/pre><\/div>\n\nDocumentation<\/h2>\n
Installing on Ascend NPU<\/h1>\n
Prerequisites<\/h2>\n
Hardware Requirements<\/h3>\n
\n
Software Requirements<\/h3>\n
\n
Installation<\/h2>\n
pip<\/h3>\n
<\/span>pip3 <\/span>install <\/span>torch<\/span>==<\/span>2<\/span>.10.0 <\/span>--index-url <\/span>https:\/\/download.pytorch.org\/whl\/cpu <\/span>&&<\/span> <\/span>pip3 <\/span>install <\/span>torch-npu==<\/span>2<\/span>.10.0\n<\/code><\/pre><\/div>\n\nVerification<\/h2>\n
<\/span>import<\/span> <\/span>torch<\/span>\nimport<\/span> <\/span>torch_npu<\/span>\n\nx<\/span> =<\/span> torch<\/span>.<\/span>randn<\/span>(<\/span>2<\/span>,<\/span> 2<\/span>,<\/span> device<\/span>=<\/span>"npu"<\/span>)<\/span>\ny<\/span> =<\/span> torch<\/span>.<\/span>randn<\/span>(<\/span>2<\/span>,<\/span> 2<\/span>,<\/span> device<\/span>=<\/span>"npu"<\/span>)<\/span>\nz<\/span> =<\/span> x<\/span>.<\/span>mm<\/span>(<\/span>y<\/span>)<\/span>\n\nprint<\/span>(<\/span>z<\/span>)<\/span>\n<\/code><\/pre><\/div>\n\n<\/span>tensor([[<\/span>-0.0515, <\/span>0<\/span>.3664]<\/span>,\n <\/span>[<\/span>-0.1258, <\/span>-0.5425]]<\/span>, <\/span>device<\/span>=<\/span>'npu:0'<\/span>)<\/span>\n<\/code><\/pre><\/div>\n\nDocumentation<\/h2>\n
\n
Get Started
Additional Platforms