Hi,
Thanks for the fast reply!
After using
pip3 install --pre --force-reinstall torch --index-url https://download.pytorch.org/whl/nightly/cpu
The PyTorch version switched from 2.0.1 to 2.1.0. And the above issue is gone.
I also check with the mps availability with following code:
import torch
if torch.backends.mps.is_available():
mps_device = torch.device("mps")
x = torch.ones(1, device=mps_device)
print (x)
else:
print ("MPS device not found.")
And the output is correct.
tensor([1.], device='mps:0')
However, I still cannot run the example code successfully.
The error output shows that I didn't have the correct version of metal 2.2 or above.
(base) ethan@liuyanfudeMacBook-Pro CustomizingAPyTorchOperation % python3 run_sample.py
Traceback (most recent call last):
File "/Users/ethan/Downloads/CustomizingAPyTorchOperation/run_sample.py", line 59, in <module>
test_softshrink()
File "/Users/ethan/Downloads/CustomizingAPyTorchOperation/run_sample.py", line 55, in test_softshrink
test_correctness()
File "/Users/ethan/Downloads/CustomizingAPyTorchOperation/run_sample.py", line 49, in test_correctness
output_custom_softshrink_op = custom_softshrink(input_data)
File "/Users/ethan/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1505, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/ethan/miniconda3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1514, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/ethan/Downloads/CustomizingAPyTorchOperation/softshrink.py", line 27, in forward
return compiled_lib.mps_softshrink(input, self.lambd)
RuntimeError: Failed to to create custom kernel library, error: program_source:18:3: error: 'host_name' attribute requires Metal language standard macos-metal2.2 or higher
[[host_name("softshrink_kernel_half")]]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
program_source:25:3: error: 'host_name' attribute requires Metal language standard macos-metal2.2 or higher
[[host_name("softshrink_kernel_float")]]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My Xcode version is 14.3.1 and running with Ventura 13.4.1.
I am using Intel/AMD Macbook pro, will this be the problem?
Since the requirements include mac with AMD GPUs.
Thanks!