From dev-return-5605-archive-asf-public=cust-asf.ponee.io@madlib.apache.org Wed Nov 6 23:20:53 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6BB15180668 for ; Thu, 7 Nov 2019 00:20:53 +0100 (CET) Received: (qmail 19528 invoked by uid 500); 6 Nov 2019 23:20:52 -0000 Mailing-List: contact dev-help@madlib.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@madlib.apache.org Delivered-To: mailing list dev@madlib.apache.org Received: (qmail 19420 invoked by uid 99); 6 Nov 2019 23:20:52 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Nov 2019 23:20:52 +0000 From: GitBox To: dev@madlib.apache.org Subject: [GitHub] [madlib] khannaekta commented on a change in pull request #455: DL: Add new helper function for gpu_configuration Message-ID: <157308245255.22517.15669379265024765362.gitbox@gitbox.apache.org> Date: Wed, 06 Nov 2019 23:20:52 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit khannaekta commented on a change in pull request #455: DL: Add new helper function for gpu_configuration URL: https://github.com/apache/madlib/pull/455#discussion_r343361133 ########## File path: src/ports/postgres/modules/deep_learning/madlib_keras_gpu_info.py_in ########## @@ -0,0 +1,203 @@ +# coding=utf-8 +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +@file madlib_keras_gpu_info.py_in + +@brief GPU configuration helper function + +@namespace madlib_keras_gpu_info +""" + +import plpy +from utilities.utilities import is_platform_pg +from utilities.utilities import unique_string +import subprocess +import os + +class OutputInfoSchema: + INFO_TABLE = unique_string(desp='gpu_info') + SEG_ID_COL = 'gp_seg_id' + GPU_DESCR_COL = 'gpu_descr' + + +class Source: + NVIDIA = 'nvidia' + TENSORFLOW = 'tensorflow' + + +class GPUInfoFunctions: + @staticmethod + def get_gpu_info_from_nvidia(): + """ + This function will run only on segment(s). Make sure not to run any non + select plpy execute. + :return: list of gpu descriptions as returned by nvidia-smi -L. + """ + try: + return subprocess.check_output(["nvidia-smi", "-L"]).splitlines() + except OSError: # Handle case when nvidia-smi is not found + return [] Review comment: I think in addition to returning an empty array, we should also add a warning, suggesting to use the function with tensorflow, else the user might not know if there are no GPUs attached to the hosts or if `nvidia-smi` was not found ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services