Skip to content

Run PyTorch on Arm Copilot+ PCs: Build & Test AI Locally

  • News

“`html

Microsoft’s Dream Team: Copilot+ PCs and PyTorch

Remember when Microsoft first announced its Copilot+ PCs almost a year ago? They promised a special set of tools called the Copilot Runtime to help developers make the most of the built-in AI smarts. Think of it like giving these PCs a superpower for understanding and using AI! Instead of relying on huge, distant cloud computers, the idea was to bring AI closer to home, keeping your personal stuff private and secure.

These Copilot+ PCs use something called NPUs to make AI magic happen.

Lila: John, what’s an NPU? It sounds like alphabet soup!

John: Great question, Lila! An NPU, or Neural Processing Unit, is a special piece of hardware inside the computer that’s designed specifically for AI tasks. Think of it like a mini-brain that’s really good at learning and recognizing patterns, much like how your brain learns to recognize faces.

These NPUs are super speedy, handling tons of calculations every second. They’re perfect for the type of modern that powers so much of today’s AI.

The Copilot Runtime: A Year in the Making

It took almost a year for these Copilot Runtime tools to arrive, and even now, a lot of it is still a work in progress. But that’s understandable! Building a reliable set of tools and services for AI is a big job. Microsoft wanted to get it right, even if it took a little longer than expected.

Part of the delay was due to working with the Qualcomm Hexagon NPU (the “brain” inside some of these PCs). But mostly, it was about making these new technologies easy for developers to use.

PyTorch Arrives for Arm-Based PCs!

The latest piece of the puzzle is a special version of PyTorch (a popular tool for building AI models) that’s designed to work perfectly with Arm-based PCs. With so much buzz around huge AI models like those that power chatbots, it’s easy to forget that smaller, more focused AI models can do a lot of good too. Think image processing or even smaller language models that can help you write emails.

Why PyTorch is a Big Deal

PyTorch gives developers a set of tools to build complex AI models. It uses things called tensors and neural networks to make it easier to work with large amounts of data and train AI models.

Lila: Tensors and neural networks? Those sound scary!

John: Don’t worry, Lila! Think of tensors as special containers for holding numbers, like a spreadsheet but much more powerful. Neural networks are like a simplified model of the human brain, made up of connected “neurons” that learn from data. PyTorch helps you put these together to create AI models.

PyTorch lets you experiment with AI models, quickly seeing how changes affect the results. You can start with the basics, define the layers in a , and see how data flows through it. This allows you to build a machine learning model, refine its parameters, and compare its predictions against real data. You can also use tensors to process data, like images, for use in the neural network. Once the model is trained, you can save it and use it to make predictions!

Key benefits of using PyTorch:

  • Experimentation: Quickly test different AI models and see what works.
  • Control: Understand how data flows through the network.
  • Training: Refine your model until it gives you the results you want.

Bringing PyTorch to Arm: A Developer’s Dream

Microsoft wants its Copilot+ PCs to be great for both regular users and developers. That’s why they’re releasing more and more tools that work well with Arm-based PCs. The latest is this Arm-native version of PyTorch and its LibTorch libraries.

While it doesn’t yet fully support all the special AI hardware (like the Qualcomm Hexagon NPUs), the Snapdragon X processors in these PCs are still powerful enough for many AI tasks. You can now build, test, and package AI applications all on your Arm-based PC, without having to worry about compatibility issues.

Getting Started with PyTorch on Arm

So, how do you get started? First, you need to make sure you have all the necessary tools installed. This includes the Visual Studio Build Tools (with C++ support), , and Rust. Once you have these, you can use the “pip” installer to install the latest version of PyTorch. It might take a while to download and install everything, so be patient!

If you prefer to use C++, you can download an Arm-ready version of LibTorch. Microsoft’s blog post has a link to the latest version. Once you have everything installed, you’re ready to start experimenting with PyTorch!

Running AI Models: Putting PyTorch to the Test

Once PyTorch is installed, you can start building, training, and testing AI models. Microsoft has provided some sample code to get you started. You can download these files from a GitHub repository.

The sample code downloads a pre-trained AI model and sets up a system that allows you to generate images from text prompts. It takes about 30 seconds to generate an image on a 12-core Snapdragon X Elite processor. While it would be great to have full support for the NPUs in these PCs, this is a big step in the right direction.

Even without NPU support, running a PyTorch inference (making a prediction with an AI model) is relatively simple. It only takes a few lines of code to download the model, load it into PyTorch, and run it. Having a framework like this makes it easy to test new models and see how they perform.

John’s and Lila’s Thoughts

John: It’s exciting to see Microsoft investing in AI development tools for Arm-based PCs. Having an Arm version of PyTorch opens up a lot of possibilities for building innovative AI applications.

Lila: As someone new to AI, I’m still trying to wrap my head around all of this. But it’s cool to see how these new technologies are making AI more accessible to everyone!

This article is based on the following original source, summarized from the author’s perspective:
Running PyTorch on an Arm Copilot+ PC

“`

Leave a Reply

Your email address will not be published. Required fields are marked *