Cannot import torch in Apple M1 Macbook

wangjia184: <pre><code class="lang-auto">import sys
import numpy as np

import platform
print (platform.platform())

print ("Python Version:{}".format(sys.version))
print ("NumPy Version:{}".format(np.__version__))


import torch
torch.device("mps")
torch.__version__
torch.tensor([1,2,3], device="mps")
print (torch.has_mps)

</code></pre>
<p>It failed to import torch</p>
<pre><code class="lang-auto">macOS-12.4-arm64-arm-64bit
Python Version:3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:01:00) 
[Clang 13.0.1 ]
NumPy Version:1.23.1
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [11], in &lt;cell line: 11&gt;()
      7 print ("Python Version:{}".format(sys.version))
      8 print ("NumPy Version:{}".format(np.__version__))
---&gt; 11 import torch
     12 torch.device("mps")
     13 torch.__version__

File ~/opt/anaconda3/envs/ml/lib/python3.9/site-packages/torch/__init__.py:22, in &lt;module&gt;
     19 if sys.version_info &lt; (3,):
     20     raise Exception("Python 2 has reached end-of-life and is no longer supported by PyTorch.")
---&gt; 22 from ._utils import _import_dotted_name
     23 from ._utils_internal import get_file_path, prepare_multiprocessing_environment, \
     24     USE_RTLD_GLOBAL_WITH_LIBTORCH, USE_GLOBAL_DEPS
     25 # TODO(torch_deploy) figure out how to freeze version.py in fbcode build

ImportError: cannot import name 'classproperty' from 'torch._utils' (/Users/xxxx/opt/anaconda3/envs/ml/lib/python3.9/site-packages/torch/_utils.py)
</code></pre>
<p>I am installing the nightly version to test mps. Installation log</p>
<pre><code class="lang-auto">$ pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu 
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/nightly/cpu
Collecting torch
  Downloading https://download.pytorch.org/whl/nightly/cpu/torch-1.13.0.dev20220728-cp39-none-macosx_11_0_arm64.whl (50.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.4/50.4 MB 549.9 kB/s eta 0:00:00
Collecting torchvision
  Downloading https://download.pytorch.org/whl/nightly/cpu/torchvision-0.14.0.dev20220727-cp39-cp39-macosx_11_0_arm64.whl (1.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 5.2 MB/s eta 0:00:00
Collecting torchaudio
  Downloading https://download.pytorch.org/whl/nightly/cpu/torchaudio-0.14.0.dev20220603-cp39-cp39-macosx_11_0_arm64.whl (2.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.7/2.7 MB 4.6 MB/s eta 0:00:00
Requirement already satisfied: typing-extensions in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from torch) (4.1.1)
Requirement already satisfied: numpy in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from torchvision) (1.23.1)
Requirement already satisfied: requests in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from torchvision) (2.28.1)
Requirement already satisfied: pillow!=8.3.*,&gt;=5.3.0 in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from torchvision) (9.2.0)
Requirement already satisfied: charset-normalizer&lt;3,&gt;=2 in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from requests-&gt;torchvision) (2.0.4)
Requirement already satisfied: urllib3&lt;1.27,&gt;=1.21.1 in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from requests-&gt;torchvision) (1.26.9)
Requirement already satisfied: idna&lt;4,&gt;=2.5 in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from requests-&gt;torchvision) (3.3)
Requirement already satisfied: certifi&gt;=2017.4.17 in ./opt/anaconda3/envs/ml/lib/python3.9/site-packages (from requests-&gt;torchvision) (2022.6.15)
Installing collected packages: torch, torchvision, torchaudio
Successfully installed torch-1.13.0.dev20220728 torchaudio-0.14.0.dev20220603 torchvision-0.14.0.dev20220727

</code></pre>
<p>Is this a bug?</p>