Skip to content

Commit fa2878c

Browse files
committed
fix pytorch build
1 parent f82ef6c commit fa2878c

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

Dockerfile.tmpl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ARG TORCHVISION_VERSION
1010

1111
{{ if eq .Accelerator "gpu" }}
1212
FROM gcr.io/kaggle-images/python-lightgbm-whl:${GPU_BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${LIGHTGBM_VERSION} AS lightgbm_whl
13-
#FROM gcr.io/kaggle-images/python-torch-whl:${GPU_BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${TORCH_VERSION} AS torch_whl
13+
FROM gcr.io/kaggle-images/python-torch-whl:${GPU_BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${TORCH_VERSION} AS torch_whl
1414
FROM ${BASE_IMAGE_REPO}/${GPU_BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}
1515
{{ else }}
1616
FROM ${BASE_IMAGE_REPO}/${CPU_BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}
@@ -111,15 +111,13 @@ RUN mamba install implicit && \
111111
{{ if eq .Accelerator "gpu" }}
112112
#COPY --from=torch_whl /tmp/whl/*.whl /tmp/torch/
113113
RUN mamba install -c pytorch magma-cuda${CUDA_MAJOR_VERSION}${CUDA_MINOR_VERSION} && \
114-
#pip install /tmp/torch/*.whl && \
114+
pip install /tmp/torch/*.whl && \
115115
# b/255757999 openmp (libomp.so) is an dependency of libtorchtext and libtorchaudio but
116-
# the built from source versions don't seem to properly link it in. This forces the dep
117-
# which makes sure that libomp is loaded when these libraries are loaded.
118-
mamba install pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0 torchtext cudatoolkit=11.3 -c pytorch && \
116+
mamba install -y openmp && \
119117
#pip install patchelf && \
120118
#patchelf --add-needed libomp.so /opt/conda/lib/python3.7/site-packages/torchtext/lib/libtorchtext.so && \
121119
#patchelf --add-needed libomp.so /opt/conda/lib/python3.7/site-packages/torchaudio/lib/libtorchaudio.so && \
122-
#rm -rf /tmp/torch && \
120+
rm -rf /tmp/torch && \
123121
/tmp/clean-layer.sh
124122
{{ else }}
125123
RUN pip install \

Jenkinsfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ pipeline {
2222
stages {
2323
stage('Pre-build Packages from Source') {
2424
parallel {
25+
stage('torch') {
26+
options {
27+
timeout(time: 180, unit: 'MINUTES')
28+
}
29+
steps {
30+
sh '''#!/bin/bash
31+
set -exo pipefail
32+
source config.txt
33+
cd packages/
34+
./build_package --base-image $BASE_IMAGE_REPO/$GPU_BASE_IMAGE_NAME:$BASE_IMAGE_TAG \
35+
--package torch \
36+
--version $TORCH_VERSION \
37+
--build-arg TORCHAUDIO_VERSION=$TORCHAUDIO_VERSION \
38+
--build-arg TORCHTEXT_VERSION=$TORCHTEXT_VERSION \
39+
--build-arg TORCHVISION_VERSION=$TORCHVISION_VERSION \
40+
--build-arg CUDA_MAJOR_VERSION=$CUDA_MAJOR_VERSION \
41+
--build-arg CUDA_MINOR_VERSION=$CUDA_MINOR_VERSION \
42+
--push
43+
'''
44+
}
45+
}
2546
stage('lightgbm') {
2647
options {
2748
timeout(time: 10, unit: 'MINUTES')

config.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ BASE_IMAGE_TAG=m103
33
CPU_BASE_IMAGE_NAME=tf2-cpu.2-11
44
GPU_BASE_IMAGE_NAME=tf2-gpu.2-11
55
LIGHTGBM_VERSION=3.3.2
6-
TORCH_VERSION=1.12.0
7-
TORCHAUDIO_VERSION=0.12.0
8-
TORCHTEXT_VERSION=0.13.0
9-
TORCHVISION_VERSION=0.13.0
6+
TORCH_VERSION=1.13.0
7+
TORCHAUDIO_VERSION=0.13.0
8+
TORCHTEXT_VERSION=0.14.0
9+
TORCHVISION_VERSION=0.14.0
1010
CUDA_MAJOR_VERSION=11
1111
CUDA_MINOR_VERSION=3

packages/torch.Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ RUN sudo apt-get update && \
5555
cd audio && \
5656
git checkout tags/v$TORCHAUDIO_VERSION && \
5757
git submodule sync && \
58-
git submodule update --init --recursive --jobs 1 && \
59-
python setup.py bdist_wheel
58+
git submodule update --init --recursive --jobs 1
59+
# https://github.com/pytorch/audio/issues/936#issuecomment-702990346
60+
RUN sed -i 's/set(envs/set(envs\n "LIBS=-ltinfo"/' /usr/local/src/audio/third_party/sox/CMakeLists.txt
61+
RUN cd /usr/local/src/audio && python setup.py bdist_wheel
6062

6163
# Build torchtext
6264
# Instructions: https://github.com/pytorch/text#building-from-source

0 commit comments

Comments
 (0)