Browse Source

Make Torch import for device safe.

Pallaidium_MacOS
tin2tin 12 months ago committed by GitHub
parent
commit
9c50c8c26a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      __init__.py

17
__init__.py

@ -26,16 +26,19 @@ import string
from os.path import dirname, realpath, isdir, join, basename
import shutil
from datetime import date
import torch
try:
exec("import torch")
if torch.cuda.is_available():
gfx_device = "cuda"
elif torch.backends.mps.is_available():
gfx_device = "mps"
else:
gfx_device = "cpu"
except ModuleNotFoundError:
print("Pallaidium dependencies needs to be installed and then Blender needs to be restarted.")
os_platform = platform.system() # 'Linux', 'Darwin', 'Java', 'Windows'
if torch.cuda.is_available():
gfx_device = "cuda"
elif torch.backends.mps.is_available():
gfx_device = "mps"
else:
gfx_device = "cpu"
def show_system_console(show):

Loading…
Cancel
Save