Environment Configuration chapter
Installation cuda
Nvidia driver update
Open the GeForce Game Ready Driver or GeForce Experience download gpu in line with their own programs.
Select cuda
-
Open the nvidia control panel
Click Help, click System Information, click the component can be seen in cuda information in 3D settings
After I upgraded nvidia driver, cuda updated to version 10.1. Next download CUDA.
Cuda10.1 installed.
Installation cuDNN
After selecting a corresponding installation cuda10.1 cuDNN version v7.6.1
Unzip the file, and then add the bin directory to environment variable
Installation cuDNN
After selecting a corresponding installation cuda10.1 cuDNN version v7.6.1
Unzip the file, and then add the bin directory to environment variable
Anaconda prompt to create environments
conda create -n pytorch_gpu pip python=3.7
Pytorch_gpu which is the name of the environment, python version 3.7
conda activate pytorch_gpu
This command can be entered to create a good environment.
Installation Pytorch
Recommended that you switch the source, I use the Chinese University of Science and Technology "( USTC Open Source Software Mirror ) provide anaconda mirroring source, a lot of speed.
method one:
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
Method Two:
.Condarc open the file for editing
The existence of a priority order, will first look in the mirror source at the University of Science and Technology of China, if you feel slow, you can also change other image source.
Open official website and select the Copy command
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
The whole process simply click on the 'y' can be.
verification
In order to ensure PyTorch whether the installation is successful, we need to run the sample code simple tests, such as printing out a randomly generated tensor matrix, and whether gpu can be used.
import torch x = torch.rand(5,5) print(x)
Output similar to the following
tensor([[0.7078, 0.1424, 0.3411, 0.3987, 0.3476], [0.7534, 0.7137, 0.3489, 0.4226, 0.3640], [0.4104, 0.8411, 0.5112, 0.0629, 0.0664], [0.7568, 0.9495, 0.3300, 0.2392, 0.6441], [0.7615, 0.1883, 0.6001, 0.9663, 0.3313]])
If ok, pytorch successful installation.
torch.cuda.is_available()
Returns True, GPU version Pytorch installed.
The PyTorch import Pycharm
Click the File Pycharm options bar select Settings, and then click Project Interpreter, and then click Add on the right side.
Then select Existing environment in Conda Environment in
python.exe in the selected Anaconda3, Conda executable select conda.exe
If it fails, the virtual environment created under the new selection under Anaconda3 select the env python, give it a try.
Pycharm open scientific computing model (Scientific Mode)
Specific steps:
- Settings –> Tools –> Python Scientific > Show plots in tool window 勾选
- View Scientific Mode check
- Run–>Edit configurations…
- Check Run with python console
Open scientific computing model, comfortable, getting used to this position.
ps: If you want to revert to the normal mode, just in view, scientific mode canceled check.
Conclusion
Environment installed, then start my path of exploration, encourage each other!