MPS not built or available on Apple M2

I’ve got the following function to check whether MPS is enabled in Pytorch on my MacBook Pro Apple M2 Max. I get the response:

MPS is not available
MPS is not built

def check_mps():
    if torch.backends.mps.is_available():
        print("MPS is available")
    else:
        print("MPS is not available")

    if torch.backends.mps.is_built():
        print("MPS is built")
    else:
        print("MPS is not built")

    if torch.backends.mps.is_macos_or_newer(13, 0):
        print("MPS is macOS 13 or newer")
    else:
        print("MPS is not macOS 13 or newer")

I’ve already verified my OS is up-to-date, and I’m not seeing many other steps to get Pytorch running on Metal. What am I missing?

Try:

pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu

Also even though some new errors popped up for me, I created a venv that downloaded python 3.10 and used that for doing the above pip install and that helped get it set up