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

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.

主站蜘蛛池模板: 云阳县| 中方县| 措美县| 常德市| 萝北县| 建德市| 梅州市| 房山区| 建平县| 南澳县| 晋州市| 九台市| 漳平市| 饶平县| 双江| 庐江县| 昌江| 大城县| 龙泉市| 芜湖市| 星子县| 会昌县| 新泰市| 荃湾区| 永登县| 苗栗县| 正镶白旗| 根河市| 青冈县| 永康市| 福州市| 肃宁县| 和硕县| 江川县| 册亨县| 怀集县| 湖北省| 柞水县| 达州市| 红原县| 剑河县|