Example #1
0
import numpy as np
from matplotlib import pyplot as plt
import tigre
import tigre.algorithms as algs
from tigre.demos.Test_data import data_loader
from tigre.utilities.Measure_Quality import Measure_Quality
from tigre.utilities import gpu

listGpuNames = gpu.getGpuNames()
if len(listGpuNames) == 0:
    print("Error: No gpu found")
else:
    for id in range(len(listGpuNames)):
        print("{}: {}".format(id, listGpuNames[id]))

gpuids = gpu.getGpuIds(listGpuNames[0])
print(gpuids)

# Geometry
#geo1 = tigre.geometry(mode='cone', high_quality=False, default=True)
geo = tigre.geometry(mode='cone',
                     nVoxel=np.array([256, 256, 256]),
                     default=True)
geo.dDetector = np.array([0.8, 0.8]) * 2  # size of each pixel            (mm)
geo.sDetector = geo.dDetector * geo.nDetector
# print(geo)

nangles = 100
angles = np.linspace(0, 2 * np.pi, nangles, endpoint=False, dtype=np.float32)

# Prepare projection data
Example #2
0
# 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=Ax(head,geo,angles,'interpolated');
#    imgFDK=FDK(noise_projections,geo,angles);
#    imgOSSART=OS_SART(noise_projections,geo,angles,niter);
# or you can write like
#    gpuids = GpuIds();
#    projections=Ax(head,geo,angles,'interpolated', 'gpuids', gpuids);
#    imgFDK=FDK(noise_projections,geo,angles, 'gpuids', gpuids);
#    imgOSSART=OS_SART(noise_projections,geo,angles,niter, 'gpuids', gpuids);