Code Monkey home page Code Monkey logo

gpuutils's Introduction

GpuUtils

Downloads

Working on a shared and distributed environment with multiple GPUs might be problematic. Advanced frameworks apply greedy approach and they tend to allocate all GPUs and all memory of your system. GpuUtils helps you to find the best GPU on your system to allocate. It also provides a gpu related information in a structure format.

Installation

The easiest way to install GpuUtils is to install it via PyPI.

pip install gpuutils

Analyzing system

Running nvidia-smi command in the command prompt allows users to monitor GPU related information such as memory and utilization. Herein, system analysis function loads GPU related information into a pandas data frame or json array.

from gpuutils import GpuUtils
df = GpuUtils.analyzeSystem() #this will return a pandas data frame
#dict = GpuUtils.analyzeSystem(pandas_format = False) #this will return a json array

Default configuration of system analysis returns a Pandas data frame.

gpu_index total_memories_in_mb available_memories_in_mb memory_usage_percentage utilizations power_usages_in_watts power_capacities_in_watts
1 32480 32469 0.0339 0 43 300
2 32480 32469 0.0339 0 43 300
3 32480 32469 0.0339 0 44 300
4 32480 32469 0.0339 0 43 300
5 32480 32469 0.0339 0 43 300
6 32480 32469 0.0339 0 43 300
7 32480 32469 0.0339 0 43 300
0 32480 31031 4.4612 7 56 300

Allocation

GpuUtils can allocate GPUs as well. Calling allocation function directly finds the available GPUs and allocate based on your demand.

from gpuutils import GpuUtils
GpuUtils.allocate() #this tries to allocate a GPU having 1GB memory
#GpuUtils.allocate(required_memory = 10000)
#GpuUtils.allocate(required_memory = 10000, gpu_count=1)

To avoid greedy approach

Advanced frameworks such as TensorFlow tend to allocate all memory. You can avoid this approach if you pass the framework argument in allocate function. In this way, the framework will use the gpu memory as much as needed. Currently, keras and tensorflow frameworks are supported in allocate function.

GpuUtils.allocate(framework = 'keras')

Support

There are many ways to support a project - starring⭐️ the GitHub repos is just one.

Licence

GpuUtils is licensed under the MIT License - see LICENSE for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.