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

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.

主站蜘蛛池模板: 长治县| 宁都县| 杭州市| 含山县| 贵定县| 彩票| 平遥县| 乌兰察布市| 剑川县| 台北市| 乌拉特中旗| 陇川县| 湟源县| 江口县| 平乐县| 冷水江市| 赤壁市| 怀宁县| 汪清县| 宝坻区| 越西县| 莆田市| 巍山| 若羌县| 浦北县| 浦江县| 雷山县| 三门县| 山阳县| 五常市| 如东县| 富平县| 黄平县| 宜兰县| 阳曲县| 晋宁县| 马公市| 佛教| 茂名市| 普洱| 恩施市|