Skip to content

Commit

Permalink
Add Dockerfile for windows agent
Browse files Browse the repository at this point in the history
  • Loading branch information
hientominh committed Jun 1, 2024
1 parent 9308211 commit f5691e8
Show file tree
Hide file tree
Showing 15 changed files with 626 additions and 1,396 deletions.
133 changes: 133 additions & 0 deletions .github/runners/Dockerfile.window.runner
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# https://learn.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2022

# Use the Windows Server Core 2019 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS devel

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# -----------------------------------------------------------------------------
# Create a working directory

WORKDIR "C:\\\\workspace"

# -----------------------------------------------------------------------------
# Install runtime dependencies

COPY setup_env.ps1 C:\\workspace\\setup_env.ps1
# TRT is installed along with build-time dependencies
RUN C:\workspace\setup_env.ps1 -skipTRT
RUN Remove-Item "C:\workspace\setup_env.ps1" -Force
# CUDNN paths are populated in the env variable CUDNN, add it to PATH
RUN [Environment]::SetEnvironmentVariable('Path', $Env:Path + ';' + $Env:CUDNN, [EnvironmentVariableTarget]::Machine)

# -----------------------------------------------------------------------------
# Install build-time dependencies

COPY setup_build_env.ps1 C:\\workspace\\setup_build_env.ps1
# TRT is installed in workspace
RUN C:\workspace\setup_build_env.ps1 -TRTPath 'C:\\workspace'
RUN Remove-Item "C:\workspace\setup_build_env.ps1" -Force

# Add binaries to Path
RUN [Environment]::SetEnvironmentVariable('Path', $Env:Path + ';C:\Program Files\CMake\bin', [EnvironmentVariableTarget]::Machine)

# -----------------------------------------------------------------------------

# Install Vim (can delete this but it's nice to have)
# and add binaries to Path

RUN Invoke-WebRequest -Uri https://ftp.nluug.nl/pub/vim/pc/gvim90.exe \
-OutFile "install_vim.exe"; \
Start-Process install_vim.exe -Wait -ArgumentList '/S'; \
Remove-Item install_vim.exe -Force ; \
[Environment]::SetEnvironmentVariable('Path', $Env:Path + ';C:\Program Files (x86)\Vim\vim90', [EnvironmentVariableTarget]::Machine)
# -----------------------------------------------------------------------------

# Install Chocolatey
# Chocolatey is a package manager for Windows

# If you try to install Chocolatey 2.0.0, it fails on .NET Framework 4.8 installation
# https://stackoverflow.com/a/76470753
ENV chocolateyVersion=1.4.0

# https://docs.chocolatey.org/en-us/choco/setup#install-with-powershell.exe
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; \
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# -----------------------------------------------------------------------------

# Install Git via Chocolatey
RUN choco install git -y

# -----------------------------------------------------------------------------
# Install CUDA 11.8 NVTX
RUN Invoke-WebRequest -Uri https://developer.download.nvidia.com/compute/cuda/11.8.0/network_installers/cuda_11.8.0_windows_network.exe \
-OutFile cuda_11.8.0_windows_network.exe; \
Invoke-WebRequest -Uri https://7-zip.org/a/7zr.exe \
-OutFile 7zr.exe

RUN .\7zr.exe e -i!'nsight_nvtx\nsight_nvtx\NVIDIA NVTX Installer.x86_64.Release.v1.21018621.Win64.msi' cuda_11.8.0_windows_network.exe ;

RUN cmd.exe /S /C "msiexec.exe /i 'NVIDIA NVTX Installer.x86_64.Release.v1.21018621.Win64.msi' /norestart /quiet"

RUN Remove-Item 'NVIDIA NVTX Installer.x86_64.Release.v1.21018621.Win64.msi' -Force ; \
Remove-Item 7zr.exe -Force ; \
Remove-Item cuda_11.8.0_windows_network.exe -Force

# -----------------------------------------------------------------------------

# Define the entry point for the docker container.
# This entry point launches the 64-bit PowerShell developer shell.
# We need to launch with amd64 arch otherwise Powershell defaults to x86 32-bit build commands which don't jive with CUDA
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "-arch=amd64", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

# -----------------------------------------------------------------------------
# COPY requirements-windows.txt C:\\workspace\\requirements-windows.txt
# COPY requirements-dev-windows.txt C:\\workspace\\requirements-dev-windows.txt
# RUN python3 -m pip --no-cache-dir install -r C:\workspace\requirements-dev-windows.txt
# RUN Remove-Item "C:\workspace\requirements-windows.txt" -Force
# RUN Remove-Item "C:\workspace\requirements-dev-windows.txt" -Force

# This bellow command lt MSVC recognize cuda compiler
RUN powershell -Command \
$ErrorActionPreference = 'Stop'; \
Copy-Item -Path 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\extras\visual_studio_integration\MSBuildExtensions\*' -Destination 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\BuildCustomizations'

RUN powershell -Command \
$ErrorActionPreference = 'Stop'; \
Copy-Item -Path 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\extras\visual_studio_integration\MSBuildExtensions\*' -Destination 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v160\BuildCustomizations'

RUN powershell -Command \
choco install Ninja -y; \
choco install sccache -y;

SHELL ["cmd", "/S", "/C"]

RUN setx Path "%Path%;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools"

ARG RUNNER_VERSION=2.316.1

# Define the entry point for the docker container.
# This entry point launches the 64-bit PowerShell developer shell.
# We need to launch with amd64 arch otherwise Powershell defaults to x86 32-bit build commands which don't jive with CUDA
# ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "-arch=amd64", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

RUN powershell -Command \
$ErrorActionPreference = 'Stop'; \
Invoke-WebRequest \
-Uri https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip \
-OutFile runner.zip; \
Expand-Archive -Path ./runner.zip -DestinationPath ./actions-runner; \
Remove-Item -Path .\runner.zip; \
setx /M PATH $(${Env:PATH} + \";${Env:ProgramFiles}\Git\bin\")

ADD runner.ps1 ./runner.ps1

RUN powershell -Command New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

RUN powershell -Command icacls 'C:\workspace\nitro-tensorrt-llm' /grant 'Everyone:F' /T

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

CMD ["powershell.exe", "-ExecutionPolicy", "Unrestricted", "-File", ".\\runner.ps1"]
Loading

0 comments on commit f5691e8

Please sign in to comment.