Skip to content

Commit c4cabc3

Browse files
authored
Merge pull request #137 from NVIDIA/main-new-layout
Patch 12.6.1
2 parents 35d06bc + 470f667 commit c4cabc3

File tree

151 files changed

+105159
-103985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+105159
-103985
lines changed

.gitignore

+24-24
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ __pycache__/
1111
.pytest_cache/
1212
.benchmarks/
1313
*.cpp
14-
!cuda/_lib/param_packer.cpp
15-
!cuda/_cuda/loader.cpp
14+
!cuda/cuda/bindings/_lib/param_packer.cpp
15+
!cuda/cuda/bindings/_bindings/loader.cpp
1616

1717
# CUDA Python specific (auto-generated)
18-
cuda/_cuda/ccuda.pxd
19-
cuda/_cuda/ccuda.pyx
20-
cuda/_cuda/cnvrtc.pxd
21-
cuda/_cuda/cnvrtc.pyx
22-
cuda/_lib/ccudart/ccudart.pxd
23-
cuda/_lib/ccudart/ccudart.pyx
24-
cuda/_lib/ccudart/utils.pxd
25-
cuda/_lib/ccudart/utils.pyx
26-
cuda/_lib/utils.pxd
27-
cuda/_lib/utils.pyx
28-
cuda/ccuda.pxd
29-
cuda/ccuda.pyx
30-
cuda/ccudart.pxd
31-
cuda/ccudart.pyx
32-
cuda/cnvrtc.pxd
33-
cuda/cnvrtc.pyx
34-
cuda/cuda.pxd
35-
cuda/cuda.pyx
36-
cuda/cudart.pxd
37-
cuda/cudart.pyx
38-
cuda/nvrtc.pxd
39-
cuda/nvrtc.pyx
18+
cuda/cuda/bindings/_bindings/cydriver.pxd
19+
cuda/cuda/bindings/_bindings/cydriver.pyx
20+
cuda/cuda/bindings/_bindings/cynvrtc.pxd
21+
cuda/cuda/bindings/_bindings/cynvrtc.pyx
22+
cuda/cuda/bindings/_lib/cyruntime/cyruntime.pxd
23+
cuda/cuda/bindings/_lib/cyruntime/cyruntime.pyx
24+
cuda/cuda/bindings/_lib/cyruntime/utils.pxd
25+
cuda/cuda/bindings/_lib/cyruntime/utils.pyx
26+
cuda/cuda/bindings/_lib/utils.pxd
27+
cuda/cuda/bindings/_lib/utils.pyx
28+
cuda/cuda/bindings/cydriver.pxd
29+
cuda/cuda/bindings/cydriver.pyx
30+
cuda/cuda/bindings/cyruntime.pxd
31+
cuda/cuda/bindings/cyruntime.pyx
32+
cuda/cuda/bindings/cynvrtc.pxd
33+
cuda/cuda/bindings/cynvrtc.pyx
34+
cuda/cuda/bindings/driver.pxd
35+
cuda/cuda/bindings/driver.pyx
36+
cuda/cuda/bindings/runtime.pxd
37+
cuda/cuda/bindings/runtime.pyx
38+
cuda/cuda/bindings/nvrtc.pxd
39+
cuda/cuda/bindings/nvrtc.pyx
4040

4141
# Distribution / packaging
4242
.Python

MANIFEST.in

-1
This file was deleted.

cuda/LICENSE

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
NVIDIA SOFTWARE LICENSE
2+
3+
This license is a legal agreement between you and NVIDIA Corporation ("NVIDIA") and governs your use of the NVIDIA CUDA Python software and materials provided hereunder ("SOFTWARE").
4+
5+
This license can be accepted only by an adult of legal age of majority in the country in which the SOFTWARE is used. If you are under the legal age of majority, you must ask your parent or legal guardian to consent to this license. By taking delivery of the SOFTWARE, you affirm that you have reached the legal age of majority, you accept the terms of this license, and you take legal and financial responsibility for the actions of your permitted users.
6+
7+
You agree to use the SOFTWARE only for purposes that are permitted by (a) this license, and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions.
8+
9+
1. LICENSE. Subject to the terms of this license, NVIDIA grants you a non-exclusive limited license to: (a) install and use the SOFTWARE, and (b) distribute the SOFTWARE subject to the distribution requirements described in this license. NVIDIA reserves all rights, title and interest in and to the SOFTWARE not expressly granted to you under this license.
10+
11+
2. DISTRIBUTION REQUIREMENTS. These are the distribution requirements for you to exercise the distribution grant:
12+
a. The terms under which you distribute the SOFTWARE must be consistent with the terms of this license, including (without limitation) terms relating to the license grant and license restrictions and protection of NVIDIA's intellectual property rights.
13+
b. You agree to notify NVIDIA in writing of any known or suspected distribution or use of the SOFTWARE not in compliance with the requirements of this license, and to enforce the terms of your agreements with respect to distributed SOFTWARE.
14+
15+
3. LIMITATIONS. Your license to use the SOFTWARE is restricted as follows:
16+
a. The SOFTWARE is licensed for you to develop applications only for use in systems with NVIDIA GPUs.
17+
b. You may not reverse engineer, decompile or disassemble, or remove copyright or other proprietary notices from any portion of the SOFTWARE or copies of the SOFTWARE.
18+
c. You may not modify or create derivative works of any portion of the SOFTWARE.
19+
d. You may not bypass, disable, or circumvent any technical measure, encryption, security, digital rights management or authentication mechanism in the SOFTWARE.
20+
e. You may not use the SOFTWARE in any manner that would cause it to become subject to an open source software license. As examples, licenses that require as a condition of use, modification, and/or distribution that the SOFTWARE be (i) disclosed or distributed in source code form; (ii) licensed for the purpose of making derivative works; or (iii) redistributable at no charge.
21+
f. Unless you have an agreement with NVIDIA for this purpose, you may not use the SOFTWARE with any system or application where the use or failure of the system or application can reasonably be expected to threaten or result in personal injury, death, or catastrophic loss. Examples include use in avionics, navigation, military, medical, life support or other life critical applications. NVIDIA does not design, test or manufacture the SOFTWARE for these critical uses and NVIDIA shall not be liable to you or any third party, in whole or in part, for any claims or damages arising from such uses.
22+
g. You agree to defend, indemnify and hold harmless NVIDIA and its affiliates, and their respective employees, contractors, agents, officers and directors, from and against any and all claims, damages, obligations, losses, liabilities, costs or debt, fines, restitutions and expenses (including but not limited to attorney's fees and costs incident to establishing the right of indemnification) arising out of or related to use of the SOFTWARE outside of the scope of this Agreement, or not in compliance with its terms.
23+
24+
4. PRE-RELEASE. SOFTWARE versions identified as alpha, beta, preview, early access or otherwise as pre-release may not be fully functional, may contain errors or design flaws, and may have reduced or different security, privacy, availability, and reliability standards relative to commercial versions of NVIDIA software and materials. You may use a pre-release SOFTWARE version at your own risk, understanding that these versions are not intended for use in production or business-critical systems.
25+
26+
5. OWNERSHIP. The SOFTWARE and the related intellectual property rights therein are and will remain the sole and exclusive property of NVIDIA or its licensors. The SOFTWARE is copyrighted and protected by the laws of the United States and other countries, and international treaty provisions. NVIDIA may make changes to the SOFTWARE, at any time without notice, but is not obligated to support or update the SOFTWARE.
27+
28+
6. COMPONENTS UNDER OTHER LICENSES. The SOFTWARE may include NVIDIA or third-party components with separate legal notices or terms as may be described in proprietary notices accompanying the SOFTWARE. If and to the extent there is a conflict between the terms in this license and the license terms associated with a component, the license terms associated with the components control only to the extent necessary to resolve the conflict.
29+
30+
7. FEEDBACK. You may, but don't have to, provide to NVIDIA any Feedback. "Feedback" means any suggestions, bug fixes, enhancements, modifications, feature requests or other feedback regarding the SOFTWARE. For any Feedback that you voluntarily provide, you hereby grant NVIDIA and its affiliates a perpetual, non-exclusive, worldwide, irrevocable license to use, reproduce, modify, license, sublicense (through multiple tiers of sublicensees), and distribute (through multiple tiers of distributors) the Feedback without the payment of any royalties or fees to you. NVIDIA will use Feedback at its choice.
31+
32+
8. NO WARRANTIES. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. NVIDIA DOES NOT WARRANT THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION THEREOF WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ALL ERRORS WILL BE CORRECTED.
33+
34+
9. LIMITATIONS OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND ITS AFFILIATES SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR ANY LOST PROFITS, PROJECT DELAYS, LOSS OF USE, LOSS OF DATA OR LOSS OF GOODWILL, OR THE COSTS OF PROCURING SUBSTITUTE PRODUCTS, ARISING OUT OF OR IN CONNECTION WITH THIS LICENSE OR THE USE OR PERFORMANCE OF THE SOFTWARE, WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON BREACH OF CONTRACT, BREACH OF WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY OR ANY OTHER CAUSE OF ACTION OR THEORY OF LIABILITY, EVEN IF NVIDIA HAS PREVIOUSLY BEEN ADVISED OF, OR COULD REASONABLY HAVE FORESEEN, THE POSSIBILITY OF SUCH DAMAGES. IN NO EVENT WILL NVIDIA'S AND ITS AFFILIATES TOTAL CUMULATIVE LIABILITY UNDER OR ARISING OUT OF THIS LICENSE EXCEED US$10.00. THE NATURE OF THE LIABILITY OR THE NUMBER OF CLAIMS OR SUITS SHALL NOT ENLARGE OR EXTEND THIS LIMIT.
35+
36+
10. TERMINATION. Your rights under this license will terminate automatically without notice from NVIDIA if you fail to comply with any term and condition of this license or if you commence or participate in any legal proceeding against NVIDIA with respect to the SOFTWARE. NVIDIA may terminate this license with advance written notice to you if NVIDIA decides to no longer provide the SOFTWARE in a country or, in NVIDIA's sole discretion, the continued use of it is no longer commercially viable. Upon any termination of this license, you agree to promptly discontinue use of the SOFTWARE and destroy all copies in your possession or control. Your prior distributions in accordance with this license are not affected by the termination of this license. All provisions of this license will survive termination, except for the license granted to you.
37+
38+
11. APPLICABLE LAW. This license will be governed in all respects by the laws of the United States and of the State of Delaware as those laws are applied to contracts entered into and performed entirely within Delaware by Delaware residents, without regard to the conflicts of laws principles. The United Nations Convention on Contracts for the International Sale of Goods is specifically disclaimed. You agree to all terms of this Agreement in the English language. The state or federal courts residing in Santa Clara County, California shall have exclusive jurisdiction over any dispute or claim arising out of this license. Notwithstanding this, you agree that NVIDIA shall still be allowed to apply for injunctive remedies or an equivalent type of urgent legal relief in any jurisdiction.
39+
40+
12. NO ASSIGNMENT. This license and your rights and obligations thereunder may not be assigned by you by any means or operation of law without NVIDIA's permission. Any attempted assignment not approved by NVIDIA in writing shall be void and of no effect.
41+
42+
13. EXPORT. The SOFTWARE is subject to United States export laws and regulations. You agree that you will not ship, transfer or export the SOFTWARE into any country, or use the SOFTWARE in any manner, prohibited by the United States Bureau of Industry and Security or economic sanctions regulations administered by the U.S. Department of Treasury's Office of Foreign Assets Control (OFAC), or any applicable export laws, restrictions or regulations. These laws include restrictions on destinations, end users and end use. By accepting this license, you confirm that you are not a resident or citizen of any country currently embargoed by the U.S. and that you are not otherwise prohibited from receiving the SOFTWARE.
43+
44+
14. GOVERNMENT USE. The SOFTWARE has been developed entirely at private expense and is "commercial items" consisting of "commercial computer software" and "commercial computer software documentation" provided with RESTRICTED RIGHTS. Use, duplication or disclosure by the U.S. Government or a U.S. Government subcontractor is subject to the restrictions in this license pursuant to DFARS 227.7202-3(a) or as set forth in subparagraphs (b)(1) and (2) of the Commercial Computer Software - Restricted Rights clause at FAR 52.227-19, as applicable. Contractor/manufacturer is NVIDIA, 2788 San Tomas Expressway, Santa Clara, CA 95051.
45+
46+
15. ENTIRE AGREEMENT. This license is the final, complete and exclusive agreement between the parties relating to the subject matter of this license and supersedes all prior or contemporaneous understandings and agreements relating to this subject matter, whether oral or written. If any court of competent jurisdiction determines that any provision of this license is illegal, invalid or unenforceable, the remaining provisions will remain in full force and effect. This license may only be modified in a writing signed by an authorized representative of each party.
47+
48+
(v. May 12, 2021)

cuda/MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
recursive-include cuda/ *.pyx *.pxd
2+
# at least with setuptools 75.0.0 this folder was added erroneously
3+
# to the payload, causing file copying to the build environment failed
4+
exclude cuda/bindings

cuda/README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# CUDA-Python
2+
3+
CUDA Python is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python. Checkout the [Overview](https://nvidia.github.io/cuda-python/overview.html) for the workflow and performance results.
4+
5+
## Installing
6+
7+
CUDA Python can be installed from:
8+
9+
* PYPI
10+
* Conda (nvidia channel)
11+
* Source builds
12+
13+
There're differences in each of these options that are described further in [Installation](https://nvidia.github.io/cuda-python/install.html) documentation. Each package will guarantee minor version compatibility.
14+
15+
## Runtime Dependencies
16+
17+
CUDA Python is supported on all platforms that CUDA is supported. Specific dependencies are as follows:
18+
19+
* Driver: Linux (450.80.02 or later) Windows (456.38 or later)
20+
* CUDA Toolkit 12.0 to 12.6
21+
22+
Only the NVRTC redistributable component is required from the CUDA Toolkit. [CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/index.html) Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or Local Installer.
23+
24+
### Supported Python Versions
25+
26+
CUDA Python follows [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html) for supported Python version guarantee.
27+
28+
Before dropping support, an issue will be raised to look for feedback.
29+
30+
Source builds work for multiple Python versions, however pre-build PyPI and Conda packages are only provided for a subset:
31+
32+
* Python 3.9 to 3.12
33+
34+
## Testing
35+
36+
### Requirements
37+
38+
Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/requirements.txt).
39+
40+
### Unit-tests
41+
42+
You can run the included tests with:
43+
44+
```
45+
python -m pytest
46+
```
47+
48+
### Benchmark
49+
50+
You can run benchmark only tests with:
51+
52+
```
53+
python -m pytest --benchmark-only
54+
```
55+
56+
### Samples
57+
58+
You can run the included tests with:
59+
60+
```
61+
python -m pytest examples
62+
```
63+
64+
## Examples
65+
66+
CUDA Samples rewriten using CUDA Python are found in `examples`.
67+
68+
Custom extra included examples:
69+
70+
- `examples/extra/jit_program_test.py`: Demonstrates the use of the API to compile and
71+
launch a kernel on the device. Includes device memory allocation /
72+
deallocation, transfers between host and device, creation and usage of
73+
streams, and context management.
74+
- `examples/extra/numba_emm_plugin.py`: Implements a Numba External Memory Management
75+
plugin, showing that this CUDA Python Driver API can coexist with other
76+
wrappers of the driver API.
File renamed without changes.

cuda/cuda/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def __getattr__(name):
2+
if name == "__version__":
3+
import warnings
4+
warnings.warn("accessing cuda.__version__ is deprecated, "
5+
"please switch to use cuda.bindings.__version__ instead",
6+
DeprecationWarning, stacklevel=2)
7+
from . import bindings
8+
return bindings.__version__
9+
10+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
File renamed without changes.
File renamed without changes.
File renamed without changes.

cuda/_cuda/ccuda.pxd.in renamed to cuda/cuda/bindings/_bindings/cydriver.pxd.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8-
from cuda.ccuda cimport *
8+
from cuda.bindings.cydriver cimport *
99

1010
{{if 'cuGetErrorString' in found_functions}}
1111

cuda/_cuda/ccuda.pyx.in renamed to cuda/cuda/bindings/_bindings/cydriver.pyx.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import win32api
1010
import struct
1111
from pywintypes import error
1212
{{else}}
13-
cimport cuda._lib.dlfcn as dlfcn
13+
cimport cuda.bindings._lib.dlfcn as dlfcn
1414
{{endif}}
1515
import os
1616
import sys
17-
cimport cuda._cuda.loader as loader
17+
cimport cuda.bindings._bindings.loader as loader
1818
cdef bint __cuPythonInit = False
1919
{{if 'cuGetErrorString' in found_functions}}cdef void *__cuGetErrorString = NULL{{endif}}
2020
{{if 'cuGetErrorName' in found_functions}}cdef void *__cuGetErrorName = NULL{{endif}}

cuda/_cuda/cnvrtc.pxd.in renamed to cuda/cuda/bindings/_bindings/cynvrtc.pxd.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8-
from cuda.cnvrtc cimport *
8+
from cuda.bindings.cynvrtc cimport *
99

1010
{{if 'nvrtcGetErrorString' in found_functions}}
1111

cuda/_cuda/cnvrtc.pyx.in renamed to cuda/cuda/bindings/_bindings/cynvrtc.pyx.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import win32api
1010
import struct
1111
from pywintypes import error
1212
{{else}}
13-
cimport cuda._lib.dlfcn as dlfcn
13+
cimport cuda.bindings._lib.dlfcn as dlfcn
1414
{{endif}}
1515

1616
cdef bint __cuPythonInit = False
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cuda/_lib/ccudart/ccudart.pxd.in renamed to cuda/cuda/bindings/_lib/cyruntime/cyruntime.pxd.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8-
cimport cuda.ccuda as ccuda
9-
from cuda.ccudart cimport *
8+
cimport cuda.bindings.cydriver as cydriver
9+
from cuda.bindings.cyruntime cimport *
1010
from libc.stdlib cimport malloc, free, calloc
1111
from libc.string cimport memset, memcpy, strncmp
1212
from libcpp cimport bool

0 commit comments

Comments
 (0)