1. 首先建立新环境 conda create -n ReID python=3.8
移植环境 :conda create -n BBB --clone 原名
进入环境:source activate ReID
退出环境:conda deactivate
问题1:
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,再激活环境。(可以看到前面没有base)
2. 安装pytorch等
进入官网https://pytorch.org/get-started/locally/,按照要求选择后直接复制命令
比如
Ubuntu :pip3 install torch torchvision torchaudio
Windows:pip3 install torch1.8.1+cu102 torchvision0.9.1+cu102 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
Pip的命令后面都可以加上加速指令
安装CV2
pip install opencv-python -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
出现问题,版本太高,高出nVidia本身的驱动版本,nvidia-smi后右上角发现cuda10.1,而我下的是10.2,肯定不行
pip3 uninstall torch torchvision torchaudio后重新安装,https://pytorch.org/get-started/previous-versions/,寻找以前的版本
conda install pytorch1.7.1 torchvision0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch
依然出现问题,包太大,下载起来太慢
后采用pip,用加速链接
pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
3. 安装完相关包之后退出环境
测试命令:
进入python
import torch
print(torch.version)
torch.cuda.is_available()
实验记录:
除了配置环境之外,其他改的地方有:数据集路径,预训练的模型
疑问:
之前配置的比较高的环境,在台式电脑anonaconda中创建,在spyder中运行,出现的问题:
- 路径指定错误,windows中copy的地址只需把斜杠反向就可以
- 多gpu参数模式在单GPU时遇到问题
- 内存过小,batchsize改小