extend setup instructions (#120)

This commit is contained in:
Sebastian Raschka 2024-04-15 22:05:03 -04:00 committed by GitHub
parent e5c567ad02
commit fdcb8f99fa
18 changed files with 35 additions and 15 deletions

View File

@ -15,7 +15,7 @@ There are several different ways you can install Python and set up your computin
Download miniforge from the GitHub repository [here](https://github.com/conda-forge/miniforge).
<img src="figures/download.png" alt="download" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/01_optional-python-setup-preferences/download.png" alt="download" width="600px">
Depending on your operating system, this should download either an `.sh` (macOS, Linux) or `.exe` file (Windows).
@ -27,7 +27,7 @@ sh ~/Desktop/Miniforge3-MacOSX-arm64.sh
where `Desktop/` is the folder where the Miniforge installer was downloaded to. On your computer, you may have to replace it with `Downloads/`.
<img src="figures/miniforge-install.png" alt="miniforge-install" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/01_optional-python-setup-preferences/miniforge-install.png" alt="miniforge-install" width="600px">
Next, step through the download instructions, confirming with "Enter".
@ -51,7 +51,7 @@ After the installation was successfully completed, I recommend creating a new vi
conda create -n LLMs python=3.10
```
<img src="figures/new-env.png" alt="new-env" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/01_optional-python-setup-preferences/new-env.png" alt="new-env" width="600px">
> Many scientific computing libraries do not immediately support the newest version of Python. Therefore, when installing PyTorch, it's advisable to use a version of Python that is one or two releases older. For instance, if the latest version of Python is 3.13, using Python 3.10 or 3.11 is recommended.
@ -61,7 +61,7 @@ Next, activate your new virtual environment (you have to do it every time you op
conda activate LLMs
```
<img src="figures/activate-env.png" alt="activate-env" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/01_optional-python-setup-preferences/activate-env.png" alt="activate-env" width="600px">
<br>
<br>
@ -83,13 +83,13 @@ To install new Python libraries, you can now use the `conda` package installer.
conda install jupyterlab watermark
```
<img src="figures/conda-install.png" alt="conda-install" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/01_optional-python-setup-preferences/conda-install.png" alt="conda-install" width="600px">
You can also still use `pip` to install libraries. By default, `pip` should be linked to your new `LLms` conda environment:
<img src="figures/check-pip.png" alt="check-pip" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/01_optional-python-setup-preferences/check-pip.png" alt="check-pip" width="600px">
<br>
<br>
@ -106,7 +106,7 @@ However, since PyTorch is a comprehensive library featuring CPU- and GPU-compati
It's also highly recommended to consult the installation guide menu on the official PyTorch website at [https://pytorch.org](https://pytorch.org).
<img src="figures/pytorch-installer.jpg" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/01_optional-python-setup-preferences/pytorch-installer.jpg" width="600px">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

View File

@ -17,19 +17,19 @@ Then, after completing the installation, please check if all the packages are in
python python_environment_check.py
```
<img src="figures/check_1.jpg" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/02_installing-python-libraries/check_1.jpg" width="600px">
It's also recommended to check the versions in JupyterLab by running the `jupyter_environment_check.ipynb` in this directory, which should ideally give you the same results as above.
<img src="figures/check_2.jpg" width="500px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/02_installing-python-libraries/check_2.jpg" width="500px">
If you see the following issues, it's likely that your JupyterLab instance is connected to wrong conda environment:
<img src="figures/jupyter-issues.jpg" width="450px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/02_installing-python-libraries/jupyter-issues.jpg" width="450px">
In this case, you may want to use `watermark` to check if you opened the JupyterLab instance in the right conda environment using the `--conda` flag:
<img src="figures/watermark.jpg" width="350px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/02_installing-python-libraries/watermark.jpg" width="350px">
<br>
@ -48,7 +48,7 @@ However, since PyTorch is a comprehensive library featuring CPU- and GPU-compati
It's also highly recommended to consult the installation guide menu on the official PyTorch website at [https://pytorch.org](https://pytorch.org).
<img src="figures/pytorch-installer.jpg" width="600px">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/02_installing-python-libraries/pytorch-installer.jpg" width="600px">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

View File

@ -46,21 +46,41 @@ If you are using Visual Studio Code (VSCode) as your primary code editor, you ca
&nbsp;
## Using Lightning Studio
For a smooth development experience in the cloud, I recommend the [Lightning AI Studio](https://lightning.ai/) platform, which allows users to set up a persistent environment and use both VSCode and Jupyter Lab on cloud CPUs and GPUs.
Once you start a new Studio, you can open the terminal and execute the following setup steps to clone the repository and install the dependencies:
```bash
git clone https://github.com/rasbt/LLMs-from-scratch.git
cd LLMs-from-scratch
pip install -r requirements.txt
```
(In contrast to Google Colab, these only need to be executed once since the Lightning AI Studion environments are persistent).
Then, navigate to the Python script or Jupyter Notebook you want to run. Optionally, you can also easily connect a GPU to accelerate the code's runtime, for example, when you are pretraining the LLM in chapter 5 or finetuning it in chapters 6 and 7.
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/README/studio.webp" alt="1" width="700">
&nbsp;
## Using Google Colab
To use a Google Colab environment in the cloud, head over to [https://colab.research.google.com/](https://colab.research.google.com/) and open the respective chapter notebook from the GitHub menu or by dragging the notebook into the *Upload* field as shown in the figure below.
<img src="./figures/1.webp" alt="1" width="700">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/README/colab_1.webp" alt="1" width="700">
Also make sure you upload the relevant files (dataset files and .py files the notebook is importing from) to the Colab environment as well, as shown below.
<img src="./figures/2.webp" alt="2" width="700">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/README/colab_2.webp" alt="2" width="700">
You can optionally run the code on a GPU by changing the *Runtime* as illustrated in the figure below.
<img src="./figures/3.webp" alt="3" width="700">
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/README/colab_3.webp" alt="3" width="700">
&nbsp;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB