Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting env.yml from Anaconda to Pip req.txt

I am having this env.yml which is generated from exporting the environment from Conda

channels:
  - pytorch
  - anaconda
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - _tflow_select=2.3.0=mkl
  - absl-py=0.8.1=py37_0
  - astor=0.8.0=py37_0
  - av=6.2.0=py37h866369f_1
  - blas=1.0=openblas
  - bzip2=1.0.8=h516909a_1
  - c-ares=1.15.0=h7b6447c_1001
  - ca-certificates=2019.10.16=0
  - certifi=2019.9.11=py37_0
  - cffi=1.13.2=py37h2e261b9_0
  - cudatoolkit=10.0.130=0
  - ffmpeg=4.1.3=h167e202_0
  - freetype=2.10.0=he983fc9_1
  - gast=0.2.2=py37_0
  - gmp=6.1.2=hf484d3e_1000
  - gnutls=3.6.5=hd3a4fd2_1002
  - google-pasta=0.1.8=py_0
  - grpcio=1.16.1=py37hf8bcb03_1
  - h5py=2.9.0=py37h7918eee_0
  - hdf5=1.10.4=hb1b8bf9_0
  - intel-openmp=2019.5=281
  - joblib=0.14.0=py_0
  - jpeg=9c=h14c3975_1001
  - keras=2.2.4=0
  - keras-applications=1.0.8=py_0
  - keras-base=2.2.4=py37_0
  - keras-preprocessing=1.1.0=py_1
  - lame=3.100=h14c3975_1001
  - libblas=3.8.0=14_openblas
  - libcblas=3.8.0=14_openblas
  - libedit=3.1.20181209=hc058e9b_0
  - mkl-service=2.3.0=py37he904b0f_0

I am then doing pip freeze to get the packages and writing this in req.txt

absl-py==0.8.1
astor==0.8.0
av==6.2.0
certifi==2019.9.11
cffi==1.13.2
gast==0.2.2
google-pasta==0.1.8
grpcio==1.16.1
h5py==2.9.0
joblib==0.14.0
Keras==2.2.4
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
Markdown==3.1.1
mkl-service==2.3.0
six==1.13.0
tensorboard==1.15.0
tensorflow==1.15.0
tensorflow-estimator==1.15.1
termcolor==1.1.0
torch==1.3.1
torchvision==0.4.2
webencodings==0.5.1
Werkzeug==0.16.0
wrapt==1.11.2

When I am using pip install -r req.txt it is breaking for few packages.

What is best way to achieve this?

tl;dr: Convert Conda environment to Pip Environment

like image 397
Abhik Sarkar Avatar asked Nov 26 '19 06:11

Abhik Sarkar


1 Answers

The error maybe due to mkl-service cannot be installed using pip It can be installed using conda : https://anaconda.org/anaconda/mkl-service

You can obtain Anaconda or Miniconda images in your Docker. To obtain a fully working Miniconda image:

docker search continuumio

Pull the desired image:

docker pull continuumio/miniconda

Create a container using the image:

docker run -t -i continuumio/miniconda /bin/bash

This gives you direct access to the container where the conda tool is already available.

Test the container:

conda info

You now have a fully working Conda image. Now you can create your environment using

conda env create -n my_env -f env.yaml
like image 106
srilekha palepu - Intel Avatar answered Sep 23 '22 00:09

srilekha palepu - Intel