创建虚拟环境
使用conda -V查看版本
root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda -V
conda 4.10.3
使用conda env list查看虚拟环境列表
root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda env list
# conda environments:
#
base * /root/miniconda3
使用conda create -n 环境名 python=x.x创建虚拟环境
root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda create -n wasser python=3.10
# To activate this environment, use
#
# $ conda activate wasser
#
# To deactivate an active environment, use
#
# $ conda deactivate
激活虚拟环境:遇到问题
输入conda activate 环境名 遇到报错:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
解决方法:先输入source activate,再进行激活环境:conda activate+环境名
root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# source activate
(base) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# conda activate wasser
(wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# torch
bash: torch: command not found
(wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04#
配置虚拟环境
查看cuda版本:nvcc --version或者nvidia-smi
(wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0
去pytorch官网找到对应的torch版本,进行下载
wasser) root@autodl-container-6fc3118c10-305d0fb9:~/autodl-tmp/data/swinIR_06/swinIR_04# pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113