Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.1%) to scientific vocabulary
Keywords
Repository
A Highlevel Python Wrapper for Vulkan's Compute API
Statistics
- Stars: 17
- Watchers: 3
- Forks: 4
- Open Issues: 7
- Releases: 7
Topics
Metadata Files
README.md
Lava
Lava allows leveraging Vulkan compute shaders from Python in an easy manner without writing any C++. Like CUDA kernels, Vulkan compute shaders can be used to move heavy computation into the GPU. For most use cases Lava will expect and return numpy arrays. Overall, Lava is similar to PyCuda or PyOpenCL.
Installation
pip install lava
The Vulkan SDK needs to be installed and its environment variables need to be set. See the LunarG guide for Linux and Windows.
See release 0.4.0 for some older Vulkan SDK versions which are no longer available on the LunarG download page.
Support
Sofar lava was tested on:
* Nvidia Tesla V100, Ubuntu 18.04 + Nvidia 415 (✓ works)
* Nvidia 1080 GTX, Ubuntu 18.04 + Nvidia 415 (✓ works)
* Nvidia 1080 GTX, Ubuntu 18.04 + Nvidia 396 (✗ does not work, driver issue)
* Nvidia 1080 GTX, Windows 10 (✓ works)
* Intel HD, Ubuntu 18.04 + Mesa (✓ works)
Features
- Automatic memory alignment and parsing of arbitrary complex block interfaces
- Supported: scalars (int, uint, float, double), vectors, matrices, multidimensional arrays and structs
- Partially supported: bool
- Not supported: dynamic arrays
- Further supported: ssbo's and ubo's, std140 and std430 layouts
- Multidimensional arrays of scalars, vectors or matrices are expected and parsed as respective numpy arrays
- CPU, GPU and staged buffers
- Intuitive shader execution
- Block definitions are parsed from the compiled shader bytecode
- Buffers are bound with a single line of code
- Buffers and shaders are checked for compatibility, other sanity checks are performed
Example
Below is the lava version of Erkaman's vulkan minimal compute:
```python import cv2 as cv import lava as lv import numpy as np
start session on first device
session = lv.Session(lv.devices()[0])
compile glsl code
shaderpath = "shader.comp" shader = lv.Shader(session, lv.compileglsl(shader_path))
allocate buffer and take its definition from the shader (see glsl: float[HEIGHT][WIDTH][3] imageData)
bufferout = lv.StagedBuffer.fromshader(session, shader, binding=0)
compute minimum amount of work groups
workgroupsize = 32 x = int(3200 / float(workgroupsize) + 0.5) y = int(2400 / float(workgroupsize) + 0.5) z = 1
bind buffer to binding 0 (see glsl: layout(std430, binding = 0) buffer buf)
stage = lv.Stage(shader, {0: bufferout}) stage.record(x, y, z) stage.runand_wait()
retrieve output as numpy array
im = buffer_out["imageData"]
cv.imwrite("mandelbrot.png", np.around(255 * im).astype(np.uint8)) ```
```glsl
version 450
extension GLARBseparateshaderobjects : enable
define WIDTH 3200
define HEIGHT 2400
define WORKGROUP_SIZE 32
layout ( localsizex = WORKGROUPSIZE, localsizey = WORKGROUPSIZE, localsizez = 1 ) in;
layout(std430, binding = 0) buffer buf { float[HEIGHT][WIDTH][3] imageData; };
void main() { if(glGlobalInvocationID.x >= WIDTH || glGlobalInvocationID.y >= HEIGHT) return;
float x = float(glGlobalInvocationID.x) / float(WIDTH); float y = float(glGlobalInvocationID.y) / float(HEIGHT);
vec2 uv = vec2(x, y); float n = 0.0; vec2 c = vec2(-.445, 0.0) + (uv - 0.5) * (2.0 + 1.7 * 0.2), z = vec2(0.0); const int M = 128; for (int i = 0; i < M; i++) { z = vec2(z.x * z.x - z.y * z.y, 2. * z.x * z.y) + c; if (dot(z, z) > 2) break; n++; }
float t = float(n) / float(M); vec3 d = vec3(0.3, 0.3 ,0.5); vec3 e = vec3(-0.2, -0.3 ,-0.5); vec3 f = vec3(2.1, 2.0, 3.0); vec3 g = vec3(0.0, 0.1, 0.0); vec3 color = d + e * cos( 6.28318 * (f * t + g) );
int xIndex = int(glGlobalInvocationID.x); int yIndex = int(glGlobalInvocationID.y); imageData[yIndex][xIndex][0] = color.r; imageData[yIndex][xIndex][1] = color.g; imageData[yIndex][xIndex][2] = color.b; } ```
Owner
- Name: Jonas Schuepfer
- Login: osanj
- Kind: user
- Location: Munich
- Website: https://osanj.github.io/
- Repositories: 4
- Profile: https://github.com/osanj
GitHub Events
Total
- Watch event: 2
- Pull request event: 1
Last Year
- Watch event: 2
- Pull request event: 1
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jonas Schuepfer | j****r@g****m | 90 |
| Jonas Schuepfer | 7****j | 4 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 13
- Total pull requests: 13
- Average time to close issues: 14 days
- Average time to close pull requests: about 5 hours
- Total issue authors: 2
- Total pull request authors: 3
- Average comments per issue: 1.46
- Average comments per pull request: 0.0
- Merged pull requests: 9
- Bot issues: 0
- Bot pull requests: 3
Past Year
- Issues: 0
- Pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 2
Top Authors
Issue Authors
- osanj (12)
- gregc-91 (1)
Pull Request Authors
- osanj (9)
- dependabot[bot] (3)
- KurniawanZATY (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 177 last-month
- Total dependent packages: 0
- Total dependent repositories: 4
- Total versions: 7
- Total maintainers: 1
pypi.org: lava
Highlevel Wrapper for Vulkan's Compute API
- Homepage: https://github.com/osanj/lava
- Documentation: https://lava.readthedocs.io/
-
Latest release: 0.4.1
published over 5 years ago
Rankings
Maintainers (1)
Dependencies
- cffi ==1.11.5
- future ==0.17.1
- numpy ==1.16.3
- pycparser ==2.19
- pytest ==5.1.0
- pytest-cov ==2.7.1
- vulkan ==1.1.99.1
- vulkan *