Skip to content

Commit

Permalink
extend setup instructions (rasbt#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt authored Apr 16, 2024
1 parent b59eacb commit 8d53e8d
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 15 deletions.
14 changes: 7 additions & 7 deletions setup/01_optional-python-setup-preferences/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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".

Expand All @@ -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.
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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">



Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions setup/02_installing-python-libraries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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">



Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26 changes: 23 additions & 3 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file removed setup/figures/1.webp
Binary file not shown.
Binary file removed setup/figures/2.webp
Binary file not shown.
Binary file removed setup/figures/3.webp
Binary file not shown.

0 comments on commit 8d53e8d

Please sign in to comment.