In the last passage, we successfully download and install anaconda and pytorch. However, the one of the most important advantages to use conda instead of pip is its virtual enviroment, where you will have a clean enviroment isolated environment to focus on your experiment or development.
Generally, we often use python version 3.6 (Of course, you can use one version you are familar with). Then I wil show how to create Conda Environment, and activate environment in docker.
Create conda environment
conda create -n python3.6 python=3.6
Also, you can create both a python version2.7 and a python version3.6.
other useful conda commands
- 列出所有的环境和当前环境(*)
bash conda info --envs
- 克隆环境从snowflakes到flowers
conda create --name flowers --clone snowflakes
- 删除环境flowers
conda remove --name flowers --all
Enter docker
docker container ls
推荐使用docker exec
,因为docker exec
从终端退出的时候不会关闭终端,而docker attach
会
docker exec -it $docker_id bash
Source and activate your env in docker
source miniconda3/bin/activate
conda activate python3.6
export CUDA_VISIBLE_DEVICES=0,1
Finally you can run your python script or conduct your exp anyway.
来源:CSDN
作者:傻白兔
链接:https://blog.csdn.net/fairyloycine/article/details/103546200