-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc79bd9
commit fb4757e
Showing
1 changed file
with
29 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,58 @@ | ||
FROM debian:buster | ||
WORKDIR /ivy | ||
ARG CLI | ||
# python version for conda | ||
ARG pycon=3.10 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install miniconda | ||
ENV CONDA_DIR /opt/miniconda/ | ||
|
||
RUN apt clean && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
apt-get update && \ | ||
apt-get install -y wget \ | ||
git -y && \ | ||
# Install dependencies and Miniconda | ||
RUN apt-get update && \ | ||
apt-get install -y wget git && \ | ||
wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \ | ||
/bin/bash ~/miniconda.sh -b -p /opt/miniconda | ||
|
||
/bin/bash ~/miniconda.sh -b -p /opt/miniconda && \ | ||
rm ~/miniconda.sh | ||
|
||
ENV CONDA_DIR /opt/miniconda/ | ||
ENV PATH=$CONDA_DIR/bin:$PATH | ||
|
||
RUN conda create --name multienv python==$pycon | ||
|
||
# to fix protobuf conflicts | ||
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION python | ||
# Fix protobuf conflicts | ||
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python | ||
ENV PATH=/opt/miniconda/envs/multienv/bin:$PATH | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y python3-pip python3-tk && \ | ||
apt-get install -y libsm6 libxext6 libxrender-dev libgl1-mesa-glx && \ | ||
apt-get install -y python-opengl && \ | ||
apt-get install -y git && \ | ||
apt-get install -y rsync && \ | ||
apt-get install -y libusb-1.0-0 && \ | ||
apt-get install -y libglib2.0-0 && \ | ||
apt-get install -y jq && \ | ||
apt-get install -y python3-pip python3-tk libsm6 libxext6 libxrender-dev libgl1-mesa-glx python-opengl git rsync libusb-1.0-0 libglib2.0-0 jq && \ | ||
pip3 install --upgrade pip && \ | ||
pip3 install pip-autoremove &&\ | ||
pip3 install setuptools==58.5.3 | ||
|
||
pip3 install pip-autoremove setuptools==58.5.3 | ||
|
||
# Install Ivy Upstream | ||
# Clone Ivy repository and remove cache | ||
RUN git clone --progress --recurse-submodules https://github.com/ivy-llc/ivy --depth 1 && \ | ||
cd ivy && \ | ||
rm -rf compiler/_cache && \ | ||
cd ivy_tests/array_api_testing/test_array_api && \ | ||
pip3 install --no-cache-dir -r requirements.txt | ||
rm -rf ivy/compiler/_cache | ||
|
||
# Install Ivy dependencies | ||
WORKDIR /ivy/ivy_tests/array_api_testing/test_array_api | ||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
|
||
# Install local optional | ||
# Copy and install local optional requirements | ||
WORKDIR /ivy | ||
COPY requirements/optional.txt . | ||
COPY requirements/requirements.txt . | ||
|
||
# requirement mappings directs which dependency to be installed and where | ||
COPY /docker/requirement_mappings.json . | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
# installing requirements based on mappings in location /opt/fw/$framework | ||
RUN jq -r 'to_entries[] | select(.value != [""]) | .key as $dir | .value[] | @sh "/opt/fw/\($dir) \(.)"' requirement_mappings.json | xargs -I {} sh -c 'printf "Installing %s\n" $2 && pip install --ignore-installed --target $1 $2 --extra-index-url https://download.pytorch.org/whl/cpu --no-cache-dir' sh {} | ||
|
||
# install the requirements.txt, optional.txt with the mapped dependencies filtered out | ||
RUN pip install --upgrade -r requirements.txt &&\ | ||
cp ./optional.txt tmp.txt &&\ | ||
jq -r 'to_entries[] | [.key] + .value | select(length > 0 or (. == "")) | .[]' requirement_mappings.json | sort -u | xargs -I {} sed -i '/{}/d;/torch/d;/torch-scatter/d;/jax\[.*\]/d' tmp.txt && pip install -r tmp.txt | ||
|
||
RUN jq -r 'to_entries[] | select(.value != [""]) | .key as $dir | .value[] | @sh "/opt/fw/\($dir) \(.)"' requirement_mappings.json | \ | ||
xargs -I {} sh -c 'printf "Installing %s\n" $2 && pip install --ignore-installed --target $1 $2 --extra-index-url https://download.pytorch.org/whl/cpu --no-cache-dir' sh {} && \ | ||
pip install --upgrade -r requirements.txt && \ | ||
cp ./optional.txt tmp.txt && \ | ||
jq -r 'to_entries[] | [.key] + .value | select(length > 0 or (. == "")) | .[]' requirement_mappings.json | \ | ||
sort -u | xargs -I {} sed -i '/{}/d;/torch/d;/torch-scatter/d;/jax\[.*\]/d' tmp.txt && \ | ||
pip install -r tmp.txt | ||
|
||
# add all the directories to environment path so that python knows where to find them | ||
# Set PYTHONPATH | ||
ENV PYTHONPATH "/opt/fw/mxnet:/opt/fw/numpy:/opt/fw/tensorflow:/opt/fw/jax:/opt/fw/torch:/opt/fw/paddle:/opt/miniconda/envs/multienv/bin" | ||
|
||
# Test dependencies | ||
COPY scripts/test_dependencies.py . | ||
RUN python3 test_dependencies.py -fp requirements.txt,optional.txt && \ | ||
rm -rf requirements.txt && \ | ||
rm -rf optional.txt && \ | ||
rm -rf tmp.txt && \ | ||
rm -rf test_dependencies.py | ||
rm -rf requirements.txt optional.txt tmp.txt test_dependencies.py |