|
||||
0001 #!/usr/bin/env bash 0002 0003 # 0004 # Licensed to the Apache Software Foundation (ASF) under one or more 0005 # contributor license agreements. See the NOTICE file distributed with 0006 # this work for additional information regarding copyright ownership. 0007 # The ASF licenses this file to You under the Apache License, Version 2.0 0008 # (the "License"); you may not use this file except in compliance with 0009 # the License. You may obtain a copy of the License at 0010 # 0011 # http://www.apache.org/licenses/LICENSE-2.0 0012 # 0013 # Unless required by applicable law or agreed to in writing, software 0014 # distributed under the License is distributed on an "AS IS" BASIS, 0015 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0016 # See the License for the specific language governing permissions and 0017 # limitations under the License. 0018 # 0019 0020 # This script is a basic example script to get resource information about NVIDIA GPUs. 0021 # It assumes the drivers are properly installed and the nvidia-smi command is available. 0022 # It is not guaranteed to work on all setups so please test and customize as needed 0023 # for your environment. It can be passed into SPARK via the config 0024 # spark.{driver/executor}.resource.gpu.discoveryScript to allow the driver or executor to discover 0025 # the GPUs it was allocated. It assumes you are running within an isolated container where the 0026 # GPUs are allocated exclusively to that driver or executor. 0027 # It outputs a JSON formatted string that is expected by the 0028 # spark.{driver/executor}.resource.gpu.discoveryScript config. 0029 # 0030 # Example output: {"name": "gpu", "addresses":["0","1","2","3","4","5","6","7"]} 0031 0032 ADDRS=`nvidia-smi --query-gpu=index --format=csv,noheader | sed -e ':a' -e 'N' -e'$!ba' -e 's/\n/","/g'` 0033 echo {\"name\": \"gpu\", \"addresses\":[\"$ADDRS\"]}
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |