Conda创建虚拟环境
-
创建虚拟环境:
conda create -n lmz python==3.7.4
-
删除虚拟环境
conda env remove --name lmz
-
列出所有虚拟环境
conda env list conda info -e
-
查看安装的包
conda list
-
关闭虚拟环境
deactivate lmz
-
检验是否安装及当前conda的版本
conda -V
-
检查更新conda
conda update conda
-
进入虚拟环境后使用如下指令可以只在当前环境中安装删除包
conda install pkg_name conda uninstall pkg_name pip install pkg_name pip uninstall pkg_name
-
使用国内源加速
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 –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config –set show_channel_urls yes
-
安装第三方依赖包
cd E:\python #例如 pip install -r requirements.txt
-
导出requirements.txt
conda list -e > requirements.txt
-
在jupyter中添加内核
-
安装ipykernel
pip install ipykernel
-
添加虚拟环境kernel
python -m ipykernel install --user --name envname
-
查看当前可用的虚拟环境内核
jupyter kernelspec list
-
删除内核
jupyter kernelspec remove envname
-
深度学习环境搭建(Pytorch)
-
注意版本匹配问题:python,pytorch,cuda版本;python与numpy版本
-
下载pytorch相关的库
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge conda install pyg -c pyg -c conda-forge
-
官方链接
-
查看pytorch版本
先进入python交互界面
import torch print(torch.__version__) #查看pytorch版本 print(torch.cuda.is_available()) #查看cuda是否可用 输出为True 或者False