In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about how to build an anaconda+pycharm+pytorch environment, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
This article will describe in detail how to build the experimental environment needed for deep learning.
The framework is divided into six modules
Video card
Simply understand that this is what we often call GPU. The function of the graphics card is a component that specializes in matrix operation, which is used for display operation. Now most of the operations in the neural network are matrix operations, so of course we can apply the matrix operation function of the graphics card to improve the computing speed.
Drive
Usually refers to NVIDIA Driver, in fact, it is a driver software, and the front graphics card is the hardware
Cuda
Cuda is an extension package that makes it easy and elegant to use GPU for general computing. It is essentially a set of instructions through which we use the matrix operation of the graphics card.
Q: how do I check the highest version of cuda supported by my graphics card?
Anaconda1. Download and install
Download the official website: https://www.anaconda.com/
Select the installation package corresponding to the number of bits of the system to download.
Anaconda takes up a lot of space, so it is recommended to choose a free disk for Anaconda.
Check add environment variable
two。 Install pytorch virtual environment to create a virtual environment: conda create-n torch (virtual environment name) python = 3.7
If the following occurs in this step:
Solution:
Enter the following command before creating a new virtual environment.
Conda config-add channels conda-forgeconda config-set channel_priority strictconda config-set channel_priority flexible
What is stored in this path is the virtual environment we have created, and under the torch folder are some of the packages we installed in the environment, and so on.
Activate and enter the environment: conda activate torch
We are in the "lobby" location (base) before activating the environment, and after activating the torch environment, we can see that we have entered the torch environment we just built (torch).
Check which toolkits are installed in this environment: conda list
Download pytorch:conda activate torch
Download the official website: https://pytorch.org/
Go to the pytorch official website and select some options, and the corresponding lines of code will be generated on the last line, and then copied to the terminal window for execution.
The command line means to download the first four toolkits from pytorch.
Q: how to solve the problem of slow download speed?
As the servers of these websites are all abroad, our download speed will be very slow. In order to solve this problem, some domestic bigwigs have made mirror websites, which will be specially updated for a period of time. So the download speed of switching to mirror websites will be greatly improved.
Tsinghua Source: conda config-- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config-- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forgeconda config-- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/conda config-- set show_channel_urls true Zhongke Dayuan: conda config-- add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/ Main/conda config-add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/conda config-add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/conda config-add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/conda config-add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/conda config-add channels https://mirrors.ustc.edu.cn/anaconda/ Cloud/menpo/conda config-set show_channel_urls yes
Let's change to Tsinghua Source for this installation.
Check whether the source change is successful after the source change. Channels indicates the download channel, in which the URLs are all Tsinghua source URLs, indicating that the source change is successful.
Replace the original download instruction and remove the following-c pytorch, which means downloading from the current Tsinghua source.
Below, our pytorch virtual environment and some toolkits have been installed.
Exit the current virtual environment and return to the lobby: conda deactivate
See what virtual environments are available in the current anconda: conda info-e
Indicates that you are in the lobby at this time.
Write test code in pytorch environment
First enter the pytorch virtual environment
Enter the command line import torch, if the following flag appears, it means that pytorch has been installed.
3. Conda common instructions
Create a virtual environment
Conda create-n torch [virtual environment name] python = 3.7
Activate and enter the environment
Conda activate torch
Check which toolkits are installed in this environment
Conda list
Exit the current virtual environment and return to the lobby
Conda deactivate
Check what virtual environments are available in the current anconda
Conda info-e
Delete all content in the environment and destroy the environment
(base) conda remove-n torch-- allpycahrm / jupyter download and install
Download the community version of pycharm and change the installation path to a free disk. There is nothing to pay special attention to, just go straight to the next step.
How to build the interpreter of the virtual environment to find out and assign to the code?
We can create multiple virtual environments, such as tensorflow,pytorch, etc., and switch to different virtual environments through the following settings when using different frameworks. Some people will install all the frameworks into a virtual environment, of course, it is possible in theory, but it is not convenient to manage, and different versions of the same tool are not allowed to be installed in the same virtual environment, which is not conducive to our follow-up study.
The specific operations are as follows:
Run the following code test in pycharm. If the following results appear, the environment has been built.
If the second line below shows false, it is possible that the computer graphics card does not support cuda, just delete the virtual environment and download the cpu version of pytorch again.
Import torchprint (torch.__version__) print (torch.cuda.is_available ()) x = torch.randn (1) if torch.cuda.is_available (): device= torch.device ("cuda") y = torch.ones_like (x, device=device) x = x.to (device) z = x + y print (z) print (z.to ("cpu", torch.double)) above is how to build an anaconda+pycharm+pytorch environment The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.