Reputation: 11
I need to use Adreno GPU for deep learning (TensorFlow, PyTorch) instead of Nvidia is there has anyone know how? I'm using Python what do I have to do I really have no idea. I also got the adreno_opencl_ml_sdk_v3.0
driver but I don't know how to use it.
# import pyopencl as cl
import pyopencl.cltypes
import pyopencl.array
import numpy as np
device = torch.device("opencl")
a = torch.tensor(\[1, 2, 3\], dtype=torch.float32).to("opencl")
b = torch.tensor(\[4, 5, 6\], dtype=torch.float32).to("opencl")
c = a + b
print(c)
This is the error:
RuntimeError: PyTorch is not linked with support for opencl devices
Upvotes: 1
Views: 549
Reputation: 1379
You can use DirectML to access the Adreno:
device_name = 'cuda' # 'cuda', 'cpu', 'mps', 'mkldnn', 'dml'
if device_name == 'dml':
# Use DML (DirectML) backend if available.
import torch_directml
device = torch_directml.device()
else:
device = torch.device(device_name)
Remember to pip install torch-directml.
The Adreno isn't very fast but it will save your battery life. I trained a pytorch model on a Qualcomm Snapdragon X Elite (12 core CPU) and Adreno (Surface Pro). The CPU ran 1.2 epochs/sec while the Adreno needed 2 epochs/second. The CPU was therefore almost double the speed. However, monitoring the power usage, I subtracted the discharge rate during the training from the baseline discharge rate using perfmon (battery discharge rate: I think the units are mW). The value fluctuates a bit -- noticeably the fans come on after a while with the CPU and that further increases the discharge rate. The following isn't very scientific but approximately:
Adreno used about 10 Watts.
CPU used about 30 Watts.
So not quite 3x the energy usage. If you can plug in, use the CPU. If you're training on a plane flight, use the GPU.
Upvotes: 0