Skip to main content

A memory allocator for PyTorch to allow using more memory than the iGPU reserved

Project description

pytorch_rocm_gtt

codecov CI

Python package to allow ROCm to overcome the reserved iGPU memory limits.

Based on https://github.com/pomoke/torch-apu-helper/tree/main, after discussion here: https://github.com/ROCm/ROCm/issues/2014

Install it from PyPI

pip install pytorch_rocm_gtt

Usage

Just call this before starting pytorch allocations (model or torch):

import pytorch_rocm_gtt

pytorch_rocm_gtt.patch()

hipcc command should be in your $PATH.

After that, just allocate GPU memory as you would with cuda:

import torch

torch.rand(1000).to("cuda")

Compatibility

In order to use this package, your APU must be compatible with ROCm in the first place.

Check AMD documentation on how to install ROCm for your distribution.

Docker images

We have pre-built images based on ROCm images, but also including the new memory allocator.

You can check the list of available images in DockerHub.

For example, to run a python shell with ROCm 6.0.2, PyTorch 2.1.2 and the unbounded memory allocator, run this shell command:

$ docker run --rm -it \
  --cap-add=SYS_PTRACE \
  --security-opt seccomp=unconfined \
  --device=/dev/kfd \
  --device=/dev/dri \
  --group-add video \
  --ipc=host \
  --shm-size 8G \
  -e HSA_OVERRIDE_GFX_VERSION=11.0.1 \
  pappacena/rocm-pytorch:rocm6.0.2_ubuntu22.04_py3.10_pytorch_2.1.2 \
  python

Python 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytorch_rocm_gtt
>>> pytorch_rocm_gtt.patch()
>>> import torch
>>> torch.rand(1000, 1000).to("cuda")
tensor([[0.3428, 0.3032, 0.7657,  ..., 0.1255, 0.3866, 0.3153],
        [0.9015, 0.3409, 0.8885,  ..., 0.4413, 0.4961, 0.9245],
        [0.3883, 0.2388, 0.7439,  ..., 0.0647, 0.6922, 0.9496],
        ...,
        [0.4221, 0.7197, 0.5481,  ..., 0.5292, 0.7475, 0.3166],
        [0.1787, 0.9987, 0.7080,  ..., 0.8570, 0.3217, 0.1324],
        [0.6306, 0.0611, 0.1979,  ..., 0.1404, 0.4922, 0.2805]],
       device='cuda:0')

Development

Read the CONTRIBUTING.md file.

How to release

Update pyproject.toml file with the desired version, and run make release to create the new tag.

After that, the github action will publish to pypi.

Once it is published, run the docker_build_and_publish.sh <version-number> script to update the docker images.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorch_rocm_gtt-0.1.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

pytorch_rocm_gtt-0.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pytorch_rocm_gtt-0.1.2.tar.gz.

File metadata

  • Download URL: pytorch_rocm_gtt-0.1.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1016-azure

File hashes

Hashes for pytorch_rocm_gtt-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9343b743c9f6e6bb32862f72dd9710c5ca8b390b2be9c67326d85a0f7afe70bb
MD5 74d4102104be217778ab5bc2ef928e44
BLAKE2b-256 28bedf53af2c8cc45407443bae8cd9580498883a51a2493722242dda6ec8f42a

See more details on using hashes here.

File details

Details for the file pytorch_rocm_gtt-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pytorch_rocm_gtt-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1016-azure

File hashes

Hashes for pytorch_rocm_gtt-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c83a1578c6e8f7c872130024ef0bb0bc8c83a094c5006f67ccd3e76783261e19
MD5 9de28d57511422f45cb119367bc00c68
BLAKE2b-256 96e2f38a6c381dfcaaee503b58ef9ea712ea05b9fa710ce308781da055c788eb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page