Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabioz/optimuspy
Python Launcher with Optimus Enablement
https://github.com/fabioz/optimuspy
Last synced: about 17 hours ago
JSON representation
Python Launcher with Optimus Enablement
- Host: GitHub
- URL: https://github.com/fabioz/optimuspy
- Owner: fabioz
- License: mit
- Created: 2017-08-22T10:40:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-19T12:00:58.000Z (about 7 years ago)
- Last Synced: 2024-10-20T06:12:25.661Z (24 days ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# optimuspy
Python Launcher with Optimus Enablement and AMD equivalent
## Problem & Solution
I am using python for developing 3D applications and games. I have a dedicated GPU and an Intel HD Graphics 630. My applications run with the Intel HD Graphics 630 unless changed in the nVidia control panel.
I started googling then I found a solution how to programatically enable the dedicated graphics card. This problem only occurres on Optimus Systems. The solution is simple. An integer variable called _NvOptimusEnablement_ should be exported in order to enable the nVidia card.
Unfortunately exporting this variable from a python module **does not** give access to the dedicated graphics card. Some of the python modules are DLLs called PYD files. Importing pyd file with an exported _NvOptimusEnablement_ is not working properly.
The only solution I found so far is to create a python launcher that exports _NvOptimusEnablement_. From now on I am able to test my applications and games using the integrated and the dedicated graphics card as well.
Reference: [Optimus Rendering Policies](http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf)
## How does it work?
The entire source code is in the [optimuspy.cpp](optimuspy.cpp).
The program simply passes every argument to the Py_Main.To create a launcher for a specific application you can hardcode the parameters and add an icon using a resource file.
## Install
The [build.py](build.py) will detect the python installation and use the proper compiler arguments to create the optimuspy launcher.
Using the `--install` the `optimuspy.exe` will be placed next to the `python.exe`.
```batch
git clone https://github.com/cprogrammer1994/optimuspy
cd optimuspy
python build.py --install
```### Compile using gcc
```batch
python build.py --gcc --install
```## Sample
```batch
> python -m ModernGLModernGL: 4.1.11
Vendor: Intel
Renderer: Intel(R) HD Graphics 630
Version: 4.4.0 - Build 21.20.16.4541
``````batch
> optimuspy -m ModernGLModernGL: 4.1.11
Vendor: NVIDIA Corporation
Renderer: GeForce GTX 1050/PCIe/SSE2
Version: 4.5.0 NVIDIA 384.94
```