fix: resolve PermissionError during local mode cleanup of root-owned Docker files#5629
Draft
mollyheamazon wants to merge 5 commits intoaws:masterfrom
Draft
fix: resolve PermissionError during local mode cleanup of root-owned Docker files#5629mollyheamazon wants to merge 5 commits intoaws:masterfrom
mollyheamazon wants to merge 5 commits intoaws:masterfrom
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Local container training fails with
PermissionErrorduring post-training cleanup.Docker containers write files as root, and
shutil.rmtreecannot remove them whenrunning as a non-root user (e.g.,
sagemaker-userin Studio).Root Cause
The original
_rmtreeattemptedos.chmodon PermissionError, which also failson root-owned files when running as non-root.
Fix
On PermissionError, use
docker run chmod -R 777(as root inside the container)to fix permissions, then retry
shutil.rmtree. In SageMaker Studio,--network sagemakeris added since Studio restricts Docker to that network. The already-pulledtraining image is reused to avoid pulling additional images.
Changes
sagemaker-train/.../local/local_container.py— updated_rmtree, pass imageand is_studio from
train()cleanup callssagemaker-core/.../local_core/local_container.py— same fix, kept in sync_rmtreecovering normal, fallback, Studio, and error casesTesting
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.