Skip to content

Import side effect: GPU preallocatoin #722

@Jacob-Stevens-Haas

Description

@Jacob-Stevens-Haas

At import, diffrax appears to grab the full preallocation of GPU memory even when it won't ever be used on device. This is hard for me as a downstream library developer because I can't assume anything about backend in the library. When it comes to testing, I have in the past relied on a pytest fixture to determine how to set the default device. But since these are after imports, they can't be used with diffrax

Setting the device in jax config at import time works, but it feels like bad practice and wont allow generic control of longer-running benchmarks which may be run on CPU or GPU.

This may be due to the same issue in lineax - of your packages, only diffrax and lineax grab the GPU as an import side effect.

diffrax version: 0.7.0
python version 3.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions