PyTorch via PIP installation

PyTorch via PIP installation#

AMD recommends the PIP install method to create a PyTorch environment when working with ROCm™ for machine learning development.

Note
To install the following wheels, Python 3.12 must be installed.

Prerequisites#

Install PyTorch via PIP#

  1. Enter the commands to set up ROCm environment.

    pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.1.1/rocm_sdk_core-0.1.dev0-py3-none-win_amd64.whl
    pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.1.1/rocm_sdk_devel-0.1.dev0-py3-none-win_amd64.whl
    pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.1.1/rocm_sdk_libraries_custom-0.1.dev0-py3-none-win_amd64.whl
    pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.1.1/rocm-0.1.dev0.tar.gz
    
  2. Enter the commands to install torch, torchvision and torchaudio for ROCm AMD GPU support.

    Note
    This may take several minutes. See Compatibility matrices for support information.

    pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.1.1/torch-2.9.0+rocmsdk20251116-cp312-cp312-win_amd64.whl
    pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.1.1/torchaudio-2.9.0+rocmsdk20251116-cp312-cp312-win_amd64.whl
    pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.1.1/torchvision-0.24.0+rocmsdk20251116-cp312-cp312-win_amd64.whl
    

Verify PyTorch installation#

Confirm if PyTorch is correctly installed.

  1. Verify if Pytorch is installed and detecting the GPU compute device.

    python -c "import torch" 2>nul && echo Success || echo Failure
    

    Expected result:

    Success
    
  2. Enter command to test if the GPU is available.

    python -c "import torch; print(torch.cuda.is_available())"
    

    Expected result:

    True
    
  3. Enter command to display installed GPU device name.

    python -c "import torch; print(f'device name [0]:', torch.cuda.get_device_name(0))"
    

    Example result: device name [0]: Radeon RX 7900 XTX

    device name [0]: <Supported AMD GPU>
    
  4. Enter command to display component information within the current PyTorch environment.

    python -m torch.utils.collect_env
    

    Example result:

    PyTorch version: 2.9.0+rocmsdk20251107
    Is debug build: False
    CUDA used to build PyTorch: N/A
    ROCM used to build PyTorch: 7.1.52802-561cc400e1
    
    OS: Microsoft Windows 11 Pro (10.0.26100 64-bit)
    GCC version: Could not collect
    Clang version: Could not collect
    CMake version: Could not collect
    Libc version: N/A
    
    Python version: 3.12.10 (tags/v3.12.10:0cc8128, Apr  8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)] (64-bit runtime)
    Python platform: Windows-11-10.0.26100-SP0
    Is CUDA available: True
    CUDA runtime version: Could not collect
    CUDA_MODULE_LOADING set to:
    GPU models and configuration: AMD Radeon PRO W7900 (gfx1100)
    Nvidia driver version: Could not collect
    cuDNN version: Could not collect
    Is XPU available: False
    HIP runtime version: 7.1.52802
    MIOpen runtime version: 3.5.1
    Is XNNPACK available: True
    

Environment set-up is complete, and the system is ready for use with PyTorch to work with machine learning models, and algorithms.

See also: Limitations and recommended settings.