code: def set_num_gpus(num_gpus):
      """
      Set the number of GPUs to use whenever applicable. Currently TuriCreate
      supports using all CPUs or one GPU.
  
      This can also be set by adding the following line to your
      ``~/.turicreate/config`` file, e.g.:
  
      ```
      num_gpus: 1
      ```
  
      Calling this function will override whatever you define in your config
      file.
  
      Parameters
      ----------
      num_gpus : int
          To always use CPUs, set to 0. To use a GPU, set to 1.
  
      See also
      --------
      get_num_gpus
  
      Examples
      --------
      .. sourcecode:: python
  
        >> turicreate.config.set_num_gpus(1)
        >> turicreate.image_classifier.create(data, target='label')
      """
      # Currently TuriCreate only supports using one GPU. See:
      # https://github.com/apple/turicreate/issues/2797
      # If `num_gpus` is a value other than 0 or 1, print a warning.
      if num_gpus < -1:
          raise ValueError("'num_gpus' must be either 0 or 1.")
      elif num_gpus == -1:
          print(
              "TuriCreate currently only supports using one GPU. Setting 'num_gpus' to 1."
          )
          num_gpus = 1
      elif num_gpus >= 2:
          print(
              "TuriCreate currently only supports using one GPU. Setting 'num_gpus' to 1."
          )
          num_gpus = 1
  
      set_runtime_config("TURI_NUM_GPUS", num_gpus)
  
file_path: turicreate/src/python/turicreate/config/__init__.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import sys
  import tempfile
  import os
  import time
  import re
label_desc: Use image node_id 3 for calling a global function with example usage: set_num_gpus(num_gpus) without return types