How to install PyTorch natively on Apple M1 with Miniforge?

2.4k Views Asked by At

I'd like to run PyTorch natively on my M1 MacBook Air. I followed these instructions which say to start with

brew install miniforge

brew info miniforge confirms that I installed the osx-arm64 version, so that's fine. Then I did

conda create --name pytorch_env python=3.8

This should download and install a few packages, but when they are listed before installation I see that they are all osx-64, not osx-arm64. The same happens for the actual PyTorch installation:

conda install -c pytorch pytorch

Only osx-64 packages get installed. I completed the process and ran a sample script which confirmed that I only have the Intel version running.

I then installed universal Python 3.9.6 and tried to create an environment with Python 3.9, but this did not make a difference.

I also have an Anaconda3 installation on this machine, which is probably x86-only (the installer is).

What can I do now?

1

There are 1 best solutions below

0
On BEST ANSWER

It was the leftover from my Anaconda3 installation, indeed.

I had to delete the conda initialize part in my .zshrc file. Then I reran the instructions starting from conda init zsh, and it worked.