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

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.

主站蜘蛛池模板: 沾化县| 镇巴县| 定西市| 横山县| 于都县| 清苑县| 丽江市| 盐亭县| 梅河口市| 萝北县| 西青区| 曲松县| 罗定市| 长岛县| 澜沧| 阳新县| 嘉鱼县| 临夏县| 黔南| 西乌| 泗洪县| 民丰县| 高密市| 长丰县| 柘荣县| 湄潭县| 大姚县| 宜章县| 叙永县| 京山县| 新余市| 崇文区| 平昌县| 松潘县| 本溪市| 三明市| 宁蒗| 乐昌市| 隆化县| 志丹县| 封丘县|