Tensorflow 支援使用 CPU 和 GPU 做運算:
"/cpu:0": The CPU of your machine."/gpu:0": The GPU of your machine, if you have one."/gpu:1": The second GPU of your machine, etc.
用 with tf.device() 來分配這個語句下使用的設備。
可以用以下設定來優化運算:
log_device_placement = True: 紀錄我們使用 device 的情況。allow_soft_placement = True: 避免指定的 device 不存在,讓他能自行分配到存在且可運行的地方。
我沒有多顆 CPU,其他的語法先不試。