Skip to content

Commit ddc7008

Browse files
committed
Updated virtual environment
1 parent 84be179 commit ddc7008

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.txt
1+
*.txt
2+
nanoGPT

Introduction/Virtual_env.md

+43-39
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44

55
Today, we will work in our machines, **not in the google colab or kaggle** and see how to do that.
66

7-
To install libraries, we will use `Pip`. Other ways of doing that will be using `conda` (personally I use this method much more than `pip`).
7+
Now, we will create a `virtual environment`. A virtual enviro­nment is a Python tool for `dependency management` and `project isolation`. They allow Python third party libraries to be installed locally in an isolated directory for a particular project. *So it works like an isolated box insode your machine for python.*
88

9+
<!-- We will create **virtual environments** inside our machine so that different projects and versions of the packages do not get mmixed up. Virtual environments are like separate boxes inside your machine which do not intearct between each other. -->
910

10-
## Conda
11-
========
11+
To install libraries, we will use `conda`, which will also be used to create virtual environments. Other ways of doing that will be using `Pip` to install packages and `venv` or some other method to create virtual environment,
1212

13-
Search `conda cheatsheet` and something like this will follow: https://docs.conda.io/projects/conda/en/latest/_downloads/843d9e0198f2a193a3484886fa28163c/conda-cheatsheet.pdf
13+
After that, we will try to run n example repository from github (about nanoGPT).
1414

15+
# Conda
1516

16-
For windows user, go there https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html#regular-installation and install conda (miniconda for smaller size)
17+
`conda cheatsheet`: https://docs.conda.io/projects/conda/en/latest/_downloads/843d9e0198f2a193a3484886fa28163c/conda-cheatsheet.pdf
1718

1819

20+
## Install conda
21+
Goto https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html#regular-installation and install conda (miniconda for smaller size)
1922

2023
Install Anaconda or Miniconda normally, and let the installer add the conda installation of Python to your PATH environment variable. There is no need to set the PYTHONPATH environment variable.
2124

@@ -25,51 +28,50 @@ To see if the conda installation of Python is in your PATH variable:
2528

2629

2730

28-
### After Installation
29-
We will try `nanoGPT` (https://github.com/karpathy/nanoGPT) - not create code but use another person's code.
30-
31+
## After Installation, create virtual environement
32+
We will try `nanoGPT` (https://github.com/karpathy/nanoGPT) and run somse of the examples - we will not create new code but use another person's code.
3133

34+
To do that, we will create a new virtual environment:
35+
* Create environment
3236
```bash
33-
## Create environment
3437
conda create --name ENVNAME
35-
36-
## Activate that environment
38+
```
39+
* Activate that environment
40+
```bash
3741
conda activate ENVNAME
3842
```
3943

40-
### Install packages:
44+
## Install packages:
4145

42-
* First, pytorch
46+
* First, install pytorch according to this website: https://pytorch.org/get-started/locally/
4347
```bash
4448
conda install pytorch torchvision torchaudio cpuonly -c pytorch
4549
```
46-
* Then other packages according to the readme file
50+
* Then other packages according to the readme file of the `nanoGPT`:
4751
```bash
4852
conda install transformers datasets tiktoken wandb tqdm -c conda-forge
4953
```
54+
(Some of the package need the extra channel `conda-forge`)
5055

5156

5257

53-
## Now go to NanoGPT page and download the package
54-
55-
56-
We will not train the whole model as it would take time. We would `fine-tune` the model, already script is ready.
57-
58-
Download or clone:
58+
## Go to nanoGPT page and download the package
59+
* Download or clone:
5960
```bash
60-
git clone git@github.com:karpathy/nanoGPT.git --depth 1
61+
git clone https://github.com/karpathy/nanoGPT.git --depth 1
6162
```
62-
63-
Go inside the folder
63+
* Go inside the folder
6464
```bash
6565
cd nanoGPT
6666
```
6767

68-
Configure:
68+
We will not train the whole model as it would take time. We would `fine-tune` the model, already script is ready.
69+
70+
Configure to prepare the models:
6971
```bash
7072
python data/shakespeare/prepare.py --device=cpu
7173
```
72-
Fine tune:
74+
Fine tune (skip it for now, you can fine tune more, see the readme of the `nanoGPT` github repo):
7375
```bash
7476
python train.py config/finetune_shakespeare.py --device=cpu --init_from=gpt2 --eval_iters=10
7577
```
@@ -84,10 +86,16 @@ python sample.py --device=cpu\
8486
```
8587

8688

89+
Deactivate the environment
90+
```bash
91+
conda deactivate
92+
```
93+
94+
8795

88-
<!--
89-
## PIP
9096

97+
# PIP
98+
The other common way to use the virtual environment is via `venv` and `Pip`. First, we have to install `pip`.
9199
"Pip is a thing that installs packages, pip itself is a package that someone might want to install..."
92100
```sh
93101
# Download PIP globally
@@ -115,10 +123,10 @@ If you’d rather run pip (or other tools) from any location, you’ll need to a
115123
* Click New, and add the directory where pip is installed, e.g. C:Python33Scripts, and select OK.
116124

117125

126+
----------------------------------------------------
127+
## Virtual environments
118128

119-
Now, we will create a `virtual environment`. A virtual enviro­nment is a Python tool for `dependency management` and `project isolation`. They allow Python third party libraries to be installed locally in an isolated directory for a particular project. *So it works like an isolated box insode your machine for python.*
120-
121-
129+
We will create **virtual environments** inside our machine so that different projects and versions of the packages do not get mmixed up.
122130
Cheatsheet: https://gist.github.com/ryanbehdad/858b47b54be441a684efb7ae6ca98a75
123131

124132

@@ -137,19 +145,15 @@ source venv1/bin/activate
137145

138146
### Install packages
139147
```bash
140-
pip install jupyter matplotlib numpy pandas scipy scikit-learn
148+
pip install transformers datasets tiktoken wandb tqdm
141149
#or
142-
python -m pip install -U jupyter matplotlib numpy pandas scipy scikit-learn
150+
python -m pip install -U transformers datasets tiktoken wandb tqdm
143151
```
144152

145153

146154

147-
## Other ways: using conda
148-
149-
150-
151155

152-
## Other ways: using virtualenv
156+
## Other ways for virtual environment using `virtualenv`
153157

154158
Cheatsheet: https://cheatography.com/ilyes64/cheat-sheets/python-virtual-environments/
155159

@@ -193,5 +197,5 @@ deactivate
193197

194198
### Installing packages
195199
```bash
196-
pip install requests
197-
``` -->
200+
pip install transformers
201+
```

0 commit comments

Comments
 (0)