Offline GPU server configuration virtual environment

Install Anaconda for linux server

It stands to reason that miniconda should be installed for the following reasons

anaconda is a version that contains commonly used packages, miniconda is a simplified version, miniconda is recommended. Anaconda also packs 1,500 commonly used software packages, which can be installed in your python environment at one time, so that you don’t have to install software packages one by one, which is very friendly to novices. Miniconda is a minimal python+conda installation program, Only the most necessary packages are included. ——In addition, in some occasions that need to be deployed, it is unrealistic to install several G of Anaconda, and many libraries are not available. At this time, using Miniconda is a more appropriate choice.

But my school's server can't install miniconda (  Miniconda3-3.6.0-Linux-x86.sh ), so I have to install anaconda with a larger size

Environment installation package download address: https://repo.anaconda.com/miniconda/

Download this file to the local Anaconda3-4.4.0-Linux-x86_64.sh

Then upload this file to the school server. (Because my school's server cannot be connected to the Internet, only a few websites, such as GitHub, can be connected to the Internet. The anaconda official website and pip install are not allowed to be connected to the Internet)

Then use the following command to install anaconda

bash Miniconda3-latest-Linux-x86_64.sh

Configure environment variables

1. Open the environment variable file
vim ~/.bashrc
# https://www.shuzhiduo.com/A/QW5YjnQNdm/

2. Add at the end:

 export PATH=你的anaconda3/bin文件夹的完整路径:$PATH

3. Restart environment variables:

source ~/.bashrc

Test the following commands, there are returns indicating that conda is installed

conda env list
conda --help

Package the existing environment into a file and save it locally. Then upload this file to the virtual environment and install

Switch to the environment that looks like the environment you want to make

conda activate py361tc100

Installation environment packaging tool (https://blog.csdn.net/Frost216/article/details/125594000)

conda install -c conda-forge conda-pack

After installation, package the environment that needs to be moved out (the name of the virtual environment after -n is the name of the packaged file after -o)

conda pack -n py361tc100 -o py361tc100.tar.gz

 

 

 

Then upload this compressed package "py361tc100.tar.gz" to the server. It doesn't matter where it is placed. Remember to put your command line cd to the location of this compressed package

Then unzip. Remember to decompress to the virtual environment (you create a new folder in ./anaconda/envs, the name of the folder is the name of the virtual environment you want to create. When you decompress the compressed package, you must also put the compressed package inside stuff unpacked to ./anaconda/envs/py361tc100)

I wrote this and it worked. You can find it by checking the environment list, and the location is also correct.

At this point, you activate the environment

conda activate py361tc100

The following error will appear

 

At this time, you only need to run the commands one by one according to the prompts, and you can add some things to the environment configuration file, so that you can use it when you activate

echo ". /_wanghaoyu/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
sudo ln -s /_wanghaoyu/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
echo "conda activate" >> ~/.bashrc

Remember to restart your terminal, and then activate, you will find that you can enter the virtual environment

 

 

Guess you like

Origin blog.csdn.net/Albert233333/article/details/129890911