In [1]:
sc


Out[1]:
<pyspark.context.SparkContext at 0x7fd8f4a766d0>

In [2]:
from tensorflow.python.client import device_lib

In [3]:
dl = device_lib.list_local_devices()

In [4]:
dl


Out[4]:
[name: "/cpu:0"
 device_type: "CPU"
 memory_limit: 268435456
 locality {
 }
 incarnation: 18352378554694701109, name: "/gpu:0"
 device_type: "GPU"
 memory_limit: 145358848
 locality {
   bus_id: 1
 }
 incarnation: 3909662228664244928
 physical_device_desc: "device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0"]

In [16]:
cpu = dl[0]

In [17]:
print cpu.name
print cpu.device_type


/cpu:0
CPU

In [18]:
gpu = dl[1]

In [19]:
print gpu.name
print gpu.device_type


/gpu:0
GPU