Training a simple model in Tensorflow GPU slower than CPU

前端 未结 2 1908
情书的邮戳
情书的邮戳 2021-02-15 10:58

I have set up a simple linear regression problem in Tensorflow, and have created simple conda environments using Tensorflow CPU and GPU both in 1.13.1 (using CUDA 10.0 in the ba

2条回答
  •  Happy的楠姐
    2021-02-15 11:27

    Select your Device using tf.device()

    with tf.device('/cpu:0'):
        #enter code here of tf data
    

    On a typical system, there are multiple computing devices. In TensorFlow, the supported device types are CPU and GPU. They are represented as strings. For example:

    "/cpu:0": The CPU of your machine.
    "/device:GPU:0": The GPU of your machine, if you have one.
    "/device:GPU:1": The second GPU of your machine, etc.
    

    GPU:

    with tf.device('/device:GPU:0'):
      #code here: tf data and model
    

    Reference: Link

提交回复
热议问题