From 69a286bbecbb83e2d4b0275578236eab3159ccb7 Mon Sep 17 00:00:00 2001 From: Kosuke Fujimoto Date: Thu, 27 Mar 2025 13:14:23 +0000 Subject: [PATCH 1/4] change UID back to 1000 to align with host side uid --- notebooks/.devcontainer/Dockerfile | 2 +- src/sample_cpu_project/.devcontainer/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/.devcontainer/Dockerfile b/notebooks/.devcontainer/Dockerfile index dc75b70..ebf2302 100644 --- a/notebooks/.devcontainer/Dockerfile +++ b/notebooks/.devcontainer/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.11.11 # create non-root user and set the default user ARG USERNAME=devuser -ARG USER_UID=1010 +ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ diff --git a/src/sample_cpu_project/.devcontainer/Dockerfile b/src/sample_cpu_project/.devcontainer/Dockerfile index 50f32bc..22af4f0 100644 --- a/src/sample_cpu_project/.devcontainer/Dockerfile +++ b/src/sample_cpu_project/.devcontainer/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.11.11 # create non-root user and set the default user ARG USERNAME=devuser -ARG USER_UID=1010 +ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ From 724497b33a9d10d2952850baddedc9381c7d8134 Mon Sep 17 00:00:00 2001 From: Kosuke Fujimoto Date: Thu, 27 Mar 2025 13:15:44 +0000 Subject: [PATCH 2/4] change the base container to python --- .../.devcontainer/Dockerfile | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile b/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile index b3d6446..10a02a1 100644 --- a/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile +++ b/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile @@ -1,29 +1,21 @@ -# leverage multi-stage build and copy python binaries to cuda container -FROM python:3.11.11 as python -FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04 -COPY --from=python /usr/local/ /usr/local/ - -RUN apt-get update \ - && apt-get install -y \ - wget \ - git \ - sudo \ - && rm -rf /var/lib/apt/lists/* - +FROM python:3.11.11 # install Azure CLI RUN wget -qO- https://aka.ms/InstallAzureCLIDeb | bash - # create non-root user and set the default user ARG USERNAME=devuser -# uid=1000 is already used for ubuntu so use 1010 instead -ARG USER_UID=1010 +ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # Add sudo support + && apt-get update \ + && apt-get install -y sudo \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME + && chmod 0440 /etc/sudoers.d/$USERNAME \ + && rm -rf /var/lib/apt/lists/* USER $USERNAME + # make all python tools installed by pip accesible ENV PATH=$PATH:/home/$USERNAME/.local/bin From 98f730fa8670c01db4dbb8b425226aea18090c58 Mon Sep 17 00:00:00 2001 From: fujikosu Date: Thu, 27 Mar 2025 22:25:55 +0900 Subject: [PATCH 3/4] upgrade target version to py311 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bb2677f..e3bfcf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.ruff] -target-version = "py39" +target-version = "py311" extend-exclude = ["notebooks"] [tool.ruff.lint] From 9b3df5c8cfd802d20cbd9e24489ff6def977aaed Mon Sep 17 00:00:00 2001 From: fujikosu Date: Thu, 27 Mar 2025 13:59:19 +0000 Subject: [PATCH 4/4] show cuda and cudnn versions in sample main --- src/sample_pytorch_gpu_project/sample_main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sample_pytorch_gpu_project/sample_main.py b/src/sample_pytorch_gpu_project/sample_main.py index 9877eb8..bdaded4 100644 --- a/src/sample_pytorch_gpu_project/sample_main.py +++ b/src/sample_pytorch_gpu_project/sample_main.py @@ -12,6 +12,8 @@ def main(): print("torch.backends.cudnn.is_available():", torch.backends.cudnn.is_available()) print("torch.backends.cuda.is_built():", torch.backends.cuda.is_built()) print("torch.backends.mkldnn.is_available():", torch.backends.mkldnn.is_available()) + print("torch.version.cuda:", torch.version.cuda) + print("torch.backends.cudnn.version():", torch.backends.cudnn.version()) if __name__ == "__main__":