Skip to content

Commit 67c0daa

Browse files
docker for bazel
1 parent fa21e1b commit 67c0daa

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE}
3+
4+
# Specify user IDs
5+
ARG GROUP
6+
ARG GID
7+
ARG USER
8+
ARG UID
9+
10+
# Run below commands as root
11+
USER root
12+
13+
#############################
14+
# Basic Dependencies
15+
#############################
16+
17+
ARG DEBIAN_FRONTEND=noninteractive
18+
19+
RUN <<EOF
20+
set -e
21+
apt-get update
22+
apt-get install -y \
23+
wget gnupg apt-utils curl \
24+
default-jdk-headless default-jre-headless \
25+
git python3.10 python3.10-distutils python3.10-dev python3.10-venv \
26+
python3-pip libprotobuf-dev protobuf-compiler libsndfile1 libcudnn8 \
27+
cuda-nsight-systems-${CUDA_VERSION%.*} \
28+
openmpi-bin openmpi-common libopenmpi-dev
29+
apt-get clean -y
30+
rm -rf /var/lib/apt/lists/*
31+
EOF
32+
33+
#------------------------------------------------------------------------------
34+
# Python setup
35+
# We install pyenv only for rockylinux, but we don't preload dependencies.
36+
# For ubuntu, preload the required python dependencies in the default python
37+
# environment.
38+
#------------------------------------------------------------------------------
39+
ARG PYTHON_VERSION=3.10
40+
ENV PYENV_ROOT="/pyenv"
41+
ENV PATH="/pyenv/bin:/pyenv/shims:$PATH"
42+
COPY python/requirements-dev.txt /tmp/requirements-dev.txt
43+
COPY python/requirements.txt /tmp/requirements.txt
44+
RUN <<EOF
45+
set -e
46+
python3 -m pip install -r /tmp/requirements-dev.txt
47+
# Cleanup dependencies file.
48+
rm /tmp/requirements-dev.txt /tmp/requirements.txt
49+
EOF
50+
51+
#------------------------------------------------------------------------------
52+
# LLVM toolchain installation
53+
# We install LLVM toolchain (clang, lld, etc) for ubuntu. This is a no-op for
54+
# rockylinux, where we just use GNU toolchain already installed above.
55+
#------------------------------------------------------------------------------
56+
ARG LLVM_VERSION=17
57+
ENV LLVM_VERSION=$LLVM_VERSION
58+
COPY build_tools/scripts/install_recommended_build_tools.sh /tmp/install_tools.sh
59+
60+
RUN <<EOF
61+
set -e
62+
chmod +x /tmp/install_tools.sh
63+
/tmp/install_tools.sh
64+
rm /tmp/install_tools.sh
65+
EOF
66+
67+
# Install bazel
68+
ARG ARCH="x86_64"
69+
ARG BAZEL_VERSION=6.4.0
70+
RUN wget -q https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-${ARCH} -O /usr/bin/bazel \
71+
&& chmod a+x /usr/bin/bazel
72+
73+
# Set workdir before launching container
74+
WORKDIR /opt/src/mlir-tensorrt
75+
76+
# Add user permissions
77+
RUN groupadd -o -g ${GID} ${GROUP} && \
78+
useradd -u ${UID} -g ${GROUP} -ms /bin/bash ${USER} && \
79+
usermod -aG sudo ${USER} && \
80+
chown -R ${USER}:${GROUP} /opt/src/mlir-tensorrt && \
81+
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
82+
83+
# Switch to user
84+
USER ${USER}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
docker build -f build_tools/bazel/Dockerfile \
4+
-t mlir-tensorrt:dev \
5+
--build-arg BASE_IMAGE=nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-ubuntu22.04 \
6+
--build-arg GROUP=$(id -gn) \
7+
--build-arg GID=$(id -g) \
8+
--build-arg USER=$(id -un) \
9+
--build-arg UID=$(id -u) \
10+
.
11+
12+
docker run -it \
13+
-v "$(pwd)":"/opt/src/mlir-tensorrt" \
14+
mlir-tensorrt:dev

0 commit comments

Comments
 (0)