.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "demos\04_data\d22_ListGPUs.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_demos_04_data_d22_ListGPUs.py: List and choose GPUs ==================== Find the installed GPUs and choose which ones TIGRE uses. See :doc:`/user-guide/gpus`. Source: `Python/demos/d22_ListGPUs.py `__ ยท `MATLAB/Demos/d22_ListGPUs.m `__ .. dropdown:: MATLAB version of this demo :icon: code .. literalinclude:: /../MATLAB/Demos/d22_ListGPUs.m :language: matlab .. GENERATED FROM PYTHON SOURCE LINES 15-66 .. rst-class:: sphx-glr-script-out .. code-block:: none Querying installed GPU names DeviceCount: 1 Names : ['NVIDIA GeForce RTX 4070'] =================== Result of (GeForce GTX 1060 6GB) Number of devices: 0 gpuids: {'name': 'GeForce GTX 1060 6GB', 'devices': []} {'name': '', 'devices': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]} {'name': 'GeForce RTX 2080 Ti', 'devices': []} | .. code-block:: Python import tigre from tigre.utilities import gpu # List the names of installed GPUs print("Querying installed GPU names") listDeviceNames = gpu.getGpuNames() # noqa: N816 print("\tDeviceCount: {}".format(len(listDeviceNames))) print("\tNames : {}".format(listDeviceNames)) print("===================") # Choose one of them # targetGpuName='' # noqa: N816 targetGpuName = "GeForce GTX 1060 6GB" # noqa: N816 # targetGpuName = 'GeForce RTX 2080 Ti' # noqa: N816 # targetGpuName = 'GeForce GTX 1070' # noqa: N816 # You can get the list of GPU IDs gpuids = gpu.getGpuIds(targetGpuName) print("Result of ({})".format(targetGpuName)) print("\t Number of devices: {}".format(len(gpuids))) print("\t gpuids: {}".format(gpuids)) # If all the GPUs you have are the same and you are going to use them all, you don't add anything to # the existing code. # Your code will look like: # projections=tigre.Ax(head,geo,angles) # imgFDK=tigre.fdk(noise_projections,geo,angles) # imgOSSART=tigre.fdk.os_sart(noise_projections,geo,angles,niter) # or you can write like: # projections=tigre.Ax(head,geo,angles,gpuids=gpuids) # imgFDK=tigre.fdk(noise_projections,geo,angles,gpuids=gpuids) # imgOSSART=tigre.fdk.os_sart(noise_projections,geo,angles,niter,gpuids=gpuids) # In the case where you have multiple types of GPUs installed or you are going to limit the number # of GPUs for a specific process, you can specify the GPUs using a GpuIds object. # For example, if you have four 'GeForce RTX 2080 Ti' and a 'GeForce GTX 1060 6GB' and you are going # to use all 'GeForce RTX 2080 Ti', use # gpuids = GpuIds('GeForce RTX 2080 Ti'); # If you use two of the GPUs, assuming whose device ID are 2 and 3, use # gpuids = GpuIds(); # gpuids.devices = int32(2:3); gpuids = gpu.GpuIds() gpuids.devices = list(range(0, 10)) print(gpuids) gpuids2080 = gpu.GpuIds("GeForce RTX 2080 Ti") print(gpuids2080) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.001 seconds) .. _sphx_glr_download_demos_04_data_d22_ListGPUs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: d22_ListGPUs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: d22_ListGPUs.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: d22_ListGPUs.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_