Spaces:
Runtime error
Runtime error
File size: 6,314 Bytes
6ecf14b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# Part 1 - Environment creation
[back](../README.md)
## Step 1: Install and Run Jupyter Lab locally
First we need to install python in our computer , in this demo I will use Python **3.10.11**
[https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe](https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe)
During the installation I should suggest add **python.exe to PATH** and **install Now**

With Python already installed, you should have pip already installed. Be sure to use a pip that corresponds with Python 3 by using pip3 or checking your pip executable with "pip --version".
## Step 2: Create a Python virtual environment
A Python virtual environment allows one to use different versions of Python as well as isolate dependencies between projects. If you've never had several repos on your machine at once, you may never have felt this need but it's a good, Pythonic choice nonetheless. Future you will thank us both!
Let us create a folder called gpt and there we will store our virtual environment.
```
mkdir gpt
cd gpt
```

Supposed that you have a different version of Python installed in your system. To check use the following command to check:
```
py --list
```

And you want to create a new virtual environment for python 3.10 on a 'test_env' directory. Run the following command:
```py
py -3.10 -m venv my_venv
```
You'll notice a new directory in your current working directory with the same name as your virtual environment.
Activate the virtual environment.
Windows:
```
cd C:\gpt
my_venv\Scripts\activate.bat
```

All other OSs: source
```
./my_venv/bin/activate
```
When the virtual environment is activated, your command prompt should change in some way, indicating the name of the virtual environment. This is how you'll know it's active. You can further verify this by executing "which pip" or "which python" to see that both binaries are located inside you virtual environment directory.
A virtual environment is only activate in your current terminal session. There is no need to deactivate it before closing your terminal.
However, if you need to deactivate it you can do so by executing "deactivate", a script that only exists when a virtual environment is activated.
Note: Be sure to deactivate a virtual environment before deleting its directory.
### Step 3: Create a Jupyter Kernel from Inside your Virtual Environment
We are goigng to install **Jupyter Lab.**
Let us open our command prompt and type
```
python.exe -m pip install --upgrade pip
```
```
pip install jupyterlab
```
For more information visit the official [Jupyter Lab](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html#pip) site.
A Jupyter "kernel" is simply a reference to a particular Python interpreter instance. You can create a kernel from any Python interpreter on your machine, including those inside of virtual environments and then choose it as your kernel for any notebook. In this way, you can customize the environments of different notebooks benefiting from the same isolation virtual environments offer during normal development.
Once we are in our environment we proceed to install ipykernel
```
pip install ipykernel
```

then
```
python -m ipykernel install --user --name gpt --display-name "Python3 (GPT)"
```

With your virtual environment created and the ability to run a Jupyter Notebook in that environment.
## Install and import the dependecies
You can copy the following code block and paste it on your terminal where you are in your enviroment.
```
pip install datasets
pip install scikit-learn
pip install chromadb==0.3.27
pip install sentence_transformers
pip install pandas
pip install rouge_score
pip install nltk
pip install "ibm-watson-machine-learning>=1.0.312"
pip install ipywidgets widgetsnbextension pandas-profiling
pip install mlxtend
pip install sentence-transformers
pip install tiktoken
pip install openai
```

If we are in Linux we can add the followig condition after each line `| tail -n 1` to surpress logs.
If we have a computer with GPUs we can install p
```
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
```
Before run the notebook, we require load our IBM cloud services.
# Step 5 - Login to IBM cloud

after you have logged, create a WatsonX instance
[https://www.ibm.com/watsonx](https://www.ibm.com/watsonx)

Then open a simple Prompt Lab

Then click **View Code** and then click on **Create personal API key**

then we create our custom GPT API, I call it gpt and I give an small description

I copy the API key for future use

## Creation of shortcuts
Once we have created our enviroments we need to load it during the the Stages:
2-Data creation
3-Modeling
For windows let us create .bat file called env.bat
```
C:\gpt\my_venv\Scripts\activate
```
then to load you simply type
```
enb.bat
```
For unix systems create .sh file called env.sh
```
gpt/my_venv/bin/activate
```
you type
```
sh env.sh
```
then type
```
jupyter lab
```

Now we are ready to start working. Let us go to the Next step [2-Data.](../2-Data/README.md)
|