Meant for app developers. A convenient way to install and configure the appropriate version of PyTorch on the user's computer, based on the OS and GPU manufacturer and model number.
Project description
torchruntime
torchruntime is a lightweight package for automatically installing the appropriate variant of PyTorch on a user's computer, based on their OS, and GPU manufacturer and GPU model.
This package is used by Easy Diffusion, but you're welcome to use it as well. It's useful for developers who make PyTorch-based apps that target users with NVIDIA, AMD and Intel graphics cards (as well as CPU-only usage), on Windows, Mac and Linux.
- Platforms:
cpu
,cuda
,rocm
,xpu
,directml
,ipex
- Operating systems:
Windows
,Linux
,Mac
(Apple Silicon and Intel) - GPU Manufacturers:
NVIDIA
,AMD
,Intel
- GPU Types: Dedicated and Integrated
Why?
It lets you treat PyTorch as a single dependency (like it should be), and lets you assume that each user will get the most-performant variant of PyTorch suitable for their computer's OS and hardware.
It deals with the complexity of the variety of torch builds and configurations required for CUDA, AMD (ROCm, DirectML), Intel (xpu/DirectML/ipex), and CPU-only.
Compatibility table: Click here to see the supported graphics cards and operating systems.
Installation
Supports Windows, Linux, and Mac.
pip install torchruntime
Usage
Step 1. Install the appropriate variant of PyTorch
This command should be run on the user's computer, or while creating platform-specific builds:
python -m torchruntime install
This will install torch
, torchvision
, and torchaudio
, and will decide the variant based on the user's OS, GPU manufacturer and GPU model number. See customizing packages for more options.
Step 2. Configure torch
This should be run inside your program, to initialize the required environment variables (if any) for the variant of torch being used.
import torchruntime
torchruntime.configure()
(Optional) Step 3. Test torch
Run python -m torchruntime test
to run a set of tests to check whether the installed version of torch is working correctly.
Customizing packages
By default, python -m torchruntime install
will install the latest available torch
, torchvision
and torchaudio
suitable on the user's platform.
You can customize the packages to install by including their names:
- For e.g. to install only
torch
andtorchvision
, you can runpython -m torchruntime install torch torchvision
- To install specific versions (in pip format), you can run
python -m torchruntime install "torch>2.0" "torchvision==0.20"
Supported torch packages: torch
, torchvision
, torchaudio
, torchao
.
Note: If you specify package versions, please keep in mind that the version may not be available to all the users on all the torch platforms. For e.g. a user with Python 3.8 would not be able to install torch 2.5 (or higher), because torch 2.5 dropped support for Python 3.8.
So in general, it's better to avoid specifying a version unless it really matters to you (or you know what you're doing). Instead, please allow torchruntime
to pick the latest-possible version for the user.
Versioning scheme
The versioning scheme for torchruntime
will be major.minor.patch
, e.g. 1.20.3
.
The patch
version will be changed for automatic PCI database updates, e.g. support for new graphics cards. The minor
version will be changed for non-breaking code changes, e.g. routine maintenance, refactoring or bug fixes. The major
version will be changed for breaking code changes, e.g. API changes.
It is recommended that you rely on the minor version, for e.g. use torchruntime ~= 1
in requirements.txt
(change this to the current major version), which will install versions like 1.21.0
, 1.22.2
etc but not 2.0.0
.
Compatibility table
The list of platforms on which torchruntime
can install a working variant of PyTorch.
Note: This list is based on user feedback (since I don't have all the cards). Please let me know if your card is supported (or not) by opening a pull request or issue or messaging on Discord (with supporting logs).
CPU-only
OS | Supported? | Notes |
---|---|---|
Windows | ✅ Yes | x86_64 |
Linux | ✅ Yes | x86_64 and aarch64 |
Mac (M1/M2/M3/M4) | ✅ Yes | arm64. mps backend |
Mac (Intel) | ✅ Yes | x86_64. Stopped after torch 2.2.2 |
NVIDIA
Series | Supported? | OS | Notes |
---|---|---|---|
50xx | ✅ Yes | Win/Linux | Uses CUDA 12.8 |
40xx | ✅ Yes | Win/Linux | Uses CUDA 12.8 |
30xx | ✅ Yes | Win/Linux | Uses CUDA 12.8 |
20xx | ✅ Yes | Win/Linux | Uses CUDA 12.8 |
16xx | ✅ Yes | Win/Linux | Uses CUDA 12.8. Requires full-precision for image generation |
10xx | ✅ Yes | Win/Linux | Uses CUDA 12.4 |
7xx | ✅ Yes | Win/Linux | Uses CUDA 11.8 |
Note: Torch dropped support for Python 3.8 from torch >= 2.5. torchruntime falls back to CUDA 12.4, if python 3.8 is being used.
AMD
Discrete GPUs
Series | Supported? | OS | Notes |
---|---|---|---|
9xxx | ✅ Yes | Win/Linux | Navi4/RDNA4 (gfx120x). ROCm 6.4 on Linux. DirectML on Windows |
7xxx | ✅ Yes | Win/Linux | Navi3/RDNA3 (gfx110x). ROCm 6.2 on Linux. DirectML on Windows |
6xxx | ✅ Yes | Win/Linux | Navi2/RDNA2 (gfx103x). ROCm 6.2 on Linux. DirectML on Windows |
6xxx on Intel Mac | ✅ Yes | Intel Mac | gfx103x. 'mps' backend |
5xxx | ✅ Yes | Win/Linux | Navi1/RDNA1 (gfx101x). Full-precision required. DirectML on Windows. Linux only supports upto ROCm 5.2. Waiting for this for ROCm 6.2 support. |
5xxx on Intel Mac | ❓ Untested (WIP) | Intel Mac | gfx101x. Implemented but need testers, please message on Discord |
Radeon VII | ✅ Yes | Win/Linux | Vega 20 gfx906. Need testers for Windows, please message on Discord |
Radeon RX Vega 56 | ✅ Yes | Win/Linux | Vega 10 gfx900. ROCm 5.2 on Linux. DirectML on Windows |
4xx/5xx/Polaris | ⚠️ Partial | Win | gfx80x. Works with DirectML on Windows (notes, 4GB bug). Did not work with ROCm5.7 with custom-compiled PyTorch 1.13 on Linux (notes). |
Integrated GPUs (APU)
Series | Supported? | OS | Notes |
---|---|---|---|
Radeon 840M/860M/880M/890M/8040S/8050S/8060S (Strix/Strix Halo/Krackan) | ⚠️ Partial | Win/Linux | gfx115x/RDNA3.5. Works with DirectML on Windows. Need testers for Linux, please message on Discord |
Radeon 740M/760M/780M (Phoenix/Hawk Point) | ⚠️ Partial | Win/Linux | gfx1103/RDNA3. Works with DirectML on Windows. Need testers for Linux, please message on Discord |
Radeon 610M/660M/680M (Rembrandt/Raphael/Mendocino/VanGogh/GraniteRidge) | ❓ Untested (WIP) | Win/Linux | gfx103x/RDNA2. Need testers for Windows and Linux, please message on Discord |
Ryzen 5000 series (Cezanne/Lucienne) | ❓ Untested (WIP) | Win/Linux | gfx90c/GCN5.1. Need testers for Windows and Linux, please message on Discord |
Ryzen 4000 series (Renoir) | ❓ Untested (WIP) | Win/Linux | gfx90c/GCN5.1. Need testers for Windows and Linux, please message on Discord |
Ryzen 3000 series (Picasso) | ❓ Untested (WIP) | Win/Linux | gfx903/GCN5. Need testers for Windows and Linux, please message on Discord |
Ryzen 2000 series (Raven Ridge) | ❓ Untested (WIP) | Win/Linux | gfx902/GCN5. Need testers for Windows and Linux, please message on Discord |
Apple
Series | Supported? | Notes |
---|---|---|
M1/M2/M3/M4 | ✅ Yes | 'mps' backend |
AMD 6xxx on Intel Mac | ✅ Yes | Intel Mac |
AMD 5xxx on Intel Mac | ❓ Untested (WIP) | Intel Mac |
Intel
Series | Supported? | OS | Notes |
---|---|---|---|
Arc | ❓ Untested (WIP) | Win/Linux | Implemented but need testers, please message on Discord. Backends: 'xpu' or DirectML or ipex |
Integrated Iris/HD/UHD | ❓ Untested (WIP) | Win/Linux | Implemented but need testers, please message on Discord. Backends: 'xpu' or DirectML or ipex |
API
See API for a complete list of module functions.
FAQ
Why can't I just run 'pip install torch'?
pip install torch
installs the CPU-only version of torch, so it won't utilize your GPU's capabilities.
Why can't I just install torch-for-ROCm directly to support AMD?
Different models of AMD cards require different LLVM targets, and sometimes different ROCm versions. And ROCm currently doesn't work on Windows, so AMD on Windows is best served (currently) with DirectML.
And plenty of AMD cards work with ROCm (even when they aren't in the official list of supported cards). Information about these cards (for e.g. the LLVM target to use) is pretty scattered.
torchruntime
deals with this complexity for your convenience.
Contributing
📢 I'm looking for contributions in these specific areas:
- More testing on consumer AMD GPUs.
- More support for older AMD GPUs. Explore: Compile and host PyTorch wheels and rocm (on GitHub) for older AMD gpus (e.g. 580/590/Polaris) with the required patches.
- Intel GPUs.
- Testing on professional AMD GPUs (e.g. the Instinct series).
- An easy-to-run benchmark script (that people can run to check the level of compatibility on their platform).
- Improve the logic for supporting multiple AMD GPUs with different ROCm compatibility. At present, it just picks the latest GPU, which means it doesn't support running workloads on multiple AMD GPUs in parallel.
Please message on the Discord community if you have AMD or Intel GPUs, and would like to help with testing or adding support for them! Thanks!
Credits
- Code contributors on Easy Diffusion.
- Users on Easy Diffusion's Discord who've helped with testing on various GPUs.
- PCI Database automatically generated from the PCI ID Database at http://pci-ids.ucw.cz
More resources
- AMD Discrete GPU Names and AMD Integrated GPU Names
- AMD HSA architectures for APUs, and also the official ROCm list (check the latest).
- AMD GPU LLVM Architectures
- Status of ROCm support for AMD Navi 1
- Torch support for ROCm 6.2 on AMD Navi 1
- ROCmLibs-for-gfx1103-AMD780M-APU
- Pre-compiled torch for AMD gfx803 (and steps to compile)
- Another guide for compiling torch with rocm 6.2 for gfx803
- ROCm's device list (in their code)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file torchruntime-1.23.1.tar.gz
.
File metadata
- Download URL: torchruntime-1.23.1.tar.gz
- Upload date:
- Size: 68.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
ff33a90880fc8acaf47e13a6e6c3ca26ae6f099e9d317fe80dcefa99bbe693d6
|
|
MD5 |
b5623d3e6e31ee47012a970fe5ea6723
|
|
BLAKE2b-256 |
598f94373c5fa327b195b691d0a363266213acd4b55537bf2ab4687b4889774b
|
Provenance
The following attestation bundles were made for torchruntime-1.23.1.tar.gz
:
Publisher:
pypi-release-workflow.yml
on easydiffusion/torchruntime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
torchruntime-1.23.1.tar.gz
-
Subject digest:
ff33a90880fc8acaf47e13a6e6c3ca26ae6f099e9d317fe80dcefa99bbe693d6
- Sigstore transparency entry: 483996663
- Sigstore integration time:
-
Permalink:
easydiffusion/torchruntime@679bfb4e0bbe3ccd6723040a506f7e92b75d3ea8
-
Branch / Tag:
refs/tags/v1.23.1
- Owner: https://github.com/easydiffusion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi-release-workflow.yml@679bfb4e0bbe3ccd6723040a506f7e92b75d3ea8
-
Trigger Event:
release
-
Statement type:
File details
Details for the file torchruntime-1.23.1-py3-none-any.whl
.
File metadata
- Download URL: torchruntime-1.23.1-py3-none-any.whl
- Upload date:
- Size: 62.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
ca7a382683f7fec363c250cc2a057b521e0344d332ea11f424ac11a1fe23d57b
|
|
MD5 |
11747b3f8bec689d0a1bedbefc4ce7fb
|
|
BLAKE2b-256 |
776203abd41e34cedb133eb6b1e4c8dd6060f4956b23d75050b90d9df1785fae
|
Provenance
The following attestation bundles were made for torchruntime-1.23.1-py3-none-any.whl
:
Publisher:
pypi-release-workflow.yml
on easydiffusion/torchruntime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
torchruntime-1.23.1-py3-none-any.whl
-
Subject digest:
ca7a382683f7fec363c250cc2a057b521e0344d332ea11f424ac11a1fe23d57b
- Sigstore transparency entry: 483996679
- Sigstore integration time:
-
Permalink:
easydiffusion/torchruntime@679bfb4e0bbe3ccd6723040a506f7e92b75d3ea8
-
Branch / Tag:
refs/tags/v1.23.1
- Owner: https://github.com/easydiffusion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi-release-workflow.yml@679bfb4e0bbe3ccd6723040a506f7e92b75d3ea8
-
Trigger Event:
release
-
Statement type: