pytorch tour

1. Environmental preparation

First prepare to install Anaconda, version 3.7 for the environment. Enable the pytorch environment after creating the pytorch environment

conda create -n pytorch python=3.7
conda activate pytorch

Then look at which packages are used:

conda activate pytorch

Next, install pytorch.

Log in to the official website, https://pytorch.org/ , configuration interface:

Here you need to check the model of your gpu, you can see it through the task manager:

 Enter this code to see the version number of the graphics card:

nvidia-smi

The following command will be generated:

conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia

If you want to use back to the original source:

conda config --remove-key channels

I have to say that it is quite troublesome to install cuda, and report an error. Forget it, use the cpu version first, and use the cuda version if you are skilled:

conda install pytorch torchvision torchaudio cpuonly -c pytorch

View the installation package:

pip list

If the installation package is slow, there is another way, which is to put it directly in pkg. I installed it on the D drive:

D:\Program Files\Anaconda3\pkgs

Still downloading the gpu package, when there is no gpu, the test code will be false:

(pytorch) C:***>python
Python 3.9.16 (main, Jan 11 2023, 16:16:36) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
False

For pycharn, there is a way to set the same environment as anaconda, using python under env/pytorch to maintain the consistency of the environment.

Here is also added to install the gpu version of pytorch, delete the version number, and let him download it!

conda install pytorch torchvision torchaudio -c pytorch -c nvidia

However, it is still unsuccessful, and I will try to study it later.

Then install jupyter notebook in the pytorch environment:

(pytorch) C:\Users\zz>conda install nb_conda

After installation, you can start jupyter notebook

jupyter notebook

Add a little bit about the environment of openai. After all, Wu Enda has also started a class. First, the entire openai package:

conda install openai

Guess you like

Origin blog.csdn.net/qq_22059611/article/details/129151665