环境信息
- WSL2 (Ubuntu)
1
2
3
4
5
6# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
配置驱动
参考文章内的版本比较老旧,这里更新为当前最新版本。
安装工具集
1
$ sudo apt install -y gpg-agent wget
下载Intel仓库证书
1
$ sudo wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
配置仓库信息
1
2
3$ echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy/lts/2350 unified' | \
sudo tee /etc/apt/sources.list.d/intel.gpu.jammy.list
$ sudo apt update安装Intel工具
1
$ sudo apt install intel-opencl-icd intel-level-zero-gpu level-zero
配置OneAPI仓库
1
2
3
4Copied
$ wget -O - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo gpg --dearmor --output /usr/share/keyrings/oneapi-archive-keyring.gpg
$ echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
$ sudo apt update安装OneAPI支持库
1
$ sudo apt install intel-oneapi-runtime-dpcpp-cpp intel-oneapi-runtime-mkl
安装tensorflow扩展
1
$ pip install --upgrade intel-extension-for-tensorflow[gpu]
检验配置
如果有Intel(R) Level-Zero
字样,表示Keras可以识别Intel的GPU了。1
2
3
4
5$ python -c "import tensorflow"
... ...
2024-10-12 17:51:26.088761: I itex/core/wrapper/itex_gpu_wrapper.cc:35] Intel Extension for Tensorflow* GPU backend is loaded.
2024-10-12 17:51:26.209443: I itex/core/devices/gpu/itex_gpu_runtime.cc:129] Selected platform: Intel(R) Level-Zero
2024-10-12 17:51:26.209538: I itex/core/devices/gpu/itex_gpu_runtime.cc:154] number of sub-devices is zero, expose root device.