Configure the deep learning environment on the ubuntu virtual machine

The study notes are mainly to record the current operations you are doing so that you can review them yourself. If you have any guidance, you are welcome to exchange ideas.

1. Install miniconda

Install miniconda under Linux_linux install miniconda - Programmer Sought

#第一步下载miniconda安装包 
#安装包连接https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/,查找相应安装包
wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh
#第二步安装
bash Miniconda3-py39_4.9.2-Linux-x86_64.sh
#第三部配置conda镜像
source ~/.bashrc
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-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
conda config --set show_channel_urls yes
#第四步创建一个名称为python38的环境,python版本等于3.8
conda create -n python38 python=3.8
#第五步 激活环境
source activate python38

#第六步之后的步骤不是这次安装所需要的,暂时可以先不执行
#第六步 在环境激活的情况下安装numpy
conda install numpy

#常用命令
#查看已有环境
conda info --env
#查看已有安装包
conda list
#退出环境
conda deactivate
#删除某个环境
conda remove -n 环境名 --all
#删除某个环境下的某个包
conda remove -n 环境名 包名

   After restarting, if (base) appears in front of the command line, the installation can be considered successful

2. Create the environment and activate the environment

[Li Mu-Deep Learning] Linux Environment Configuration + Frequently Asked Questions_Li Mu d2l-zh_Sherry me's Blog-CSDN Blog

# 1 删除已经存在的环境
# 如果不存在d2l,会报错
# 这步可以跳过
conda-env remove d2l

# 2 下载环境
# 这里的d2l-zh是自定义的
conda create -n d2l -y python=3.8 pip

# 3 使环境生效
conda activate d2l


# 给他们放在一起好了,这里的d2l-zh只是环境的名字,我取的是d2l而已
conda env remove d2l-zh
conda create -n d2l-zh -y python=3.8 pip
conda activate d2l-zh

find(base) becomes ( d2l -zh)

3. Install the required packages

Hands-on deep learning installation environment configuration - Tencent Cloud Developer Community - Tencent Cloud (tencent.com)

Because jupyter is needed, install one first

# 一口气安装
# 等待时间长
pip install jupyter d2l torch torchvision

# 如果一口气安装有报错,不妨一个一个安装,看看问题出在哪里
# 一个一个安装
pip install jupyter

# 后面这三个用镜像网站下载更快
# pip install d2l
# pip install torch
# pip install torchvision

# 在我的记忆里,anacoda好像包括jupter和ipython

The packages required for installation are mainly d2l, torch, torchvision.

It is more recommended to use Douban source and Alibaba Cloud mirror source:

pip install -i https://pypi.douban.com/simple/ d2l
pip install torch torchvision -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

The package downloaded and installed by the second line command is 619M, and it took about 20 minutes to install (it seems to have failed)

Put the wrong information on Baidu search results:

Solution: pip install ERROR: Exception: Traceback (most recent call last):_sucr.'s blog - CSDN blog

So it's because I opened an agent? I don't know how to look at it. It seems that because the virtual machine I use uses the NAT mode, it is considered to be a proxy.

Introduction to NAT and bridge mode:

Application analysis of NAT network mode in virtual machine vmware (full text) (wenmi.com) https://www.wenmi.com/article/pvif7n02efjc.html  NAT mode and bridge mode:

How to let the VmWare virtual machine go online- China_King - Blog Garden (cnblogs.com) https://www.cnblogs.com/lhpking/p/15067768.html The default is NAT mode before, so should I change it to bridge mode? (no change)

I stopped at this step, and I will look for a solution first. If there are big brothers who see it, can I ask you big brothers to give pointers.


The guess is that it is caused by the inability to recognize the network, and the solutions are as follows:

VMnet1 and VMnet8 unrecognized network solution - jackphang's blog - CSDN blog

Virtual machine installation: Detailed explanation of VMware Network Adapter VMnet1 and VMnet8 unrecognized network solutions_vmnet8 is identifying


4. Officially run jupyter notebook

Officially run the Jupyter notebook and open the link that pops up in the command line. Generally http://localhost:8888/tree .

jupyter notebook

You may encounter the problem that the image source fails, so here are some common commands about the image source. For information on how to find a suitable source, you can refer to " CSDN blogger "Yu Yu Yu Yu": Conda replaces the mirror source method at the end, no longer need to search for the mirror source address everywhere "

conda info
# 你可以在channel URLs里面找到你现有的所有镜像源。
# 添加指定源
conda config --add channels *(*指代你要添加的源)
# 设置安装包时,显示镜像来源,建议显示
conda config --set show_channel_urls yes 
# 删除指定源
conda config --remove channels *(*代表你要删除的源)
# 可以删除并恢复默认的conda源
conda config --remove-key channels
# 临时使用的时候,加上参数-i和镜像地址
pip install -i https://pypi.douban.com/simple tensorflow-gpu==1.14

5. When re-entering

# 1 使环境生效
conda activate d2l

# 2 开启jupyter notebook
jupyter notebook

# 3 打开浏览器:访问<http://remoteaddr:8888/>即可

Guess you like

Origin blog.csdn.net/qq_46703208/article/details/129667425