-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7d69ac9
Showing
13 changed files
with
1,006 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.18.1 | ||
|
||
- name: Lint | ||
run: make fmt-check lint-check | ||
|
||
- name: Build | ||
run: make build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.18.1 | ||
|
||
- name: Build release binaries | ||
run: make release | ||
|
||
- name: Release to GitHub | ||
uses: skx/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
args: 'bin/release/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
run: | ||
# We don't use generics so we can enable all the linters that don't work with Go 1.18. | ||
go: '1.17' | ||
|
||
linters-settings: | ||
dupl: | ||
threshold: 100 | ||
exhaustive: | ||
default-signifies-exhaustive: true | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
gocyclo: | ||
min-complexity: 15 | ||
goimports: | ||
local-prefixes: github.com/kylrth/gpublame | ||
gomnd: | ||
settings: | ||
mnd: | ||
# don't include the "operation" and "assign" | ||
checks: argument,case,condition,return | ||
govet: | ||
check-shadowing: true | ||
enable-all: true | ||
lll: | ||
line-length: 100 | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-unused: false | ||
allow-leading-space: false | ||
require-explanation: true | ||
require-specific: true | ||
|
||
issues: | ||
exclude-rules: | ||
# no gomnd on test files | ||
- path: _test\.go | ||
linters: | ||
- gomnd | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- containedctx | ||
- contextcheck | ||
- cyclop | ||
- deadcode | ||
- decorder | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- durationcheck | ||
- errcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- forcetypeassert | ||
- funlen | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- godot | ||
- godox | ||
- gofmt | ||
- gofumpt | ||
- goimports | ||
- gomoddirectives | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- grouper | ||
- govet | ||
- ifshort | ||
- importas | ||
- ineffassign | ||
- ireturn | ||
- lll | ||
- maintidx | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- paralleltest | ||
- prealloc | ||
- predeclared | ||
- promlinter | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- tagliatelle | ||
- tenv | ||
- testpackage | ||
- thelper | ||
- tparallel | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- wastedassign | ||
- whitespace | ||
- wsl | ||
# not enabled: | ||
# - exhaustivestruct # This doesn't make sense to check for in most cases. | ||
# - forbidigo # nothing to forbid | ||
# - gci # prefer goimports | ||
# - gochecknoglobals # I don't think globals should be universally disallowed. | ||
# - gochecknoinits # I don't think init should be universally disallowed. | ||
# - goerr113 # I think it's ok to include info in errors without defining a new type. | ||
# - goheader # no need for a header | ||
# - golint # deprecated | ||
# - gomnd # prefer goconst | ||
# - interfacer # deprecated | ||
# - maligned # deprecated | ||
# - scopelint # deprecated | ||
# - varnamelen # I don't think this matters. | ||
# - wrapcheck # I think this should only happen for public functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Kyle Roth | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
all: fmt-check lint-check build | ||
|
||
BINDIR := bin | ||
|
||
LINTER_VERSION := 1.45.2 | ||
LINTER := $(BINDIR)/golangci-lint_$(LINTER_VERSION) | ||
DEV_OS := $(shell uname -s | tr A-Z a-z) | ||
|
||
$(LINTER): | ||
mkdir -p $(BINDIR) | ||
wget "https://github.com/golangci/golangci-lint/releases/download/v$(LINTER_VERSION)/golangci-lint-$(LINTER_VERSION)-$(DEV_OS)-amd64.tar.gz" -O - \ | ||
| tar -xz -C $(BINDIR) --strip-components=1 --exclude=README.md --exclude=LICENSE | ||
mv $(BINDIR)/golangci-lint $(LINTER) | ||
|
||
.PHONY: fmt-check | ||
fmt-check: | ||
BADFILES=$$(gofmt -l -s -d $$(find . -type f -name '*.go')) && [ -z "$$BADFILES" ] && exit 0 | ||
|
||
.PHONY: lint-check | ||
lint-check: $(LINTER) | ||
$(LINTER) run --deadline=2m | ||
|
||
## DEBUG BUILDS | ||
|
||
GO_FILES = $(shell find . -type f -name '*.go') | ||
|
||
$(BINDIR)/gpublame: $(GO_FILES) | ||
mkdir -p $(BINDIR) | ||
go build -o $(BINDIR)/gpublame ./cmd | ||
|
||
.PHONY: build | ||
build: $(BINDIR)/gpublame | ||
|
||
## RELEASE BUILDS | ||
|
||
RELEASEDIR := $(BINDIR)/release | ||
ARCHES := amd64 arm arm64 | ||
|
||
# This rule expects targets with the format $(RELEASEDIR)/gpublame-GOARCH | ||
$(RELEASEDIR)/gpublame-%: $(GO_FILES) | ||
mkdir -p $(RELEASEDIR) | ||
GOARCH=$(word 2,$(subst -, ,$@)) \ | ||
go build -o $@ -ldflags "-s -w" ./cmd | ||
|
||
.PHONY: release | ||
release: $(foreach arch,$(ARCHES),$(RELEASEDIR)/gpublame-$(arch)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# gpublame | ||
|
||
Want to find out who's hogging the GPU? `gpublame` gives you the proof you need to duke it out in the research group chat. | ||
|
||
`gpublame` depends on `nvidia-smi pmon`, which means monitoring is limited to a maximum of 4 devices. You should be able to use `CUDA_VISIBLE_DEVICES` to select which devices to show. If someone with more than 4 GPUs would like to help me test code to support more than 4 devices, please reach out. :) | ||
|
||
## installation | ||
|
||
Go to [Releases](https://github.com/kylrth/gpublame/releases) and download the latest release for your architecture to somewhere on your PATH, e.g.: | ||
|
||
```sh | ||
wget 'https://github.com/kylrth/gpublame/releases/latest/download/gpublame-amd64' -O - | sudo tee /usr/bin/gpublame > /dev/null | ||
sudo chmod +x /usr/bin/gpublame | ||
``` | ||
|
||
Let me know if I don't build for your architecture so I can add it. | ||
|
||
## usage | ||
|
||
```sh | ||
gpublame | ||
``` | ||
|
||
Pretty simple. | ||
|
||
### package usage | ||
|
||
You can use some `gpublame` functionality in your own Go code: | ||
|
||
```go | ||
import ( | ||
"context" | ||
|
||
"github.com/kylrth/gpublame" | ||
) | ||
|
||
func main() { | ||
gpublame.Pmon(context.Background()) | ||
|
||
// ... | ||
} | ||
``` |
Oops, something went wrong.