pytorch macos_Windows,Linux和MacOS上的PyTorch安装

pytorch macos

The installation of PyTorch is pretty straightforward and can be done on all major operating systems. However, if you want to get your hands dirty without actually installing it, Google Colab provides a good starting point.

PyTorch的安装非常简单,可以在所有主要操作系统上完成。 但是,如果您想在不进行实际安装的情况下弄脏手,则Google Colab提供了一个很好的起点。

Colab comes with preinstalled PyTorch and Tensorflow modules and works with both GPU and TPU support.

Colab随附了预装的PyTorch和Tensorflow模块,并与GPU和TPU支持一起使用。

For installation on your own computer, PyTorch comes with both the CUDA and no CUDA versions, depending upon the hardware available to you.

为了在您自己的计算机上安装,PyTorch随附CUDA和不提供CUDA版本,具体取决于您可用的硬件。

This will be a single step installation – PyTorch Start Locally.

这将是一步安装– PyTorch Local Local 。

Prerequisite: Anaconda Distribution (Link to official website) – You need Anaconda installed on your system to follow this tutorial. The download packages are available for all major operating systems and the process of installation is very straight forward.

先决条件: Anaconda发行版(链接到官方网站) –您需要在系统上安装Anaconda才能遵循本教程。 下载包适用于所有主要操作系统,安装过程非常简单。

So before you go ahead with the tutorial, make sure you have an up and running Anaconda distribution set up on your operating system.

因此,在继续学习本教程之前,请确保已在操作系统上建立并运行了Anaconda发行版。

Note: In case you don’t want to use Anaconda, you can always use PIP to install PyTorch. Since PIP comes bundled with Python installer, you will already have it in your system.

注意 :如果您不想使用Anaconda,则可以始终使用PIP安装PyTorch。 由于PIP与Python安装程序捆绑在一起,因此您已经将其安装在系统中。

在Windows上安装Pytorch (Install Pytorch on Windows)

The PyTorch website provides the following command for the windows system. PyTorch works with Windows 7 or higher and uses Python 3 or higher. Installing it using Anaconda is quite simple and can be done in a few minutes.

PyTorch网站为Windows系统提供以下命令。 PyTorch可在Windows 7或更高版本上使用,并使用Python 3或更高版本。 使用Anaconda进行安装非常简单,只需几分钟即可完成。

pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第1张图片
PyTorch Installation 1 PyTorch安装1

The next step is to paste the following command in your Anaconda prompt and run it.

下一步是将以下命令粘贴到Anaconda提示符中并运行它。


conda install pytorch torchvision cpuonly -c pytorch

The prompt will list out all the dependencies that will be installed along with PyTorch. If you are okay to proceed, type yes in the command line.

该提示将列出将与PyTorch一起安装的所有依赖项。 如果可以继续,请在命令行中输入yes。

pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第2张图片
PyTorch Installation 2 PyTorch安装2

Anaconda now proceeds with the installation. You can check the installation through the Python interpreter or a Jupyter Notebook later.

Anaconda现在继续安装。 您可以稍后通过Python解释器或Jupyter Notebook检查安装。

pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第3张图片
PyTorch Version PyTorch版本

Now you have successfully installed PyTorch on your Windows system.

现在,您已经在Windows系统上成功安装了PyTorch。

在Linux上安装PyTorch (Installing PyTorch on Linux)

If you open the same installation page from a Linux machine, you will notice that the generated command will be a different one.

如果从Linux机器打开相同的安装页面,则会注意到生成的命令将是不同的命令。

pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第4张图片
PyTorch Linux PyTorch Linux

The next step is to copy and paste the command into your terminal and run it.

下一步是将命令复制并粘贴到终端中并运行它。


conda install pytorch torchvision cpuonly -c pytorch
pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第5张图片
Pytorch Ubuntu Installation Pytorch Ubuntu安装

The terminal asks you for permission to install/update packages. You need to press yes as a response.

终端会要求您许可安装/更新软件包。 您需要按

pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第6张图片
Pytorch Ubuntu Packages Pytorch Ubuntu软件包

The installation will now continue to install torch and torchvision packages into your environment.

现在,安装将继续将TorchTorchvision软件包安装到您的环境中。

pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第7张图片
Pytorch Ubuntu Progress Pytorch Ubuntu进展

在Mac OS上安装PyTorch (Installing PyTorch on Mac OS)

We will use PIP to install PyTorch in Mac OS. All we need is to select the appropriate options on the PyTorch home page to get the install command.

我们将使用PIP在Mac OS中安装PyTorch。 我们所需要做的就是在PyTorch主页上选择适当的选项以获取安装命令。

pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第8张图片
Pytorch Quick Start Locally Mac Os Pytorch本地快速入门Mac OS

So, we have to run the following command to install PyTorch and torchvision libraries on Mac OS.

因此,我们必须运行以下命令在Mac OS上安装PyTorch和torchvision库。


$ pip3.7 install torch torchvision

Here is the output from the Terminal when the above command is executed.

这是执行上述命令时来自终端的输出。

Pip Install Torch 点安装火炬

The last line of the output clearly states that both torch and torchvision packages are successfully installed.

输出的最后一行清楚地表明,torch和torchvision软件包都已成功安装。

Let’s launch the Python 3.7 interpreter and print the torch version to confirm the successful installation.

让我们启动Python 3.7解释器并打印割炬版本以确认安装成功。


$ python3.7
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
1.4.0
>>>
pytorch macos_Windows,Linux和MacOS上的PyTorch安装_第9张图片
Python Print Torch Version Python Print Torch版本

结论 (Conclusion)

PyTorch is a very powerful machine learning framework. It’s used a lot in creating deep learning by processing large amounts of data. We will look into more features of PyTorch in the upcoming tutorials.

PyTorch是一个非常强大的机器学习框架。 它通过处理大量数据在创建深度学习中使用了很多方法。 我们将在接下来的教程中研究PyTorch的更多功能。

翻译自: https://www.journaldev.com/35965/pytorch-installation

pytorch macos

你可能感兴趣的:(python,linux,人工智能,深度学习,大数据)