-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: add buildspec-release file and upgrade cuda version (#109)
- Loading branch information
1 parent
5b4466c
commit cb9f417
Showing
9 changed files
with
195 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
version: 0.2 | ||
|
||
env: | ||
variables: | ||
FRAMEWORK_VERSION: '1.1.0' | ||
CPU_INSTANCE_TYPE: 'ml.c4.xlarge' | ||
CPU_PY_VERSION: '2' | ||
GPU_INSTANCE_TYPE: 'ml.p2.xlarge' | ||
GPU_PY_VERSION: '3' | ||
LOCAL_BASE_REPO: 'pytorch-base' | ||
ECR_REPO: 'sagemaker-pytorch' | ||
GITHUB_REPO: 'sagemaker-pytorch-container' | ||
SETUP_FILE: 'setup_cmds.sh' | ||
SETUP_CMDS: '#!/bin/bash\npip install --upgrade pip\npip install -U -e .\npip install -U -e .[test]' | ||
|
||
|
||
phases: | ||
pre_build: | ||
commands: | ||
- start-dockerd | ||
- ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text) | ||
- PREPROD_IMAGE="$ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$ECR_REPO" | ||
- PR_NUM=$(echo $CODEBUILD_SOURCE_VERSION | grep -o '[0-9]\+') | ||
- echo 'Pull request number:' $PR_NUM '. No value means this build is not from pull request.' | ||
|
||
build: | ||
commands: | ||
# prepare the release | ||
- git-release --prepare --min-version 1.2.0 | ||
|
||
# install | ||
- pip3 install -U -e . | ||
- pip3 install -U -e .[test] | ||
|
||
# run unit tests | ||
- pytest test/unit | ||
|
||
# build cpu base image | ||
- base_dir="docker/$FRAMEWORK_VERSION/base" | ||
- cpu_py2_base_tag="$FRAMEWORK_VERSION-cpu-py2" | ||
- cpu_py3_base_tag="$FRAMEWORK_VERSION-cpu-py3" | ||
- cpu_dockerfile="Dockerfile.cpu" | ||
- cd $base_dir | ||
- docker build -t $LOCAL_BASE_REPO:$cpu_py2_base_tag -f $cpu_dockerfile --build-arg py_version=2 . | ||
- docker build -t $LOCAL_BASE_REPO:$cpu_py3_base_tag -f $cpu_dockerfile --build-arg py_version=3 . | ||
- cd ../../../ | ||
|
||
# build gpu base image | ||
- gpu_py2_base_tag="$FRAMEWORK_VERSION-gpu-py2" | ||
- gpu_py3_base_tag="$FRAMEWORK_VERSION-gpu-py3" | ||
- gpu_dockerfile="Dockerfile.gpu" | ||
- cd $base_dir | ||
- docker build -t $LOCAL_BASE_REPO:$gpu_py2_base_tag -f $gpu_dockerfile --build-arg py_version=2 . | ||
- docker build -t $LOCAL_BASE_REPO:$gpu_py3_base_tag -f $gpu_dockerfile --build-arg py_version=3 . | ||
- cd ../../../ | ||
|
||
# create wheel | ||
- python3 setup.py bdist_wheel | ||
|
||
# build cpu image | ||
- build_dir="docker/$FRAMEWORK_VERSION/final" | ||
- CPU_PY2_TAG="$FRAMEWORK_VERSION-cpu-py2" | ||
- CPU_PY3_TAG="$FRAMEWORK_VERSION-cpu-py3" | ||
- docker build -f "$build_dir/$cpu_dockerfile" --build-arg py_version=2 -t $PREPROD_IMAGE:$CPU_PY2_TAG . | ||
- docker build -f "$build_dir/$cpu_dockerfile" --build-arg py_version=3 -t $PREPROD_IMAGE:$CPU_PY3_TAG . | ||
|
||
# build gpu image | ||
- GPU_PY2_TAG="$FRAMEWORK_VERSION-gpu-py2" | ||
- GPU_PY3_TAG="$FRAMEWORK_VERSION-gpu-py3" | ||
- docker build -f "$build_dir/$gpu_dockerfile" --build-arg py_version=2 -t $PREPROD_IMAGE:$GPU_PY2_TAG . | ||
- docker build -f "$build_dir/$gpu_dockerfile" --build-arg py_version=3 -t $PREPROD_IMAGE:$GPU_PY3_TAG . | ||
|
||
# push images to ecr | ||
- $(aws ecr get-login --registry-ids $ACCOUNT --no-include-email --region $AWS_DEFAULT_REGION) | ||
- docker push $PREPROD_IMAGE:$CPU_PY2_TAG | ||
- docker push $PREPROD_IMAGE:$CPU_PY3_TAG | ||
- docker push $PREPROD_IMAGE:$GPU_PY2_TAG | ||
- docker push $PREPROD_IMAGE:$GPU_PY3_TAG | ||
|
||
# launch remote gpu instance | ||
- prefix='ml.' | ||
- instance_type=${GPU_INSTANCE_TYPE#"$prefix"} | ||
- create-key-pair | ||
- launch-ec2-instance --instance-type $instance_type --ami-name dlami-ubuntu | ||
|
||
# run cpu integration tests | ||
- | | ||
if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then | ||
pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY_VERSION --processor cpu | ||
else | ||
echo "skipping cpu integration tests" | ||
fi | ||
# run gpu integration tests | ||
- | | ||
if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then | ||
printf "$SETUP_CMDS" > $SETUP_FILE | ||
cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY_VERSION --processor gpu" | ||
remote-test --github-repo $GITHUB_REPO --test-cmd "$cmd" --setup-file $SETUP_FILE --pr-number "$PR_NUM" | ||
else | ||
echo "skipping gpu integration tests" | ||
fi | ||
# run cpu sagemaker tests | ||
- | | ||
if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then | ||
pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY_VERSION --processor cpu --instance-type $CPU_INSTANCE_TYPE | ||
else | ||
echo "skipping cpu sagemaker tests" | ||
fi | ||
# run gpu sagemaker tests | ||
- | | ||
if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then | ||
pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY_VERSION --processor gpu --instance-type $GPU_INSTANCE_TYPE | ||
else | ||
echo "skipping gpu sagemaker tests" | ||
fi | ||
- | | ||
echo '[{ | ||
"repository": "sagemaker-pytorch", | ||
"tags": [{ | ||
"source": "1.1.0-cpu-py2", | ||
"dest": ["1.1.0-cpu-py2", "1.1-cpu-py2", "1.1.0-cpu-py2-'${CODEBUILD_BUILD_ID#*:}'"] | ||
},{ | ||
"source": "1.1.0-cpu-py3", | ||
"dest": ["1.1.0-cpu-py3", "1.1-cpu-py3", "1.1.0-cpu-py3-'${CODEBUILD_BUILD_ID#*:}'"] | ||
},{ | ||
"source": "1.1.0-gpu-py2", | ||
"dest": ["1.1.0-gpu-py2", "1.1-gpu-py2", "1.1.0-gpu-py2-'${CODEBUILD_BUILD_ID#*:}'"] | ||
},{ | ||
"source": "1.1.0-gpu-py3", | ||
"dest": ["1.1.0-gpu-py3", "1.1-gpu-py3", "1.1.0-gpu-py3-'${CODEBUILD_BUILD_ID#*:}'"] | ||
}], | ||
"test": [ | ||
"IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker --py-version 3 --processor cpu --region {region} --docker-base-name '$ECR_REPO' --aws-id 520713654638 --framework-version '$FRAMEWORK_VERSION' --instance-type '$CPU_INSTANCE_TYPE'", | ||
"IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker --py-version 2 --processor cpu --region {region} --docker-base-name '$ECR_REPO' --aws-id 520713654638 --framework-version '$FRAMEWORK_VERSION' --instance-type '$CPU_INSTANCE_TYPE'", | ||
"IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker --py-version 3 --processor gpu --region {region} --docker-base-name '$ECR_REPO' --aws-id 520713654638 --framework-version '$FRAMEWORK_VERSION' --instance-type '$GPU_INSTANCE_TYPE'", | ||
"IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker --py-version 2 --processor gpu --region {region} --docker-base-name '$ECR_REPO' --aws-id 520713654638 --framework-version '$FRAMEWORK_VERSION' --instance-type '$GPU_INSTANCE_TYPE'" | ||
] | ||
}]' > deployments.json | ||
# publish the release to github | ||
- git-release --publish | ||
|
||
finally: | ||
# shut down remote gpu instance | ||
- cleanup-gpu-instances | ||
- cleanup-key-pairs | ||
|
||
artifacts: | ||
files: | ||
- deployments.json | ||
name: ARTIFACT_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04 | ||
FROM nvidia/cuda:10.1-cudnn7-runtime-ubuntu16.04 | ||
|
||
ARG py_version | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters