You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cuda_bindings/docs/source/install.rst
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,8 @@ Installing from PyPI
27
27
28
28
$ pip install -U cuda-python
29
29
30
-
Install all optional dependencies with:
30
+
Install all optional dependencies with::
31
+
31
32
.. code-block:: console
32
33
33
34
pip install -U cuda-python[all]
@@ -52,7 +53,8 @@ Installing from Conda
52
53
53
54
When using conda, the ``cuda-version`` metapackage can be used to control the versions of CUDA Toolkit components that are installed to the conda environment.
[^2]: The CUDA Runtime static library (``libcudart_static.a`` on Linux, ``cudart_static.lib`` on Windows) is part of the CUDA Toolkit. If using conda packages, it is contained in the ``cuda-cudart-static`` package.
72
74
73
-
Source builds require that the provided CUDA headers are of the same major.minor version as the ``cuda.bindings`` you're trying to build. Despite this requirement, note that the minor version compatibility is still maintained. Use the ``CUDA_HOME`` (or ``CUDA_PATH``) environment variable to specify the location of your headers. For example, if your headers are located in ``/usr/local/cuda/include``, then you should set ``CUDA_HOME`` with:
75
+
Source builds require that the provided CUDA headers are of the same major.minor version as the ``cuda.bindings`` you're trying to build. Despite this requirement, note that the minor version compatibility is still maintained. Use the ``CUDA_HOME`` (or ``CUDA_PATH``) environment variable to specify the location of your headers. For example, if your headers are located in ``/usr/local/cuda/include``, then you should set ``CUDA_HOME`` with::
74
76
75
77
.. code-block:: console
76
78
@@ -85,7 +87,7 @@ See `Environment Variables <environment_variables.rst>`_ for a description of ot
The following command was used to profile the applications:
280
+
The following command was used to profile the applications::
281
281
282
282
.. code-block:: shell
283
283
@@ -323,7 +323,8 @@ Using NumPy
323
323
324
324
NumPy `Array objects <https://numpy.org/doc/stable/reference/arrays.html>`_ can be used to fulfill each of these conditions directly.
325
325
326
-
Let's use the following kernel definition as an example:
326
+
Let's use the following kernel definition as an example::
327
+
327
328
.. code-block:: python
328
329
329
330
kernel_string ="""
@@ -403,7 +404,8 @@ This example uses the following types:
403
404
404
405
Note how all three pointers are ``np.intp`` since the pointer values are always a representation of an address space.
405
406
406
-
Putting it all together:
407
+
Putting it all together::
408
+
407
409
.. code-block:: python
408
410
409
411
# Define a custom type
@@ -427,13 +429,13 @@ Putting it all together:
427
429
The final step is to construct a ``kernelParams`` argument that fulfills all of the launch API conditions. This is made easy because each array object comes
428
430
with a `ctypes <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.ctypes.html#numpy.ndarray.ctypes>`_ data attribute that returns the underlying ``void*`` pointer value.
429
431
430
-
By having the final array object contain all pointers, we fulfill the contiguous array requirement:
432
+
By having the final array object contain all pointers, we fulfill the contiguous array requirement::
431
433
432
434
.. code-block:: python
433
435
434
436
kernelParams = np.array([arg.ctypes.data for arg in kernelValues], dtype=np.intp)
435
437
436
-
The launch API supports `Buffer Protocol <https://docs.python.org/3/c-api/buffer.html>`_ objects, therefore we can pass the array object directly.
438
+
The launch API supports `Buffer Protocol <https://docs.python.org/3/c-api/buffer.html>`_ objects, therefore we can pass the array object directly.::
437
439
438
440
.. code-block:: python
439
441
@@ -461,7 +463,7 @@ The ctypes approach treats the ``kernelParams`` argument as a pair of two tuples
461
463
The ctypes `fundamental data types <https://docs.python.org/3/library/ctypes.html#fundamental-data-types>`_ documentation describes the compatibility between different Python types and C types.
462
464
Furthermore, `custom data types <https://docs.python.org/3/library/ctypes.html#calling-functions-with-your-own-custom-data-types>`_ can be used to support kernels with custom types.
463
465
464
-
For this example the result becomes:
466
+
For this example the result becomes::
465
467
466
468
.. code-block:: python
467
469
@@ -500,7 +502,7 @@ Values that are set to ``None`` have a special meaning:
500
502
501
503
In all three cases, the API call will fetch the underlying pointer value and construct a contiguous array with other kernel parameters.
502
504
503
-
With the setup complete, the kernel can be launched:
505
+
With the setup complete, the kernel can be launched::
504
506
505
507
.. code-block:: python
506
508
@@ -518,7 +520,7 @@ CUDA objects
518
520
519
521
Certain CUDA kernels use native CUDA types as their parameters such as ``cudaTextureObject_t``. These types require special handling since they're neither a primitive ctype nor a custom user type. Since ``cuda.bindings`` exposes each of them as Python classes, they each implement ``getPtr()`` and ``__int__()``. These two callables used to support the NumPy and ctypes approach. The difference between each call is further described under `Tips and Tricks <https://nvidia.github.io/cuda-python/cuda-bindings/latest/tips_and_tricks.html#>`_.
520
522
521
-
For this example, lets use the ``transformKernel`` from `examples/0_Introduction/simpleCubemapTexture_test.py <https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/examples/0_Introduction/simpleCubemapTexture_test.py>`_:
523
+
For this example, lets use the ``transformKernel`` from `examples/0_Introduction/simpleCubemapTexture_test.py <https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/examples/0_Introduction/simpleCubemapTexture_test.py>`_::
522
524
523
525
.. code-block:: python
524
526
@@ -537,7 +539,7 @@ For this example, lets use the ``transformKernel`` from `examples/0_Introduction
For NumPy, we can convert these CUDA types by leveraging the ``__int__()`` call to fetch the address of the underlying ``cudaTextureObject_t`` C object and wrapping it in a NumPy object array of type ``np.intp``:
542
+
For NumPy, we can convert these CUDA types by leveraging the ``__int__()`` call to fetch the address of the underlying ``cudaTextureObject_t`` C object and wrapping it in a NumPy object array of type ``np.intp``::
541
543
542
544
.. code-block:: python
543
545
@@ -548,7 +550,7 @@ For NumPy, we can convert these CUDA types by leveraging the ``__int__()`` call
548
550
)
549
551
kernelArgs = np.array([arg.ctypes.data for arg in kernelValues], dtype=np.intp)
550
552
551
-
For ctypes, we leverage the special handling of ``None`` type since each Python class already implements ``getPtr()``:
553
+
For ctypes, we leverage the special handling of ``None`` type since each Python class already implements ``getPtr()``::
0 commit comments