tch-rs icon indicating copy to clipboard operation
tch-rs copied to clipboard

Not finding MPS on M1 Mac

Open n8henrie opened this issue 2 years ago • 4 comments

I'm using the following to enter a nix environment with pytorch installed:

$ NIXPKGS_ALLOW_UNFREE=1 LIBTORCH_BYPASS_VERSION_CHECK=1 LIBTORCH_USE_PYTORCH=1 \
    nix-shell -I nixpkgs=channel:nixpkgs-unstable \
        -p 'python310.withPackages (ps: with ps; [ pytorch-bin ])' \
        -p iconv

Some contextual discussion here about MPS support with nix-installed torch; it works with pytorch-bin and is available in that environment:

[nix-shell:~/git/tch-rs]$ python -c 'import torch; print(torch.backends.mps.is_available())'
True

Unfortunately tch-rs seems to think it doesn't exist:

[nix-shell:~/git/tch-rs]$ cargo run --example basics 2>/dev/null | grep mps
has_mps: false

n8henrie avatar Jul 29 '23 13:07 n8henrie

[nix-shell:~/git/tch-rs]$ python -c 'import torch; print(torch.__version__)'
2.0.1

n8henrie avatar Jul 29 '23 13:07 n8henrie

[nix-shell:~/git/tch-rs]$ python -c 'import torch; print(torch.__version__)'
2.0.1

@n8henrie There was in issue with the exact 2.0.0 version vs 2.0.1. Please see an issue ticket I have filed: https://github.com/LaurentMazare/tch-rs/issues/742

antimora avatar Jul 29 '23 14:07 antimora

@antimora do you think this explains the mps issue? I would have thought that the LIBTORCH_BYPASS_VERSION_CHECK=1 which @n8henrie is setting should get around the 2.0.0 vs 2.0.1 issue but maybe I'm missing something here?

LaurentMazare avatar Jul 29 '23 14:07 LaurentMazare

Sorry I missed this flag so I am not sure if it is related. I am still looking into this.

antimora avatar Jul 29 '23 14:07 antimora