From 1f4f4a61c20cc108bdf2b84495a1ae4b0c4a8f0c Mon Sep 17 00:00:00 2001 From: Wouter Devriendt Date: Tue, 6 May 2025 19:23:54 +0000 Subject: [PATCH] Devcontainer: Replace conda with apt-based setup (#152881) ## Summary - Replaced miniconda base image with base Ubuntu 22.04 image - Installed Python and required dependencies using apt - Replaced conda-based CUDA installation with apt-based version - Updated paths in install-dev-tools.sh to reflect the new non-conda environment - Removed conda-specific files and added requirements.txt for Python dependencies ## Test plan Test by building and running the devcontainer in VS Code with both CPU and CUDA configurations Pull Request resolved: https://github.com/pytorch/pytorch/pull/152881 Approved by: https://github.com/atalman --- .devcontainer/Dockerfile | 54 ++++++++++++++-------- .devcontainer/cpu/environment.yml | 6 --- .devcontainer/cuda/devcontainer.json | 2 +- .devcontainer/cuda/environment.yml | 6 --- .devcontainer/cuda/requirements.txt | 2 + .devcontainer/noop.txt | 3 -- .devcontainer/scripts/install-dev-tools.sh | 4 +- 7 files changed, 41 insertions(+), 36 deletions(-) delete mode 100644 .devcontainer/cpu/environment.yml delete mode 100644 .devcontainer/cuda/environment.yml create mode 100644 .devcontainer/cuda/requirements.txt delete mode 100644 .devcontainer/noop.txt diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e151576219af..86e4d622536e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,34 +1,52 @@ -FROM mcr.microsoft.com/vscode/devcontainers/miniconda:0-3 +FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu-22.04 -# I am suprised this is needed -RUN conda init - -# Copy environment.yml (if found) to a temp location so we update the environment. Also -# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists. -COPY .devcontainer/cuda/environment.yml .devcontainer/noop.txt /tmp/conda-tmp/ -RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \ - && sudo rm -rf /tmp/conda-tmp +# Tools needed for development +RUN apt-get -y update && \ + apt-get install -y \ + build-essential \ + cmake \ + ninja-build \ + git \ + python3 \ + python3-pip \ + python3-dev \ + python3-venv \ + libopenblas-dev # Tools needed for llvm -RUN sudo apt-get -y update -RUN sudo apt install -y lsb-release wget software-properties-common gnupg +RUN apt-get install -y \ + lsb-release \ + wget \ + software-properties-common \ + gnupg + +# Create Python virtual environment +# RUN python3 -m venv /opt/venv +# ENV PATH="/opt/venv/bin:$PATH" +RUN pip3 install --upgrade pip # Install CLANG if version is specified ARG CLANG_VERSION RUN if [ -n "$CLANG_VERSION" ]; then \ - sudo wget https://apt.llvm.org/llvm.sh; \ + wget https://apt.llvm.org/llvm.sh; \ chmod +x llvm.sh; \ - sudo ./llvm.sh "${CLANG_VERSION}"; \ + ./llvm.sh "${CLANG_VERSION}"; \ echo 'export CC=clang' >> ~/.bashrc; \ echo 'export CXX=clang++' >> ~/.bashrc; \ - sudo apt update; \ - sudo apt install -y clang; \ - sudo apt install -y libomp-dev; \ + apt install -y clang libomp-dev; \ fi -# Install cuda if version is specified +# Install CUDA if version is specified ARG CUDA_VERSION RUN if [ -n "$CUDA_VERSION" ]; then \ - conda install -y cuda -c "nvidia/label/cuda-${CUDA_VERSION}"; \ + CUDA_REPO_VERSION=$(echo ${CUDA_VERSION} | sed 's/\./\-/g'); \ + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb && \ + dpkg -i cuda-keyring_1.0-1_all.deb && \ + apt-get install -y cuda-toolkit-${CUDA_VERSION}; \ fi + +# Set PATH for CUDA +ENV PATH="/usr/local/cuda/bin:${PATH}" +ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" +ENV PIP_BREAK_SYSTEM_PACKAGES=1 diff --git a/.devcontainer/cpu/environment.yml b/.devcontainer/cpu/environment.yml deleted file mode 100644 index 6367278e0aaf..000000000000 --- a/.devcontainer/cpu/environment.yml +++ /dev/null @@ -1,6 +0,0 @@ -# This environment is specific to Debian -name: PyTorch -dependencies: - - cmake - - ninja - - libopenblas \ No newline at end of file diff --git a/.devcontainer/cuda/devcontainer.json b/.devcontainer/cuda/devcontainer.json index df0c8a478a11..2dfcbd431717 100644 --- a/.devcontainer/cuda/devcontainer.json +++ b/.devcontainer/cuda/devcontainer.json @@ -8,7 +8,7 @@ "args": { "USERNAME": "vscode", "BUILDKIT_INLINE_CACHE": "0", - "CUDA_VERSION": "11.8.0", + "CUDA_VERSION": "12.8.0", "CLANG_VERSION": "" } }, diff --git a/.devcontainer/cuda/environment.yml b/.devcontainer/cuda/environment.yml deleted file mode 100644 index 6367278e0aaf..000000000000 --- a/.devcontainer/cuda/environment.yml +++ /dev/null @@ -1,6 +0,0 @@ -# This environment is specific to Debian -name: PyTorch -dependencies: - - cmake - - ninja - - libopenblas \ No newline at end of file diff --git a/.devcontainer/cuda/requirements.txt b/.devcontainer/cuda/requirements.txt new file mode 100644 index 000000000000..eb0a8b9c2b19 --- /dev/null +++ b/.devcontainer/cuda/requirements.txt @@ -0,0 +1,2 @@ +cmake +ninja \ No newline at end of file diff --git a/.devcontainer/noop.txt b/.devcontainer/noop.txt deleted file mode 100644 index 848dd98523f6..000000000000 --- a/.devcontainer/noop.txt +++ /dev/null @@ -1,3 +0,0 @@ -This file copied into the container along with environment.yml* from the parent -folder. This file is included to prevents the Dockerfile COPY instruction from -failing if no environment.yml is found. \ No newline at end of file diff --git a/.devcontainer/scripts/install-dev-tools.sh b/.devcontainer/scripts/install-dev-tools.sh index f33f294645e7..b5e15d6159d4 100644 --- a/.devcontainer/scripts/install-dev-tools.sh +++ b/.devcontainer/scripts/install-dev-tools.sh @@ -8,6 +8,6 @@ git submodule update --init --recursive make setup-lint # Add CMAKE_PREFIX_PATH to bashrc -echo 'export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}' >> ~/.bashrc +echo 'export CMAKE_PREFIX_PATH=/usr/local' >> ~/.bashrc # Add linker path so that cuda-related libraries can be found -echo 'export LDFLAGS="-L${CONDA_PREFIX}/lib/ $LDFLAGS"' >> ~/.bashrc +echo 'export LDFLAGS="-L/usr/local/cuda/lib64/ $LDFLAGS"' >> ~/.bashrc