This message was deleted.
# ask-for-help
s
This message was deleted.
g
Copy code
use_conda = not self.conda.is_empty()
        use_cuda = self.docker.cuda_version is not None

        if use_cuda and use_conda:
            raise BentoMLException(
                "BentoML does not support using both conda dependencies and setting a CUDA version for GPU. If you need both conda and CUDA, use a custom base image or create a dockerfile_template, see <https://docs.bentoml.org/en/latest/concepts/bento.html#custom-base-image-advanced>"
            )
Looks like either cuda version or conda config needs to be empty? However need both..
a
Hi Greg, is there a reason for you to use conda? Is there a package that pip won’t be able to install?
g
@Aaron Pham yes, there are some packages that are not pip installable.
a
Got it. I will make a PR for this to be a warning instead of an exception.
g
Great, thanks! For now, is it safe to simply bypass that warning?
a
yes. If you are using the example templates from our advanced guides it should be sufficient.
I think for this case, we might want to support conda and cuda altogether
g
Ok great, thanks @Aaron Pham. Will give it a try!
Yeah, that would be amazing.
a
For now, I will make a PR that bypass that warning
❤️ 1
then afterwards a diff PR as an enhancement
g
While I have you qq: non-ideal, but is it safe to use both the
python
and
conda
sections together?
a
it is
g
If I want some things install via
pip
and others via
conda
Great
Cheers!
a
Hmm, it seems like it is a bit more than just passing the warning. Because when you use conda field under bentofile.yaml, we will also install those dependencies specified under conda.
nonetheless I will propose a PR to handle this.
g
My current plan: • use my existing Bento (uses pip to install) • use custom dockerfile template to add
conda
•
conda install
the single dependency that
pip
doesn't allow for in
setup.sh
👍 1
a
Hi greg, you can use this template as follows
Copy code
{% import '_macros.j2' as common %}
{% extends bento_base_template %}
{# Make sure to change the correct python_version and conda version accordingly. #}
{# example: py38_4.10.3 #}
{# refers to <https://repo.anaconda.com/miniconda/> for miniconda3 base #}
{% set conda_version="py39_4.11.0" %}
{% set conda_path="/opt/conda" %}
{% set conda_exec=[conda_path, "bin", "conda"] | join("/") %}
{% block SETUP_BENTO_BASE_IMAGE %}
FROM debian:bullseye-slim as conda-build

RUN --mount=type=cache,from=cached,sharing=shared,target=/var/cache/apt \
	--mount=type=cache,from=cached,sharing=shared,target=/var/lib/apt \
	apt-get update -y && \
	apt-get install -y --no-install-recommends --allow-remove-essential \
	software-properties-common \
	bzip2 \
	ca-certificates \
	git \
	libglib2.0-0 \
	libsm6 \
	libxext6 \
	libxrender1 \
	mercurial \
	openssh-client \
	procps \
	subversion \
	wget && \
	apt-get clean

ENV PATH {{ conda_path }}/bin:$PATH

SHELL [ "/bin/bash", "-eo", "pipefail", "-c" ]

ARG CONDA_VERSION={{ conda_version }}

RUN set -ex && \
	UNAME_M=$(uname -m) && \
	if [ "${UNAME_M}" = "x86_64" ]; then \
	MINICONDA_URL="<https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh>"; \
	SHA256SUM="4ee9c3aa53329cd7a63b49877c0babb49b19b7e5af29807b793a76bdb1d362b4"; \
	elif [ "${UNAME_M}" = "s390x" ]; then \
	MINICONDA_URL="<https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-s390x.sh>"; \
	SHA256SUM="e5e5e89cdcef9332fe632cd25d318cf71f681eef029a24495c713b18e66a8018"; \
	elif [ "${UNAME_M}" = "aarch64" ]; then \
	MINICONDA_URL="<https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-aarch64.sh>"; \
	SHA256SUM="00c7127a8a8d3f4b9c2ab3391c661239d5b9a88eafe895fd0f3f2a8d9c0f4556"; \
	elif [ "${UNAME_M}" = "ppc64le" ]; then \
	MINICONDA_URL="<https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-ppc64le.sh>"; \
	SHA256SUM="8ee1f8d17ef7c8cb08a85f7d858b1cb55866c06fcf7545b98c3b82e4d0277e66"; \
	fi && \
	wget "${MINICONDA_URL}" -O miniconda.sh -q && echo "${SHA256SUM} miniconda.sh" > shasum && \
	if [ "${CONDA_VERSION}" != "latest" ]; then \
	sha256sum --check --status shasum; \
	fi && \
	mkdir -p /opt && \
	sh miniconda.sh -b -p {{ conda_path }} && rm miniconda.sh shasum && \
	find {{ conda_path }}/ -follow -type f -name '*.a' -delete && \
	find {{ conda_path }}/ -follow -type f -name '*.js.map' -delete && \
	{{ conda_exec }} clean -afy

{{ super() }}

ENV PATH {{ conda_path }}/bin:$PATH

COPY --from=conda-build {{ conda_path }} {{ conda_path }}

RUN set -ex && \
	ln -s {{ conda_path }}/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
	echo ". {{ conda_path }}/etc/profile.d/conda.sh" >> ~/.bashrc && \
	echo "{{ conda_exec }} activate base" >> ~/.bashrc

{% endblock %}
{% block SETUP_BENTO_ENVARS %}

SHELL [ "/bin/bash", "-eo", "pipefail", "-c" ]
{{ super() }}
{{ common.setup_conda(__python_version__, bento__path, conda_path=conda_path) }}
{% endblock %}
Then you can specify this templates as
Copy code
docker:
  dockerfile_template: ./Dockerfile.template
your plan also works as well