1
- FROM nvcr.io/nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
1
+ # Multi-stage build to keep the final image lean while providing CUDA, LLVM 7, and Rust.
2
+ FROM nvcr.io/nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 AS builder
2
3
3
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
4
- build-essential \
5
- curl \
6
- clang \
7
- libssl-dev \
8
- libtinfo-dev \
9
- pkg-config \
10
- xz-utils \
11
- zlib1g-dev && \
4
+ RUN apt-get update && \
5
+ DEBIAN_FRONTEND=noninteractive apt-get -y install \
6
+ build-essential \
7
+ clang \
8
+ cmake \
9
+ curl \
10
+ libffi-dev \
11
+ libfontconfig-dev \
12
+ libssl-dev \
13
+ libtinfo-dev \
14
+ libedit-dev \
15
+ libncurses5-dev \
16
+ libxml2-dev \
17
+ libx11-xcb-dev \
18
+ libxcursor-dev \
19
+ libxi-dev \
20
+ libxinerama-dev \
21
+ libxrandr-dev \
22
+ ninja-build \
23
+ pkg-config \
24
+ python3 \
25
+ xz-utils \
26
+ zlib1g-dev && \
12
27
rm -rf /var/lib/apt/lists/*
13
28
14
- # Needed to build `path_tracer`, `optix/ex03_window` example
15
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
16
- cmake \
17
- libfontconfig-dev \
18
- libx11-xcb-dev \
19
- libxcursor-dev \
20
- libxi-dev \
21
- libxinerama-dev \
22
- libxrandr-dev && \
23
- rm -rf /var/lib/apt/lists/*
24
-
25
- # Get LLVM 7
26
- WORKDIR /data/llvm7
27
-
28
- # Install dependencies for building LLVM
29
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
30
- libffi-dev \
31
- libedit-dev \
32
- libncurses5-dev \
33
- libxml2-dev \
34
- python3 \
35
- ninja-build && \
36
- rm -rf /var/lib/apt/lists/*
37
-
38
- # Download and build LLVM 7.1.0 for all architectures
29
+ WORKDIR /opt/build
39
30
RUN curl -sSf -L -O https://github.com/llvm/llvm-project/releases/download/llvmorg-7.1.0/llvm-7.1.0.src.tar.xz && \
40
31
tar -xf llvm-7.1.0.src.tar.xz && \
41
32
cd llvm-7.1.0.src && \
@@ -58,25 +49,56 @@ RUN curl -sSf -L -O https://github.com/llvm/llvm-project/releases/download/llvmo
58
49
-DLLVM_INCLUDE_BENCHMARKS=OFF \
59
50
-DLLVM_ENABLE_ZLIB=ON \
60
51
-DLLVM_ENABLE_TERMINFO=ON \
61
- -DCMAKE_INSTALL_PREFIX=/usr \
52
+ -DCMAKE_INSTALL_PREFIX=/opt/llvm-7 \
62
53
.. && \
63
- ninja -j$(nproc) && \
54
+ ninja -j" $(nproc)" && \
64
55
ninja install && \
65
- cd ../.. && \
66
- rm -rf llvm-7.1.0.src* && \
67
- ln -s /usr/bin/llvm-config /usr/bin/llvm-config-7
56
+ cd /opt && rm -rf /opt/build
68
57
69
- # Get Rust
70
- RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y
58
+ RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y --profile minimal && \
59
+ /root/.cargo/bin/rustup component add rustfmt clippy && \
60
+ rm -rf /root/.cargo/registry /root/.cargo/git /root/.rustup/tmp
71
61
ENV PATH="/root/.cargo/bin:${PATH}"
72
62
73
- # Setup the workspace
74
- WORKDIR /data/rust-cuda
75
- RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/rust-cuda/rust-toolchain.toml \
76
- rustup show
63
+ FROM nvcr.io/nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 AS runtime
77
64
78
- # Add nvvm to LD_LIBRARY_PATH.
65
+ RUN apt-get update && \
66
+ DEBIAN_FRONTEND=noninteractive apt-get -y install \
67
+ build-essential \
68
+ clang \
69
+ cmake \
70
+ curl \
71
+ libffi-dev \
72
+ libfontconfig-dev \
73
+ libssl-dev \
74
+ libtinfo-dev \
75
+ libedit-dev \
76
+ libncurses5-dev \
77
+ libxml2-dev \
78
+ libx11-xcb-dev \
79
+ libxcursor-dev \
80
+ libxi-dev \
81
+ libxinerama-dev \
82
+ libxrandr-dev \
83
+ pkg-config \
84
+ python3 \
85
+ xz-utils \
86
+ zlib1g-dev && \
87
+ rm -rf /var/lib/apt/lists/*
88
+
89
+ COPY --from=builder /opt/llvm-7 /opt/llvm-7
90
+ RUN ln -sf /opt/llvm-7/bin/llvm-config /usr/bin/llvm-config && \
91
+ ln -sf /opt/llvm-7/bin/llvm-config /usr/bin/llvm-config-7
92
+
93
+ COPY --from=builder /root/.cargo /root/.cargo
94
+ COPY --from=builder /root/.rustup /root/.rustup
95
+ ENV PATH="/root/.cargo/bin:${PATH}"
96
+ RUN /root/.cargo/bin/rustup show && \
97
+ rm -rf /root/.cargo/registry /root/.cargo/git /root/.rustup/tmp
98
+
99
+ WORKDIR /data/rust-cuda
79
100
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"
80
101
ENV LLVM_LINK_STATIC=1
81
102
ENV RUST_LOG=info
82
103
104
+ CMD ["bash" ]
0 commit comments