macOS M2 uses conda to configure the pytorch environment

1. conda

First of all, we need to have conda, the installation and configuration process of miniconda can be seen at this http://t.csdn.cn/ShcNb

2. Enter the official website

Select the corresponding version and copy the following command

conda install pytorch torchvision torchaudio -c pytorch

3. Start to create a virtual environment and download pytorch

  • into the terminal, enter

conda create -n torch-gpu python=3.9
conda activate torch-gpu
conda install pytorch torchvision torchaudio -c pytorch

The first command is to create a virtual environment named torch-gpu, python version 3.9

The second command is to activate the environment

The third command is to install pytorch

4. Test

python
import torch
torch.__version__
torch.device('mps')

Guess you like

Origin blog.csdn.net/qyqyqyi/article/details/129714370