Skip to content

Commit

Permalink
Update Dockerfile and build.py (#6281)
Browse files Browse the repository at this point in the history
* Update configuration for Windows Dockerfile (#6256)

* Adding installation of docker and docker-buildx

* Enable '--expt-relaxed-constexpr' flag for custom ops models

* Upate Dockerfile version

* Disable unit tests for Jetson
  • Loading branch information
mc-nv committed Sep 29, 2023
1 parent 35ab206 commit a6a80b5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 41 deletions.
77 changes: 40 additions & 37 deletions Dockerfile.win10.min
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ RUN powershell.exe Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Loca
RUN powershell.exe [Net.ServicePointManager]::Expect100Continue=$true;[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls,[Net.SecurityProtocolType]::Tls11,[Net.SecurityProtocolType]::Tls12,[Net.SecurityProtocolType]::Ssl3;Invoke-Expression( New-Object System.Net.WebClient ).DownloadString('https://chocolatey.org/install.ps1')
RUN choco install git docker unzip -y

#
# Installing CMake
#
ARG CMAKE_VERSION=3.27.1
ARG CMAKE_FILE=cmake-${CMAKE_VERSION}-windows-x86_64
ARG CMAKE_SOURCE=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_FILE}.zip

ADD ${CMAKE_SOURCE} ${CMAKE_FILE}.zip
RUN unzip %CMAKE_FILE%.zip
RUN move %CMAKE_FILE% "c:\CMake"
RUN setx PATH "c:\CMake\bin;%PATH%"

ENV CMAKE_TOOLCHAIN_FILE /vcpkg/scripts/buildsystems/vcpkg.cmake
ENV VCPKG_TARGET_TRIPLET x64-windows

LABEL CMAKE_VERSION=${CMAKE_VERSION}

# Be aware that pip can interact badly with VS cmd shell so need to pip install before
# vsdevcmd.bat (see https://bugs.python.org/issue38989)
ARG PYTHON_VERSION=3.8.10
Expand All @@ -51,44 +68,31 @@ RUN pip install grpcio-tools

LABEL PYTHON_VERSION=${PYTHON_VERSION}

# Download and install Build Tools for Visual Studio. The use of
# powershell for the install seems to be required to make the command
# wait for the install to complete before continuing. To avoid failures
# caused by VS regressions we want to stick with a working
# compiler. Currently this is 16.11.21. This page contains download
# links for buildtools.
# https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers
ARG BUILDTOOLS_VERSION=16.11.21
ARG BUILDTOOLS_SOURCE=https://download.visualstudio.microsoft.com/download/pr/8f1eb024-006a-43f6-a372-0721f71058b3/cc5cc690ac094fbfa78dfb8e40089ba52056026579e8d8dc31e95e8ea5466df5/vs_BuildTools.exe
ADD ${BUILDTOOLS_SOURCE} vs_buildtools.exe
#
# Installing Visual Studio BuildTools: VS17 2022
#
ARG BUILDTOOLS_VERSION
# Download collect.exe in case of an install failure.
ADD https://aka.ms/vscollect.exe "C:\tmp\collect.exe"

# Use the latest release channel. For more control, specify the location of an internal layout.
ARG CHANNEL_URL=https://aka.ms/vs/17/release/channel
ADD ${CHANNEL_URL} "C:\tmp\VisualStudio.chman"
# Download the Build Tools bootstrapper.
ARG BUILD_TOOLS_SOURCE=https://aka.ms/vs/17/release/vs_buildtools.exe
ADD ${BUILD_TOOLS_SOURCE} vs_buildtools.exe
# Install Build Tools with the Microsoft.VisualStudio.Workload.VCTools workload, including recommended.
ARG VS_INSTALL_PATH_WP="C:\BuildTools"
RUN powershell.exe Start-Process -FilePath vs_buildtools.exe -ArgumentList "--wait","--quiet","--norestart","--nocache","--installPath","%VS_INSTALL_PATH_WP%","--channelUri","C:\tmp\doesnotexist.chman","--addProductLang","En-us","--add","Microsoft.VisualStudio.Workload.VCTools`;includeRecommended","--add","Microsoft.Component.MSBuild" -Wait -PassThru
RUN vs_buildtools.exe --quiet --wait --norestart --nocache install --installPath %VS_INSTALL_PATH_WP% --channelUri "C:\tmp\VisualStudio.chman" --installChannelUri "C:\tmp\VisualStudio.chman" --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --locale "En-us"

LABEL BUILDTOOLS_VERSION=${BUILDTOOLS_VERSION}

WORKDIR /

#
# Installing CMake
#
ARG CMAKE_VERSION=3.26.1
ARG CMAKE_FILE=cmake-${CMAKE_VERSION}-windows-x86_64
ARG CMAKE_SOURCE=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_FILE}.zip

ADD ${CMAKE_SOURCE} ${CMAKE_FILE}.zip
RUN unzip %CMAKE_FILE%.zip
RUN move %CMAKE_FILE% CMake
RUN setx PATH "c:\CMake\bin;%PATH%"

ENV CMAKE_TOOLCHAIN_FILE /vcpkg/scripts/buildsystems/vcpkg.cmake
ENV VCPKG_TARGET_TRIPLET x64-windows

LABEL CMAKE_VERSION=${CMAKE_VERSION}

# Installing Vcpkg
#
# Installing Vcpkg
#
ARG VCPGK_VERSION=2022.11.14
ARG VCPGK_VERSION=2023.07.21
RUN git clone --single-branch --depth=1 -b %VCPGK_VERSION% https://github.com/microsoft/vcpkg.git
WORKDIR /vcpkg
RUN bootstrap-vcpkg.bat
Expand All @@ -100,13 +104,12 @@ LABEL VCPGK_VERSION=${VCPGK_VERSION}

WORKDIR /


#
# Installing CUDA
# Installing CUDA
#
ARG CUDA_MAJOR=12
ARG CUDA_MINOR=2
ARG CUDA_PATCH=0
ARG CUDA_PATCH=1
ARG CUDA_VERSION=${CUDA_MAJOR}.${CUDA_MINOR}.${CUDA_PATCH}
ARG CUDA_PACKAGES="nvcc_${CUDA_MAJOR}.${CUDA_MINOR} \
cudart_${CUDA_MAJOR}.${CUDA_MINOR} \
Expand All @@ -127,14 +130,14 @@ ADD ${CUDA_SOURCE} cuda_${CUDA_VERSION}_windows_network.exe
RUN cuda_%CUDA_VERSION%_windows_network.exe -s %CUDA_PACKAGES%
# Copy the CUDA visualstudio integration from where it was installed
# into the appropriate place in BuildTools
RUN copy "%CUDA_INSTALL_ROOT_WP%\extras\visual_studio_integration\MSBuildExtensions\*" "%VS_INSTALL_PATH_WP%\MSBuild\Microsoft\VC\v160\BuildCustomizations"
RUN copy "%CUDA_INSTALL_ROOT_WP%\extras\visual_studio_integration\MSBuildExtensions\*" "%VS_INSTALL_PATH_WP%\MSBuild\Microsoft\VC\v170\BuildCustomizations"

RUN setx PATH "%CUDA_INSTALL_ROOT_WP%\bin;%PATH%"

LABEL CUDA_VERSION="${CUDA_VERSION}"

#
# Installing Tensorrt
# Installing TensorRT
#
ARG TENSORRT_VERSION=8.6.1.6
ARG TENSORRT_ZIP="TensorRT-${TENSORRT_VERSION}.Windows10.x86_64.cuda-12.0.zip"
Expand All @@ -152,9 +155,9 @@ LABEL TENSORRT_VERSION="${TENSORRT_VERSION}"


#
# Installing CUDNN
# Installing cuDNN
#
ARG CUDNN_VERSION=8.9.4.25
ARG CUDNN_VERSION=8.9.5.27
ARG CUDNN_ZIP=cudnn-windows-x86_64-${CUDNN_VERSION}_cuda12-archive.zip
ARG CUDNN_SOURCE=${CUDNN_ZIP}

Expand Down
8 changes: 6 additions & 2 deletions qa/common/gen_qa_custom_ops
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ nvidia-smi -L || true
nvidia-smi || true
set -e
# Segmentation fault with protobuf 4.24.0 (https://github.com/tensorflow/tensorflow/issues/61551)
# Upgrade protobuf version to fix the issue.
pip3 install "protobuf>4.24.0"
TF_CFLAGS=\$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))')
TF_LFLAGS=\$(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')
Expand All @@ -88,12 +92,12 @@ g++ -std=${STD_FLAG} -O2 -shared -fPIC zero_out_op_kernel_1.cc -o $DESTDIR/libze
cp /opt/tensorflow/tensorflow-source/tensorflow/examples/adding_an_op/cuda_op_kernel.cc .
cp /opt/tensorflow/tensorflow-source/tensorflow/examples/adding_an_op/cuda_op_kernel.cu.cc .
patch -i $SRCDIR/cuda_op_kernel.cu.cc.patch cuda_op_kernel.cu.cc
nvcc -std=${STD_FLAG} -O2 -c -arch=all -o cuda_op_kernel.cu.o cuda_op_kernel.cu.cc \${TF_CFLAGS[@]} -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
nvcc --expt-relaxed-constexpr -std=${STD_FLAG} -O2 -c -arch=all -o cuda_op_kernel.cu.o cuda_op_kernel.cu.cc \${TF_CFLAGS[@]} -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
g++ -std=${STD_FLAG} -shared -o $DESTDIR/libcudaop.so cuda_op_kernel.cc cuda_op_kernel.cu.o \${TF_CFLAGS[@]} -fPIC -L/usr/local/cuda/lib64 -lcudart \${TF_LFLAGS[@]}
cp $SRCDIR/busy_op_kernel.cc .
cp $SRCDIR/busy_op_kernel.cu.cc .
nvcc -std=${STD_FLAG} -O2 -c -arch=all -o busy_op_kernel.cu.o busy_op_kernel.cu.cc \${TF_CFLAGS[@]} -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
nvcc --expt-relaxed-constexpr -std=${STD_FLAG} -O2 -c -arch=all -o busy_op_kernel.cu.o busy_op_kernel.cu.cc \${TF_CFLAGS[@]} -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
g++ -std=${STD_FLAG} -shared -o $DESTDIR/libbusyop.so busy_op_kernel.cc busy_op_kernel.cu.o \${TF_CFLAGS[@]} -fPIC -L/usr/local/cuda/lib64 -lcudart \${TF_LFLAGS[@]}
python3 $SRCDIR/gen_qa_custom_ops_models.py --graphdef --savedmodel \
Expand Down
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ if (NOT WIN32)
endif() # NOT WIN32

# Currently unit tests do not build for windows...
if (NOT WIN32)
add_subdirectory(test test)
if ( NOT WIN32)
if ( NOT EXISTS "/usr/lib/aarch64-linux-gnu/tegra/" )
add_subdirectory(test test)
endif()
endif() # NOT WIN32

0 comments on commit a6a80b5

Please sign in to comment.