如何让 Google AI Platform 的 BASIC_GPU scale-tier 上的 GPU 对我的 tensorflow 程序可见?

How can I make a GPU on Google AI Platform's BASIC_GPU scale-tier visible to my tensorflow program?

我在 Google Cloud 的 AI 平台上获取我的代码 运行 以在我有 BASIC_GPU 规模层时查找和使用 GPU 时遇到问题。我没有本地GPU,所以一直无法测试是否可以在本地识别GPU。

我用下面的代码调用google的人工智能平台API:

gcloud ai-platform jobs submit training $JOB_NAME \
--job-dir $OUTPUT_PATH \
--runtime-version 1.13 \
--python-version 3.5 \
--package-path source/ \
--module-name source.train \
--region $REGION \
--scale-tier BASIC_GPU \
-- \

在我的训练代码中打印:

  tf.logging.info('Is GPU Available: ' + str(tf.test.is_gpu_available()))

并打印出:GPU 是否可用:False。

我正在尝试弄清楚如何让 TF 看到 GPU,以便我可以使用它来加快我的训练过程并充分利用 BASIC_GPU scale-tier。

谢谢!

在指定所需软件包的setup.py文件中,您需要将tensorflow-gpu添加到所需软件包列表中。

例如:setup.py 可能看起来像

from setuptools import find_packages
from setuptools import setup
import sys
sys.path.append('/source/')


REQUIRED_PACKAGES = ['tensorflow-gpu==1.13.1', 'matplotlib', 'ray', 'psutil', 'requests']

setup(
    name='source',
    version='0.1',
    install_requires=REQUIRED_PACKAGES,
    packages=find_packages(),
    include_package_data=True,
    description='Generic example trainer package.'
    )

如果不是 tensorflow-gpu==1.13.1 而是 tensorflow==1.13.1 它将没有正确的包,因此将无法找到 GPU。有一些版本的 tensorflow (1.15) 结合了 gpu 和非 gpu 版本,但对于那些它们仍然分开的版本,如果你打算使用 GPU,你需要确保你需要 gpu 版本。