Skip to content

Commit

Permalink
Update scripts and actions to use renamed files/folders
Browse files Browse the repository at this point in the history
  • Loading branch information
wmaxey committed Jun 9, 2023
1 parent 0919dc0 commit 71bbce4
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/actions/build-windows-image/action.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Param(
$ErrorActionPreference = "Stop"

# Assume this script is launched from repo root.
./images/vs-version-matrix.ps1
.\scripts\windows\vs-version-matrix.ps1
$clVerArray = $vsVerToCompilers[$msvcVersion]

foreach ($cl in $clVerArray) {
./images/docker-build.ps1 -clVersion $cl -isolation $isolation -cudaVersion $cudaVersion -edition $edition -repo $repo
.\scripts\windows\build-windows-image.ps1 -clVersion $cl -isolation $isolation -cudaVersion $cudaVersion -edition $edition -repo $repo
}
5 changes: 3 additions & 2 deletions .github/actions/push-windows-image/action.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ Param(
$ErrorActionPreference = "Stop"

# Assume this script is launched from repo root.
./images/vs-version-matrix.ps1
.\scripts\windows\vs-version-matrix.ps1
$clVerArray = ($vsVerToCompilers[$msvcVersion])


foreach($cl in $clVerArray) {
$image=$(./images/generate-image-name -clVersion $cl -cudaVersion $cudaVersion -edition $edition -repo $repo)
$image=$(.\scripts\windows\generate-image-name -clVersion $cl -cudaVersion $cudaVersion -edition $edition -repo $repo)
Write-Output "Pushing $image"

docker push $image
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/test-windows-image/action.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ function TestReturnCode {
$ErrorActionPreference = "Stop"

# Assume this script is launched from repo root.
./images/vs-version-matrix.ps1
.\scripts\windows\vs-version-matrix.ps1
$clVerArray = ($vsVerToCompilers[$msvcVersion])

foreach($cl in $clVerArray) {
$image=$(./images/generate-image-name -clVersion $cl -cudaVersion $cudaVersion -edition $edition -repo $repo)
$image=$(.\scripts\windows\generate-image-name -clVersion $cl -cudaVersion $cudaVersion -edition $edition -repo $repo)
Write-Output "Testing $image"

docker run --mount type=bind,src="$(Get-Location)\.github\actions\test-windows-image",dst="C:\test" $image powershell "C:\test\image-test.ps1"
Expand Down
45 changes: 24 additions & 21 deletions scripts/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,46 @@ This process removes much of the difficulty in assembling a workspace compatible

## Caveats

It is easy to be successful with hyperv enabled, however the true potential of the container can be
It is easy to be successful with hyperv enabled, however the true potential of the container can be
achieved when `--isolation=process` is used. This requires either Windows 11 or Server editions of Windows.

## Building the container

### Step 0
If you are developing and testing, [install docker-desktop.](https://docs.docker.com/desktop/) If you are worried about
deployment you may need to
[install Docker Engine](https://docs.docker.com/engine/install/binaries/#install-server-and-client-binaries-on-windows)
manually. Regardless whatever option allows you to invoke Docker from the shell is required.

### Step 1
If you are developing and testing, [install docker-desktop.](https://docs.docker.com/desktop/) If you are worried about
deployment you may need to
[install Docker Engine](https://docs.docker.com/engine/install/binaries/#install-server-and-client-binaries-on-windows)
manually. Regardless, either option allows you to invoke Docker from the shell is required.

Prepare to wait, a long time, and execute the build step.
To install Docker Engine via script:

`$> docker build --pull --rm -f "docker\msvc\msvc.Dockerfile" -t MyWinEnv:latest "docker\msvc"`
```
## Invoke from within an elevated Powershell prompt
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1
.\install-docker-ce.ps1
## Fetch docker-compose plugin
Invoke-WebRequest -UseBasicParsing "https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-windows-x86_64.exe" -o $Env:ProgramFiles\Docker\docker-compose.exe
```

### Step 2
If issuing docker commands from a non-elevated prompt, you may need to add yourself to the `docker` group or modify the
Docker config: `daemon.json` appropriately to include the group you belong to.

Start up the container and mount your work directory.
### Step 1

`$> docker run --mount type=bind,src=C:\absolut\vodka\path,dst=C:\workspace\ -it MyWinEnv powershell.exe`
Build desired configuration. Windows 2019 and Windows 2022 versions map to Windows 10 and 11 respectively.

### Step 3 - Pick a flavor
`$> .\scripts\windows\build-windows-image.ps1 -clVersion 14.36 -cudaVersion 12.1 -edition windows-2019 -isolation hyperv -repo local"`

Now that you are in a shell, we need to pick a MSVC environment. A powershell module that handles this has been
pre-loaded to assist with this.
### Step 2

`$> Get-VSDevPrompt 14.xy`
Start up the container and mount workspace directories as needed.

Inspect msvc/resources/env_config.psm1 to see which compilers are available, this will occasionally get updated to
support new versions as they are released.
`$> docker run --mount type=bind,src="$(pwd)",dst="C:\thrust" -it local:windows-cuda-12.1-cl-14.36 powershell`

### Step 4 - Build your projects
### Step 3 - Build your projects

The environment will be configured to use the compiler you selected, and NVCC will be already set into the PATH.
No hacks necessary to make Thrust build (fingers crossed.)
The environment will be configured to use the compiler you when the image was built, and NVCC will be already available.

`$> cmake -S thrust -B build -G Ninja`
`$> ninja -C build thrust.tests`
`$> ninja -C build thrust.tests`
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Param(
[Parameter(Mandatory=$true)]
[string]
$clVersion,
$clVersion="latest",
[Parameter(Mandatory=$false)]
[string]
$cudaVersion="latest",
Expand All @@ -19,6 +19,12 @@ Param(
$repo="local"
)

function TestReturnCode {
if (-not $?) {
throw 'Step Failed'
}
}

Push-location "$PSScriptRoot"

$rootWindowsImage = @{
Expand All @@ -38,6 +44,7 @@ try {
$ENV:MSVC_COMPILER_VER="$clVersion"
$ENV:CUDA_VER="$cudaVersion"
$ENV:ROOT_IMAGE="$rootWindowsImage"
$ENV:BUILDKIT_PROGRESS="plain"

Write-Output "Building $ENV:IMAGE_NAME"
Write-Output "with args:"
Expand All @@ -48,7 +55,21 @@ try {
Write-Output "ENV:CUDA_VER $ENV:CUDA_VER"
Write-Output "ENV:ROOT_IMAGE $ENV:ROOT_IMAGE"

docker compose -f .\docker-compose.yml build windows --progress=plain
# Docker Desktop includes the compose command while CE installations will only have the standalone plugin.

$compose = "docker compose"
try {
docker compose
TestReturnCode
}
catch {
$compose = "docker-compose.exe"
}

Write-Output "Using $compose for building"
$compose = "$compose -f .\docker-compose.yml build windows"

Invoke-Expression $compose
}
catch {
Pop-Location
Expand Down
4 changes: 2 additions & 2 deletions scripts/windows/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ services:
image: "$IMAGE_NAME"
tty: true
build:
context: ./image
dockerfile: ../windows.dockerfile
context: .\image
dockerfile: ..\windows.dockerfile
args:
MSVC_VER: "$MSVC_VER"
MSVC_COMPILER_VER: "$MSVC_COMPILER_VER"
Expand Down
6 changes: 3 additions & 3 deletions scripts/windows/generate-image-name.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Param(
[Parameter(Mandatory=$true)]
[string]
$clVersion,
[Parameter(Mandatory=$false)]
[Parameter(Mandatory=$true)]
[string]
$cudaVersion="latest",
[Parameter(Mandatory=$false)]
$cudaVersion,
[Parameter(Mandatory=$true)]
[string]
$edition,
[Parameter(Mandatory=$true)]
Expand Down

0 comments on commit 71bbce4

Please sign in to comment.