Configuring python virtual environment on remote server through Anaconda under Mac os

1, SSH management software

Here I recommend a software I am using, termius. Termius is a very easy to use and beautiful SSH client, which can quickly control the server remotely and customize your favorite themes Termius not only covers Windows, Linux and OSX, but also supports Android and iOS (in the future, you can take out your mobile phone to troubleshoot online problems on the subway and bus at any time, which is really a blessing for programmers). Termius is also part of the student installation package provided by github, so you can use termius for free as long as you pass the student authentication on github.

2, Install anaconda

Anaconda refers to an open source Python distribution, which contains more than 180 scientific packages such as conda and Python and their dependencies. Anaconda can be installed in two ways:

1. On Anaconda's official website( https://www.anaconda.com/products/individual )Download the installation package and transfer it to the server

Generally speaking, installation packages are marked with a red line. For details, please ask the server administrator:

The downloaded file is named anaconda3-2020.11-linux-x86_ When the installation package of 64.sh is transferred to the server, SSH management software can be used. Termius has a special FTP transfer function, and mouse operation can be realized. I put the uploaded file in the root directory, so I execute it directly

sh Anaconda3-2020.11-Linux-x86_64.sh

The following code snippet appears:

Welcome to Anaconda3 2020.11

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> 

press ENTER directly and press ENTER repeatedly. After reading the license, the system will prompt you to approve the license terms. Do you accept the license terms? [yes|no]
Enter yes

Do you accept the license terms? [yes|no]
[no] >>> 
Please answer 'yes' or 'no':'
>>> yes

Anaconda3 will now be installed into this location:
/***

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/***] >>> 

Click ENTER to confirm the installation address. You can also ENTER a custom directory

After that, the following query will appear——

Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> 

Enter yes here to finish successfully

2. Directly download the anaconda installation package to the server by using the command line method for installation (temporarily empty)

III Anaconda verify installation

Verify the installation with the conda command, such as the list command

userName@serverName ~ $ conda list
bash: conda: Command not found...

Obviously not at this time. You can use source ~ / Bashrc or restart the terminal according to its prompt

userName@serverName ~ $ source ~/.bashrc
(base) userName@serverName ~ $ conda list
# packages in environment at /home/mazhuo/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py38_0  
_libgcc_mutex             0.1                        main  
alabaster                 0.7.12                     py_0  
anaconda                  2020.11                  py38_0  

Use the following commands to update them respectively

$ conda update conda
$ conda update anaconda

IV Creating python virtual environment with anaconda

The main commands are as follows:

conda update -n base conda        //update latest version of conda
conda create -n xxxx python=3.6   //Create Python 3.0 6 xxxx virtual environment
conda activate xxxx               //Open xxxx environment
conda deactivate                  //Turn off the environment
conda env list                    //Show all virtual environments

Start a series of installations in the virtual environment. The basic commands are:

conda install xxx

You can install the following packages in sequence through the above commands

pytorch
tensorflow
keras
ipykernel
cython
numpy
matplotlib
scipy
Pillow
opencv
pandas
seaborn
scikit-learn

I haven't covered cv in my actual programming, so I just installed pytorch, numpy, matchlib, scipy, pandas and scikit learn, which are important packages. Of course, they can also be installed through pip.

During installation, if the network connection is poor, you can add the domestic source of conda for installation. The specific commands are as follows:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

For deep learning experiments that do not involve cv, it is often necessary to use tensorboard. For specific installation tutorials, please refer to another blog post: Install TensorBoard under Pytorch

Key reference pages:

1. https://zhuanlan.zhihu.com/p/105025848

2. https://blog.csdn.net/ZhaoDongyu_AK47/article/details/104066482

3. https://www.cnblogs.com/xbit/p/9863493.html

 

Keywords: Python Anaconda neural networks Pytorch Deep Learning

Added by the_NEWBIE_ON_THE_BLOCK on Wed, 02 Feb 2022 02:31:04 +0200