Build a deep learning environment offline

Build a deep learning environment offline


Sometimes due to confidentiality and security requirements, we need to configure a deep learning environment on computers that cannot connect to the external network to carry out related work.

This article shares the relevant experience of configuring a deep learning environment on a computer that cannot be connected to the Internet

Hardware support: computers 转接计算机that can be connected to the external network ( ), computers that cannot be connected to the external network ( 目标计算机)

Anaconda3 offline installation

Download the installation package with the help of a networkable PC

In 转接计算机the download installation packages
official website to download
Tsinghua image
after the download sshtransfer to目标计算机

Install Anaconda3

Install Anaconda3 on 转接计算机and 目标计算机respectively

Open the directory where the Anaconda installation package is located and install the
installation command as

bash Anaconda-...-Linux-*,sh

Automatically configure conda environment selection yes
to activate the environment after installation

source ~/.bashrc

Configure the deep learning environment

Method: 转接计算机Configure the deep learning environment on the Internet, package and transfer to目标计算机

Get a deep learning environment

In the 转接计算机creation sandbox environments conda command, envirementfor the sandbox name

conda create -n envirement python=3.8 

Use pip, conda and other methods to install the required package, you can switch the domestic source to improve the download speed

Packaging a deep learning environment

After 转接计算机上entering the */anaconda3/envs/directory, package the environment to be copied

tar cvf envirement.tar envirement

It must be packaged when the environment is migrated, otherwise the link information in the environment will be destroyed! ! !

Copy the deep learning environment

Copy the envirement.tarfile from the directory 转接计算机to which it 目标计算机is copied via http, ssh, etc. */anaconda3/envs/, and unpack

This part 目标计算机is carried out on* : path of envirement.tar

rsync -rzP */envirement.tar ~/anaconda3/envs/
cd ~/anaconda3/envs
tar xvf envirement.tar

Add a deep learning environment to the environment list

Finally, 目标计算机modify the conda environment configuration file ~/.conda/envirement.txtand add the copied environment directory at the end
vim ~/.conda/envirement.txt

/root/anaconda3
/root/anaconda3/envs/envirement

This 离线搭建深度学习环境task is completed,

  • Use to conda env listcheck whether the environment is created successfully
  • After using the conda activate envirementactivation environment, you can test whether the specific package is installed successfully through the specific program

Note: No need to executeconda create -n [name] --clone [path] --offline

Guess you like

Origin blog.csdn.net/qq_38832757/article/details/107558118