PyTomography icon indicating copy to clipboard operation
PyTomography copied to clipboard

Fixes in dt2.ipynb

Open jjgomezcadenas opened this issue 1 year ago • 0 comments

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)

jjgomezcadenas avatar Feb 15 '24 21:02 jjgomezcadenas