AI Learning Notes 1: Software and Environment Construction

If the article is an original article, please indicate the source of the original article when reprinting it.

If a worker wants to do his job well, he must first sharpen his tools.

1. Environmental description

1. win10, no CPU.

2. Cloud server AutoDL

3. Installed software: pyCharm (less used, so not installed)

4. Environment: miniconda

2. miniconda installation

1. Download address

https://docs.conda.io/en/latest/miniconda.html

What is installed is py3.8. Other parameters are selected according to the computer. My computer is win10 64-bit. I downloaded the following software.

imgedit

Install directly after downloading. After installation, you can find miniconda3 in the menu interface.

imgedit

2. Conda replacement source

Open the miniconda3 terminal. Windows users cannot directly create a file named .condarc. They can first execute conda config --set show_channel_urls yes to generate the file and then modify it.

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

3. pip replacement source

  • Create a new pip folder in C:\Users\your username directory

  • Create pip.ini in the new pip directory (create a new txt and change the suffix to ini)

  • Open with notepad for writing

[global]
timeout = 6000
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

3. Pytorch installation

Directly follow the commands given on the official website to download:

Official website address:

Start Locally | PyTorch

Select the corresponding version parameters, and the official website will automatically give the latest installation command.

pip install torch torchvision torchaudio

4. Conda usage and operation

1) Check which packages are installed

conda list

2) Check which virtual environments currently exist

conda env list 
conda info -e

3) Check to update the current conda

conda update conda

3.Python creates a virtual environment

conda create -n your_env_name python=x.x

The anaconda command creates a virtual environment with python version xx and name your_env_name. Your_env_name file can be found under the envs file in the Anaconda installation directory.

4. Activate or switch virtual environments

Open the command line and enter python --version to check the current python version.

Linux:  source activate your_env_nam
Windows: activate your_env_name

5. Install additional packages on the virtual environment

conda install -n your_env_name [package]

6. Close the virtual environment (i.e. exit from the current environment and return to using the default python version in the PATH environment)

deactivate env_name

Or activate rootswitch back to the root environment

Linux下:source deactivate 

7. Delete the virtual environment

conda remove -n your_env_name --all

8. Delete a package in the environment

conda remove --name $your_env_name  $package_name 

 The environment is basically like this. All subsequent projects will create corresponding virtual environments separately. If you are used to Windows, it is recommended to install pycharm. For Linux, just use the terminal!

If there is any infringement or you need the complete code, please contact the blogger in time.

Guess you like

Origin blog.csdn.net/weixin_38807927/article/details/131905441