Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to set logging level #7

Merged
merged 5 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions nidn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os

# Set main device by default to cpu if no other choice was made before
if "TORCH_DEVICE" not in os.environ:
os.environ["TORCH_DEVICE"] = "cpu"
import torch
from loguru import logger

# Add exposed features here
from .plots.plot_model_grid import plot_model_grid
Expand All @@ -15,6 +13,19 @@
from .utils.fix_random_seeds import fix_random_seeds
from .utils.load_default_cfg import load_default_cfg
from .utils.print_cfg import print_cfg
from .utils.set_log_level import set_log_level

set_log_level("INFO")

# Set main device by default to cpu if no other choice was made before
if "TORCH_DEVICE" not in os.environ:
os.environ["TORCH_DEVICE"] = "cpu"

logger.info(f"Initialized NIDN for {os.environ['TORCH_DEVICE']}")

# Set precision (and potentially GPU)
torch.set_default_tensor_type(torch.DoubleTensor)
logger.info("Using double precision")

__all__ = [
"compute_target_frequencies",
Expand All @@ -28,5 +39,6 @@
"plot_model_grid_per_freq",
"plot_spectra",
"print_cfg",
"set_log_level",
"wl_to_phys_wl",
]
Empty file added nidn/materials/__init__.py
Empty file.
Loading