PyTomography
PyTomography copied to clipboard
Fixes in dt2.ipynb
To make the code compatible with MacOS I commented the line below:
#device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
And used instead:
device = (
"cuda"
if torch.cuda.is_available()
else "mps"
if torch.backends.mps.is_available()
else "cpu"
)
print(f"Using {device} device")
In my mac this prints "mps", while in a Linux PC using CUDA it would print "cuda". This fix allows the use of the GPU in Macs (through MPS).
Also, replace "np" by "torch", like below (same issue than in notebook dt1)
x = torch.linspace(-1,1,128)