Skip to content

Torch scatter executes functional code upon import #209

@TimZaman

Description

@TimZaman

To keep imports in Python snappy, it's wise not to execute any functional code;

import torch_scatter

Creates a cuda context on all visible gpus due to the call https://github.com/rusty1s/pytorch_scatter/blob/master/torch_scatter/__init__.py#L9

suffix = 'cuda' if torch.cuda.is_available() else 'cpu'

This statement torch.cuda.is_available() should be encapsulated and not be executed upon import.

I'm a bit busy to make a PR now [sorry], just putting this here for posterity.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions