How to conda install OpenCV along with PyTorch in a Miniconda?

Does anybody have any working recipes? My failed attempt is at Installation with OpenCV triggers install of torchvision 0.2.2 · Issue #4665 · pytorch/vision · GitHub

I need to have the shared OpenCV libraries / headers, so pip install opencv-python-headless doesn’t cut it.

Or maybe if using mamba is a solution, I would appreciate any mamba installation scripts as well. I have never used mamba before for now…

I think I found one way: installing torchvision from pip instead of conda:


mkdir -p $PREFIX

curl -L -so $PREFIX/ && chmod +x $PREFIX/ && $PREFIX/ -b -p $PREFIX/miniconda && rm $PREFIX/

export PATH=$PREFIX/miniconda/bin:$PATH

conda install -y opencv pytorch cudatoolkit=11.1 -c pytorch -c conda-forge

python -m pip install torchvision 



PATH="$PATH" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" bash --init-file <(echo "export TERM=xterm-256color; export MPLBACKEND=agg; export PS1='CONDA [\u@\h \W]\$ '")