Deep learning 실험 시 모델에 맞게 새로운 가상환경을 항상 만드는 편이다.
사용 가능한 서버가 여러 개 있을 경우 매번 가상환경을 만드는 일은 상당히 번거로운 작업이다.
이 때, 현재 가상환경에 설치된 파일과 환경 이름 등 anaconda 환경을 그대로 옮길 수 있는 방법은 다음과 같다.
먼저 옮길 가상환경 실행 후,
conda env export --no-builds | grep -v “prefix” > environment.yml
실행하면 environment.yaml에 다음과 같이 저장된다.
name: gan
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1
- blas=1.0
- ca-certificates=2021.1.19
- certifi=2020.12.5
- cudatoolkit=11.0.221
- intel-openmp=2020.2
- ld_impl_linux-64=2.33.1
- libffi=3.3
- libgcc-ng=9.1.0
- libgfortran-ng=7.3.0
- libstdcxx-ng=9.1.0
- mkl=2020.2
- mkl-service=2.3.0
- mkl_fft=1.3.0
- mkl_random=1.1.1
- ncurses=6.2
- numpy=1.19.2
- numpy-base=1.19.2
- openssl=1.1.1k
- pip=21.0.1
- python=3.7.10
- readline=8.1
- setuptools=52.0.0
- six=1.15.0
- sqlite=3.35.3
- tk=8.6.10
- wheel=0.36.2
- xz=5.2.5
- zlib=1.2.11
- pip:
- absl-py==0.12.0
- argon2-cffi==20.1.0
- astor==0.8.1
- astunparse==1.6.3
- async-generator==1.10
- attrs==20.3.0
- backcall==0.2.0
- bleach==3.3.0
- cachetools==4.2.1
- cffi==1.14.5
- chardet==4.0.0
- cloudpickle==1.6.0
- contrib==0.3.0
- coverage==5.5
- cycler==0.10.0
- decorator==4.4.2
- defusedxml==0.7.1
- dm-tree==0.1.6
- entrypoints==0.3
- flatbuffers==1.12
- future==0.18.2
- gast==0.3.3
- google-auth==1.28.1
- google-auth-oauthlib==0.4.4
- google-pasta==0.2.0
- grpcio==1.32.0
- h5py==2.10.0
- idna==2.10
- imageio==2.9.0
- importlib-metadata==3.10.1
- iniconfig==1.1.1
- ipykernel==5.5.3
- ipython==7.22.0
- ipython-genutils==0.2.0
- ipywidgets==7.6.3
- jedi==0.18.0
- jinja2==2.11.3
- joblib==1.0.1
- jsonschema==3.2.0
- jupyter==1.0.0
- jupyter-client==6.1.12
- jupyter-console==6.4.0
- jupyter-core==4.7.1
- jupyterlab-pygments==0.1.2
- jupyterlab-widgets==1.0.0
- keras-applications==1.0.8
- keras-preprocessing==1.1.2
- kiwisolver==1.3.1
- lmdb==1.2.1
- markdown==3.3.4
- markupsafe==1.1.1
- matplotlib==3.4.1
- mistune==0.8.4
- nbclient==0.5.3
- nbconvert==6.0.7
- nbformat==5.1.3
- nest-asyncio==1.5.1
- networkx==2.5.1
- notebook==6.3.0
- oauthlib==3.1.0
- opt-einsum==3.3.0
- packaging==20.9
- pandas==1.2.4
- pandocfilters==1.4.3
- parso==0.8.2
- pexpect==4.8.0
- pickleshare==0.7.5
- pillow==8.2.0
- pluggy==0.13.1
- prometheus-client==0.10.1
- prompt-toolkit==3.0.18
- protobuf==3.15.8
- psutil==5.8.0
- ptyprocess==0.7.0
- py==1.10.0
- pyasn1==0.4.8
- pyasn1-modules==0.2.8
- pycparser==2.20
- pygments==2.8.1
- pyparsing==2.4.7
- pyrsistent==0.17.3
- pytest==6.2.3
- pytest-cov==2.11.1
- python-dateutil==2.8.1
- pytorch-fid==0.2.0
- pytz==2021.1
- pywavelets==1.1.1
- pyyaml==5.4.1
- pyzmq==22.0.3
- qtconsole==5.0.3
- qtpy==1.9.0
- requests==2.25.1
- requests-oauthlib==1.3.0
- rsa==4.7.2
- scikit-image==0.18.1
- scikit-learn==0.24.1
- scipy==1.1.0
- send2trash==1.5.0
- sklearn==0.0
- tensorboard==2.5.0
- tensorboard-data-server==0.6.0
- tensorboard-plugin-wit==1.8.0
- tensorflow==2.4.1
- tensorflow-estimator==2.4.0
- tensorflow-gan==2.0.0
- tensorflow-gpu==1.14.0
- tensorflow-hub==0.11.0
- tensorflow-probability==0.12.1
- termcolor==1.1.0
- terminado==0.9.4
- testpath==0.4.4
- threadpoolctl==2.1.0
- tifffile==2021.3.31
- toml==0.10.2
- torch==1.7.1+cu110
- torch-mimicry==0.1.16
- torchaudio==0.7.2
- torchvision==0.8.2+cu110
- tornado==6.1
- tqdm==4.59.0
- traitlets==5.0.5
- typing-extensions==3.7.4.3
- urllib3==1.26.4
- wcwidth==0.2.5
- webencodings==0.5.1
- werkzeug==1.0.1
- widgetsnbextension==3.5.1
- wrapt==1.12.1
- yapf==0.31.0
- zipp==3.4.1
prefix: /home/zekim/anaconda3/envs/gan
environment.yaml 파일을 환경을 옮길 서버에 접속해 올려주고
conda env create --file environment.yml
코드를 실행시켜주면 environment.yaml에 지정되어있는 name의 이름으로 가상환경이 생성되며 기존 설치된 패키지도 모두 동일한 버전으로 설치된다!!!