Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metal and Tensor::print() #1

Closed
oersted opened this issue Oct 25, 2022 · 4 comments
Closed

Metal and Tensor::print() #1

oersted opened this issue Oct 25, 2022 · 4 comments

Comments

@oersted
Copy link

oersted commented Oct 25, 2022

Tensor::print() doesn't seem to segfault any more on PyTorch 1.12.1 and tch 0.8.0.

I did try Metal acceleration by applying your installation method with PyTorch nightly. At present it doesn't work mainly because tch is only compatible up to 1.12, but it sounds like we will get the Metal accelerated version working very soon: LaurentMazare/tch-rs#542

PS: Thank you very much for publishing this, it's by far the cleanest method I've found.

@ssoudan
Copy link
Owner

ssoudan commented Oct 26, 2022

Glad you found it useful.

The symlink is how I'm managed to get the repo layout to work for both OSX and linux - just get it point to the appropriate place on both architectures. The env variable in the cargo/config.toml are not conditional on the architecture AFAIK.

Note that the generated binaries will also need the DYLD_LIBRARY_PATH (or LD_LIBRARY_PATH on linux) to work. Not found an equivalent of gcc -L/somewhere/xxx for cargo/rustc. If you launch the executable with cargo run, the env will be set. There must some option to pass to the linker to change the search paths.

@oersted
Copy link
Author

oersted commented Oct 26, 2022

Yep, I actually came up with the exact same method since I was working on Linux too. But I see what you mean, good point, I hadn't considered that the binaries need the env vars too. Nevertheless, I've never had a good reason not to use cargo run.

@oersted oersted closed this as completed Oct 26, 2022
@oersted oersted reopened this Oct 26, 2022
@oersted
Copy link
Author

oersted commented Oct 26, 2022

In any case, I wrote the issue to make you aware of these developments mostly so that the README can be updated.

@ssoudan
Copy link
Owner

ssoudan commented Nov 19, 2022

Finally updated the example to PyTorch 1.13. Tensor transfers to and from MPS with to_device() works. Print() works for CPU tensors but not for MPS tensors as it seems to assume they are based on doubles - while they seems to be backed by floats (more digging needed).

@ssoudan ssoudan closed this as completed Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants