move devcontainer (#113)

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

View File

@ -3,7 +3,7 @@
This document lists different approaches for setting up your machine and using the code in this repository. I recommend browsing through the different sections from top to bottom and then deciding which approach best suits your needs.
<br>
&nbsp;
## Quickstart
@ -13,7 +13,7 @@ If you already have a Python installation on your machine, the quickest way to g
pip install -r requirements.txt
```
<br>
&nbsp;
## Setting up Python
@ -25,7 +25,7 @@ If you don't have Python set up on your machine yet, I have written about my per
<br>
&nbsp;
## Using Google Colab
@ -44,13 +44,19 @@ You can optionally run the code on a GPU by changing the *Runtime* as illustrate
<img src="./figures/3.webp" alt="3" width="700">
<br>
&nbsp;
## Using DevContainers
Alternatively, If you prefer a development setup that isolates a project's dependencies and configurations, using Docker is a highly effective solution. This approach eliminates the need to manually install software packages and libraries and ensures a consistent development environment. You can find more instructions for setting up Docker and using a DevContainer here in [../appendix-A/04_optional-docker-environment](../appendix-A/04_optional-docker-environment).
<br>
&nbsp;
## VSCode extensions
If you are using Visual Studio Code (VSCode) as your primary code editor, you can find recommended extensions in the `.vscode` subfolder. To install these, open the `extensions.json` file in VSCode and click the "Install" button in the pop-up menu on the lower right.
&nbsp;
## Questions?

View File

@ -1,3 +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](../appendix-A/04_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

@ -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.