官术网_书友最值得收藏!

How to do it...

We will begin by installing Anaconda. You can skip this if you already have Anaconda for Python 3.6 or 3.7 running on your system. Otherwise, you can follow the instructions at https://docs.anaconda.com/anaconda/install/ for your operating system, as follows:  

Feel free to play around with PyTorch once the setup is done. To verify that you have the right setup of Anaconda and Python, you can enter the following line in your Terminal in Linux/Mac or Command Prompt in Windows (from now on, we will just call it Terminal):

python

It will display your Python Anaconda environment. You should see something similar to the following screenshot:

If Anaconda and Python 3.x are not mentioned, please check the system path or the path Python is running from.

The next thing to do is to install PyTorch. First, go to https://pytorch.org/get-started/locally/ and pick the description of your environment from the following table:

Here, we use Mac, Conda, Python 3.7, and running locally (no CUDA) as an example, and enter the resulting command line in the Terminal:

conda install pytorch torchvision -c pytorch

To confirm PyTorch is installed correctly, run the following lines of code in Python:

>>> import torch
>>> x = torch.empty(3, 4)
>>> print(x)
tensor([[ 0.0000e+00, 2.0000e+00, -1.2750e+16, -2.0005e+00],
[ 9.8742e-37, 1.4013e-45, 9.9222e-37, 1.4013e-45],
[ 9.9220e-37, 1.4013e-45, 9.9225e-37, 2.7551e-40]])

If a 3 x 4 matrix is displayed, that means PyTorch is installed correctly.

Now we have successfully set up the working environment.

主站蜘蛛池模板: 和田市| 包头市| 长子县| 宁安市| 苏州市| 金溪县| 大庆市| 鄂温| 高台县| 平安县| 虎林市| 临夏县| 临清市| 余姚市| 阿克苏市| 山东省| 文登市| 霍林郭勒市| 林芝县| 永平县| 儋州市| 含山县| 大名县| 高尔夫| 昭通市| 桃园市| 房产| 麟游县| 凤城市| 南乐县| 葵青区| 通河县| 茶陵县| 鄂尔多斯市| 天长市| 绩溪县| 龙江县| 绥中县| 邓州市| 平果县| 霸州市|