$:conda create -n test python=3.6
建虚拟环境
$:source activate test
激活环境
$:which python
:/home/hhp/.conda/envs/test/bin/python
查看该环境中的python版本
$:/home/hhp/.conda/envs/test/bin/python
检验是否有torch,此处应该没有
$:conda install pytorch=0.2.0 cuda80 -c pytorch
安装
$:pip install torchvision==0.2.0
安装
$:/home/hhp/.conda/envs/test/bin/python
检验安装的东西和版本
$:conda list
查看安装列表
删除环境:
使用命令conda remove -n your_env_name(虚拟环境名称) --all 即可。
有时需要将某个环境复制到另一个新环境中,则
先在源环境导出所有的依赖:
$ pip freeze > requirements.txt
然后在另一个目标新环境(或虚拟环境)中恢复:
$ pip install -r requirements.txt
zai cuda=10.0的环境下安装torchvision,会出现ImportError: cannot import name 'PILLOW_VERSION'问题,原因是pillow版本过高,手动降低版本即可,pip install Pillow==6.2.2 --user
spams安装:
按上述方式装好其他环境之后,再根据spams之git(https://github.com/conda-forge/python-spams-feedstock)安装spams会出现numpy版本问题,采用简单版本 ‘’pip install --index-url https://test.pypi.org/simple/ spams‘’安装即可,采自官网http://spams-devel.gforge.inria.fr/downloads.html
anaconda增加信道或删除信道(为了获取免费镜像资源)时,下载安装包可能会出现其他已经安装软件的更新问题,此时不能更新,因为可能会出现版本不匹配问题,此时应该删除该信道:
conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
增加信道的方式如下:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
spams的官方安装就需要增加其他信道,安装后悔同时更新numpy等,但与本人的numpy版本不兼容,因此使用了上述简化版本的numpy安装。
某些信道变更细节可参考:
https://blog.youkuaiyun.com/mtj66/article/details/57074986