Intel® Extension for TensorFlow* is compatible with stock TensorFlow*. This example uses the tutorial from tensorflow.org Classify text with BERT to show training on BERT model without changing the original code.
Installing the Intel® Extension for TensorFlow* in legacy running environment, TensorFlow will execute the training on Intel CPU and GPU.
No need any code change
Verified Hardware Platforms:
- Intel® Data Center GPU Max Series
- Intel CPU
Refer to Prepare
- Setup for GPU
./set_env_gpu.sh
- Setup for CPU
./set_env_cpu.sh
-
Enable oneAPI running environment (only for GPU) and virtual running environment.
-
For GPU, refer to Running
-
For CPU,
-
source env_itex_cpu/bin/activate
- Install the Python packages used in Classify text with BERT.
The Jupyter notebook script will install other required pacakges while it is running. So there's no need to pre-install them.
wget https://storage.googleapis.com/tensorflow_docs/text/docs/tutorials/classify_text_with_bert.ipynb
jupyter notebook --notebook-dir=./ --ip=0.0.0.0 --no-browser --allow-root &
...
http://xxx.xxx:8888/?token=f502f0715979ec73c571ca5676ba58431b916f5f58ee3333
Open the url:http://xxx.xxx:8888/?token=f502f0715979ec73c571ca5676ba58431b916f5f58ee3333 above in your web browser.
-
Open classify_text_with_bert.ipynb by Jupyter notebook.
-
Run the tutorial according to the description in the Jupyter notebook.
-
The TensorFlow will train and infer the BERT model on Intel CPU or GPU.
- The following error log is a known issue and it is not caused by Intel® Extension for TensorFlow*. This crash happens when the code is finished and tries to release resources. It doesn't impact the result of the Bert training and inference/test.
Traceback (most recent call last):
File "/home/xxx/xxx/env_itex/lib/python3.9/site-packages/tensorflow/python/training/tracking/util.py", line 174, in __del__
TypeError: 'NoneType' object is not callable