move devcontainer (#113)

This commit is contained in:
Sebastian Raschka
2024-04-08 20:49:37 -04:00
committed by GitHub
parent 61b6e35ddf
commit 028a346498
6 changed files with 26 additions and 14 deletions

View File

@@ -0,0 +1,11 @@
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y rsync && \
apt-get install -y git && \
rm -rf /var/lib/apt/lists/*
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

View File

@@ -0,0 +1,3 @@
# Optional Docker Environment
This is an optional Docker environment for those users who prefer Docker. For more instructions, see the *Docker Environment Setup Guide* in [appendix-A/04_optional-docker-environment](../).

View File

@@ -0,0 +1,19 @@
{
"name": "LLMs From Scratch",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
"runArgs": ["--runtime=nvidia", "--gpus=all"],
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker",
"ms-toolsai.jupyter",
"yahyabatulu.vscode-markdown-alert",
"tomoki1207.pdf"
]
}
}
}

View File

@@ -27,10 +27,16 @@ git clone https://github.com/rasbt/LLMs-from-scratch.git
cd LLMs-from-scratch
```
2. In Docker Desktop, make sure that ***desktop-linux* builder** is running and will be used to build the Docker container (see *Docker Desktop* -> *Change settings* -> *Builders* -> *desktop-linux* -> *...* -> *Use*)
2. Move the `.devcontainer` file to the main `LLMs-from-scratch` project directory.
3. If you have a [CUDA-supported GPU](https://developer.nvidia.com/cuda-gpus), you can speed up the training and inference:
```bash
mv appendix-A/04_optional-docker-environment/.devcontainer ./
```
3. In Docker Desktop, make sure that ***desktop-linux* builder** is running and will be used to build the Docker container (see *Docker Desktop* -> *Change settings* -> *Builders* -> *desktop-linux* -> *...* -> *Use*)
4. If you have a [CUDA-supported GPU](https://developer.nvidia.com/cuda-gpus), you can speed up the training and inference:
3.1 Install **NVIDIA Container Toolkit** as described [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installing-with-apt). NVIDIA Container Toolkit is supported as written [here](https://docs.nvidia.com/cuda/wsl-user-guide/index.html#nvidia-compute-software-support-on-wsl-2).
3.2 Add *nvidia* as runtime in Docker Engine daemon config (see *Docker Desktop* -> *Change settings* -> *Docker Engine*). Add these lines to your config:
@@ -61,15 +67,15 @@ cd LLMs-from-scratch
```
and restart Docker Desktop.
4. Type `code .` in the terminal to open the project in VS Code. Alternatively, you can launch VS Code and select the project to open from the UI.
5. Type `code .` in the terminal to open the project in VS Code. Alternatively, you can launch VS Code and select the project to open from the UI.
5. Install the **Remote Development** extension from the VS Code *Extensions* menu on the left-hand side.
6. Install the **Remote Development** extension from the VS Code *Extensions* menu on the left-hand side.
6. Open the DevContainer.
7. Open the DevContainer.
Since the `.devcontainer` folder is present in the main `LLMs-from-scratch` directory (folders starting with `.` may be invisible in your OS depending on your settings), VS Code should automatically detect it and ask whether you would like to open the project in a devcontainer. If it doesn't, simply press `Ctrl + Shift + P` to open the command palette and start typing `dev containers` to see a list of all DevContainer-specific options.
7. Select **Reopen in Container**.
8. Select **Reopen in Container**.
Docker will now begin the process of building the Docker image specified in the `.devcontainer` configuration if it hasn't been built before, or pull the image if it's available from a registry.
@@ -80,7 +86,7 @@ Once completed, VS Code will automatically connect to the container and reopen t
> [!WARNING]
> If you are encountering an error during the build process, this is likely because your machine does not support NVIDIA container toolkit because your machine doesn't have a compatible GPU. In this case, edit the `devcontainer.json` file to remove the `"runArgs": ["--runtime=nvidia", "--gpus=all"],` line and run the "Reopen Dev Container" procedure again.
8. Finished.
9. Finished.
Once the image has been pulled and built, you should have your project mounted inside the container with all the packages installed, ready for development.