Skip to content

Commit 213c0b7

Browse files
krzeszewPosiadacz07Marina-Zubova
authored
Upadte readme IntelPython_Numpy_Numba_dpex_kNN (#2385)
* Upadte readme: new AI template and IDP offline installer * Apply suggestions from code review Co-authored-by: Marina Zubova <[email protected]> * Applying PR comments --------- Co-authored-by: Urszula Guminska <[email protected]> Co-authored-by: Marina Zubova <[email protected]>
1 parent c17d251 commit 213c0b7

File tree

1 file changed

+81
-100
lines changed
  • AI-and-Analytics/Features-and-Functionality/IntelPython_Numpy_Numba_dpex_kNN

1 file changed

+81
-100
lines changed
Lines changed: 81 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# `Intel® Python NumPy vs numba-dpex` Sample
1+
# `Intel® Python: NumPy vs numba-dpex` Sample
22

3-
The `Intel® Python NumPy vs numba-dpex` sample shows how to achieve the same accuracy of the k-NN model classification while using NumPy, Numba, and Data-parallel Extension for Numba* (numba-dpex).
3+
The `Intel® Python: NumPy vs numba-dpex` sample shows how to achieve the same accuracy of the k-NN model classification while using NumPy*, Numba*, and Data Parallel Extension for Numba* (numba-dpex).
44

5-
| Area | Description
5+
| Property | Description
66
| :--- | :---
7-
| What you will learn | How to program using the Data-parallel Extension for Numba* (numba-dpex)
8-
| Time to complete | 5 minutes
97
| Category | Code Optimization
8+
| What you will learn | How to program using the Data Parallel Extension for Numba* (numba-dpex)
9+
| Time to complete | 5 minutes
1010

11-
>**Note**: The libraries used in this sample are available in Intel® Distribution for Python* as part of the [Intel® AI Analytics Toolkit (AI Kit)](https://software.intel.com/en-us/oneapi/ai-kit).
11+
>**Note**: This sample is validated on Intel® Distribution for Python* Offline Installer and AI Tools Offline Installer. For the full list of validated platforms refer to [Platform Validation](https://github.com/oneapi-src/oneAPI-samples/tree/master?tab=readme-ov-file#platform-validation).
1212
1313
## Purpose
1414

@@ -20,109 +20,82 @@ In this sample, you will run a k-nearest neighbors algorithm using 3 different I
2020
|:--- |:---
2121
| OS | Ubuntu* 20.04
2222
| Hardware | CPU
23-
| Software | Intel® AI Analytics Toolkit (AI Kit)
23+
| Software | Intel® Distribution for Python*
2424

25-
### For Local Development Environments
25+
## Key Implementation Details
2626

27-
You will need to download and install the following toolkits, tools, and components to use the sample.
27+
This sample code is implemented for the CPU using Python. The sample assumes you have numba-dpex installed inside a Conda environment, similar to what is installed with the Intel® Distribution for Python*.
2828

29-
- **Intel® AI Analytics Toolkit (AI Kit)**
29+
The sample tutorial contains one Jupyter Notebook and one Python script. You can use either.
3030

31-
You can get the AI Kit from [Intel® oneAPI Toolkits](https://www.intel.com/content/www/us/en/developer/tools/oneapi/toolkits.html#analytics-kit). <br> See [*Get Started with the Intel® AI Analytics Toolkit for Linux**](https://www.intel.com/content/www/us/en/develop/documentation/get-started-with-ai-linux) for AI Kit installation information and post-installation steps and scripts.
31+
## Environment Setup
32+
You will need to download and install the following toolkits to use the sample.
33+
<!-- Use numbered steps instead of subheadings -->
3234

33-
- **Jupyter Notebook**
35+
**1. Get Intel® Distribution for Python***
3436

35-
Install using PIP: `$pip install notebook`. <br> Alternatively, see [*Installing Jupyter*](https://jupyter.org/install) for detailed installation instructions.
37+
If you have not already, install Intel® Distribution for Python* via [Installer](https://www.intel.com/content/www/us/en/developer/tools/oneapi/distribution-python-download.html?operatingsystem=linux&linux-install-type=offline).
3638

37-
### For Intel® DevCloud
39+
**2. Activate the Intel® Distribution for Python\* base environment**
40+
<!-- this step is from AI Tools GSG, please don't modify unless GSG is updated -->
41+
If the default path is used during the installation of Intel® Distribution for Python*:
42+
```
43+
source $HOME/intelpython3/bin/activate
44+
```
45+
If a non-default path is used:
46+
```
47+
source <custom_path>/bin/activate
48+
```
3849

39-
The necessary tools and components are already installed in the environment. You do not need to install additional components. See [Intel® DevCloud for oneAPI](https://devcloud.intel.com/oneapi/get_started/) for information.
50+
**3. Clone the GitHub repository**
51+
<!-- for oneapi-samples: git clone https://github.com/oneapi-src/oneAPI-samples.git
52+
cd oneAPI-samples/AI-and-Analytics/<samples-folder>/<individual-sample-folder> -->
53+
<!-- for migrated samples - provide git clone command for individual repo and cd to sample dir -->
54+
```
55+
git clone https://github.com/oneapi-src/oneAPI-samples.git
56+
cd oneAPI-samples/AI-and-Analytics/Features-and-Functionality/IntelPython_Numpy_Numba_dpex_kNN
57+
```
4058

41-
## Key Implementation Details
59+
**4. Install dependencies**
60+
<!-- It is required to have requirement.txt file in sample dir. It should list additional libraries, such as matplotlib, ipykernel etc. -->
61+
>**Note**: Before running the following commands, make sure your Conda environment is activated
4262
43-
This sample code is implemented for the CPU using Python. The sample assumes you have numba-dpex installed inside a Conda environment, similar to what is installed with the Intel® Distribution for Python*.
63+
```
64+
pip install ipykernel
65+
pip install notebook
66+
```
67+
For Jupyter Notebook, refer to [Installing Jupyter](https://jupyter.org/install) for detailed installation instructions.
68+
69+
## Run the Sample
70+
>**Note**: Before running the sample, make sure [Environment Setup](https://github.com/oneapi-src/oneAPI-samples/tree/master/AI-and-Analytics/Features-and-Functionality/IntelPython_Numpy_Numba_dpex_kNN#environment-setup) is completed.
4471
45-
>**Note**: Read *[Get Started with the Intel® AI Analytics Toolkit for Linux*](https://www.intel.com/content/www/us/en/develop/documentation/get-started-with-ai-linux/top.html)* to find out how you can achieve performance gains for popular deep-learning and machine-learning frameworks through Intel optimizations.
46-
47-
## Run the `Intel® Python NumPy vs numba-dpex` Sample
48-
49-
### On Linux*
50-
51-
> **Note**: If you have not already done so, set up your CLI
52-
> environment by sourcing the `setvars` script in the root of your oneAPI installation.
53-
>
54-
> Linux*:
55-
> - For system wide installations: `. /opt/intel/oneapi/setvars.sh`
56-
> - For private installations: ` . ~/intel/oneapi/setvars.sh`
57-
> - For non-POSIX shells, like csh, use the following command: `bash -c 'source <install-dir>/setvars.sh ; exec csh'`
58-
>
59-
> For more information on configuring environment variables, see *[Use the setvars Script with Linux* or macOS*](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup/use-the-setvars-script-with-linux-or-macos.html)*.
60-
61-
#### Activate Conda
62-
63-
1. Activate the Conda environment.
64-
```
65-
conda activate base
66-
```
67-
By default, the AI Kit is installed in the `/opt/intel/oneapi` folder and requires root privileges to manage it.
68-
69-
You can choose to activate Conda environment without root access. To bypass root access to manage your Conda environment, clone and activate your desired Conda environment using the following commands similar to the following.
70-
71-
```
72-
conda create --name usr_base --clone base
73-
conda activate usr_base
74-
```
75-
76-
#### Run the Python Script
77-
78-
1. Change to the sample directory.
79-
2. Run the script.
80-
```
81-
python IntelPython_Numpy_Numba_dpex_kNN.py
82-
```
83-
84-
#### Run the Jupyter Notebook (Optional)
85-
86-
1. Launch Jupyter Notebook.
87-
```
88-
jupyter notebook --ip=0.0.0.0
89-
```
90-
2. Follow the instructions to open the URL with the token in your browser.
91-
3. Locate and select the Notebook.
92-
```
93-
IntelPython_Numpy_Numba_dpex_kNN.ipynb
94-
```
95-
4. Run every cell in the Notebook in sequence.
96-
97-
#### Troubleshooting
98-
99-
If you receive an error message, troubleshoot the problem using the **Diagnostics Utility for Intel® oneAPI Toolkits**. The diagnostic utility provides configuration and system checks to help find missing dependencies, permissions errors, and other issues. See the [Diagnostics Utility for Intel® oneAPI Toolkits User Guide](https://www.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html) for more information on using the utility.
100-
101-
### Build and Run the Sample on Intel® DevCloud (Optional)
102-
103-
>**Note**: For more information on using Intel® DevCloud, see the Intel® oneAPI [Get Started](https://devcloud.intel.com/oneapi/get_started/) page.
104-
105-
1. Open a terminal on a Linux* system.
106-
2. Log in to the Intel® DevCloud.
107-
```
108-
ssh devcloud
109-
```
110-
3. If the sample is not already available, download the samples from GitHub.
111-
```
112-
git clone https://github.com/oneapi-src/oneAPI-samples.git
113-
```
114-
4. Change to the sample directory.
115-
5. Launch Jupyter Notebook.
116-
6. Locate and select the Notebook.
117-
```
118-
IntelPython_Numpy_Numba_dpex_kNN.ipynb
119-
```
120-
7. Run every cell in the Notebook in sequence.
121-
8. Review the output.
122-
9. Disconnect from Intel® DevCloud.
123-
```
124-
exit
125-
```
72+
### Intel® Distribution for Python* Offline Installer (Validated)
73+
74+
**1. Register Conda kernel to Jupyter Notebook kernel**
75+
76+
If the default path is used during the installation of Intel® Distribution for Python*:
77+
```
78+
$HOME/intelpython3/bin/python -m ipykernel install --user --name=base
79+
```
80+
If a non-default path is used:
81+
```
82+
<custom_path>/bin/python -m ipykernel install --user --name=base
83+
```
84+
**2. Launch Jupyter Notebook**
85+
<!-- add other flags to jupyter notebook command if needed, such as port 8888 or allow-root -->
86+
```
87+
jupyter notebook --ip=0.0.0.0
88+
```
89+
**3. Follow the instructions to open the URL with the token in your browser**
90+
91+
**4. Select the Notebook**
92+
<!-- add sample file name -->
93+
```
94+
IntelPython_Numpy_Numba_dpex_kNN.ipynb
95+
```
96+
**5. Change the kernel to `base`**
97+
<!-- specify relevant kernel name(s), for example `pytorch` -->
98+
**6. Run every cell in the Notebook in sequence**
12699

127100
## Example Output
128101

@@ -136,9 +109,17 @@ Numba_dpex accuracy 0.7222222222222222
136109
[CODE_SAMPLE_COMPLETED_SUCCESFULLY]
137110
```
138111

112+
## Related Samples
113+
114+
* [Get Started with the Intel® Distribution for Python*](https://www.intel.com/content/www/us/en/developer/articles/technical/get-started-with-intel-distribution-for-python.html)
115+
* [`Genetic Algorithms on GPU using Intel® Distribution for Python* numba-dpex` Sample](https://github.com/oneapi-src/AI-and-Analytics/Features-and-Functionality/IntelPython_GPU_numba-dpex_Genetic_Algorithm/README.md)
139116
## License
140117

141-
Code samples are licensed under the MIT license. See [License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt)
118+
Code samples are licensed under the MIT license. See
119+
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt)
142120
for details.
143121

144-
Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt).
122+
Third party program Licenses can be found here:
123+
[third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt)
124+
125+
*Other names and brands may be claimed as the property of others. [Trademarks](https://www.intel.com/content/www/us/en/legal/trademarks.html)

0 commit comments

Comments
 (0)