first sync

This commit is contained in:
rasbt
2023-07-23 13:18:13 -05:00
commit d66b23588d
23 changed files with 2555 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
# Libraries Used In This Workshop
We will be using the following libraries in this workshop, and I highly recommend installing them before attending the event:
- numpy >= 1.24.3 (The fundamental package for scientific computing with Python)
- scipy >= 1.10.1 (Additional functions for NumPy)
- pandas >= 2.0.2 (A data frame library)
- matplotlib >= 3.7.1 (A plotting library)
- jupyterlab >= 4.0 (An application for running Jupyter notebooks)
- ipywidgets >= 8.0.6 (Fixes progress bar issues in Jupyter Lab)
- scikit-learn >= 1.2.2 (A general machine learning library)
- watermark >= 2.4.2 (An IPython/Jupyter extension for printing package information)
- torch >= 2.0.1 (The PyTorch deep learning library)
- torchvision >= 0.15.2 (PyTorch utilities for computer vision)
- torchmetrics >= 0.11.4 (Metrics for PyTorch)
- transformers >= 4.30.2 (Language transformers and LLMs for PyTorch)
- lightning >= 2.0.3 (A library for advanced PyTorch features: multi-GPU, mixed-precision etc.)
To install these requirements most conveniently, you can use the `requirements.txt` file:
```
pip install -r requirements.txt
```
![install-requirements](figures/install-requirements.png)
Then, after completing the installation, please check if all the packages are installed and are up to date using
```
python_environment_check.py
```
![check_1](figures/check_1.png)
It's also recommended to check the versions in JupyterLab by running the `jupyter_environment_check.ipynb` in this directory. Ideally, it should look like as follows:
![check_1](figures/check_2.png)
If you see the following issues, it's likely that your JupyterLab instance is connected to wrong conda environment:
![jupyter-issues](figures/jupyter-issues.png)
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:
![watermark](figures/watermark.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

View File

@@ -0,0 +1,123 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "18d54544-92d0-412c-8e28-f9083b2bab6f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[OK] Your Python version is 3.10.12\n"
]
}
],
"source": [
"from python_environment_check import check_packages, get_requirements_dict"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "60e03297-4337-4181-b8eb-f483f406954a",
"metadata": {},
"outputs": [],
"source": [
"d = get_requirements_dict()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d982ddf9-c167-4ed2-9fce-e271f2b1e1de",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[OK] numpy 1.25.1\n",
"[OK] scipy 1.11.1\n",
"[OK] pandas 2.0.3\n",
"[OK] matplotlib 3.7.2\n",
"[OK] jupyterlab 4.0.3\n",
"[OK] ipywidgets 8.0.7\n",
"[OK] watermark 2.4.3\n",
"[OK] torch 2.0.1\n"
]
}
],
"source": [
"check_packages(d)"
]
},
{
"cell_type": "markdown",
"id": "e0bdd547-333c-42a9-92f3-4e552f206cf3",
"metadata": {},
"source": [
"Same checks as above but using watermark:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "9d696044-9272-4b96-8305-34602807bb94",
"metadata": {},
"outputs": [],
"source": [
"%load_ext watermark"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "ce321731-a15a-4579-b33b-035730371eb3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"numpy : 1.25.1\n",
"scipy : 1.11.1\n",
"pandas : 2.0.3\n",
"matplotlib: 3.7.2\n",
"sklearn : 1.3.0\n",
"watermark : 2.4.3\n",
"torch : 2.0.1\n",
"\n",
"conda environment: LLMs\n",
"\n"
]
}
],
"source": [
"%watermark --conda -p numpy,scipy,pandas,matplotlib,sklearn,watermark,torch"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -0,0 +1,62 @@
# Sebastian Raschka, 2023
from os.path import dirname, join, realpath
from packaging.version import parse as version_parse
import platform
import sys
if version_parse(platform.python_version()) < version_parse('3.9'):
print('[FAIL] We recommend Python 3.9 or newer but'
' found version %s' % (sys.version))
else:
print('[OK] Your Python version is %s' % (platform.python_version()))
def get_packages(pkgs):
versions = []
for p in pkgs:
try:
imported = __import__(p)
try:
versions.append(imported.__version__)
except AttributeError:
try:
versions.append(imported.version)
except AttributeError:
try:
versions.append(imported.version_info)
except AttributeError:
versions.append('0.0')
except ImportError:
print(f'[FAIL]: {p} is not installed and/or cannot be imported.')
versions.append('N/A')
return versions
def get_requirements_dict():
PROJECT_ROOT = dirname(realpath(__file__))
REQUIREMENTS_FILE = join(PROJECT_ROOT, "requirements.txt")
d = {}
with open(REQUIREMENTS_FILE) as f:
for line in f:
line = line.split(" ")
d[line[0]] = line[-1]
return d
def check_packages(d):
versions = get_packages(d.keys())
for (pkg_name, suggested_ver), actual_ver in zip(d.items(), versions):
if actual_ver == 'N/A':
continue
actual_ver, suggested_ver = version_parse(actual_ver), version_parse(suggested_ver)
if actual_ver < suggested_ver:
print(f'[FAIL] {pkg_name} {actual_ver}, please upgrade to >= {suggested_ver}')
else:
print(f'[OK] {pkg_name} {actual_ver}')
if __name__ == '__main__':
d = get_requirements_dict()
check_packages(d)

View File

@@ -0,0 +1,8 @@
numpy >= 1.24.3
scipy >= 1.10.1
pandas >= 2.0.2
matplotlib >= 3.7.1
jupyterlab >= 4.0
ipywidgets >= 8.0.6
watermark >= 2.4.2
torch >= 2.0.1