Skip to content

Commit

Permalink
handle CUBLAS_WORKSPACE_CONFIG env var
Browse files Browse the repository at this point in the history
  • Loading branch information
jettjaniak committed May 15, 2024
1 parent 0a58825 commit d29d377
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/delphi/train/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,25 @@ def setup_training(config: TrainingConfig):
init_wandb(config=config)


def check_set_env_cublas_workspace_config():
expected_val = ":4096:8"
actual_val = os.getenv("CUBLAS_WORKSPACE_CONFIG")
if actual_val is None:
# https://docs.nvidia.com/cuda/archive/12.4.0/cublas/index.html#results-reproducibility
logging.info(
f"Environment variable CUBLAS_WORKSPACE_CONFIG not set. Setting to '{expected_val}' to ensure reproducibility."
)
os.environ["CUBLAS_WORKSPACE_CONFIG"] = expected_val
elif actual_val != expected_val:
logging.warning(
f"Environment variable CUBLAS_WORKSPACE_CONFIG is set to {actual_val}, which may affect reproducibility. "
f"We recommend setting it to '{expected_val}' to ensure reproducibility."
)


def run_training(config: TrainingConfig) -> tuple[ModelTrainingState, RunContext]:
if torch.cuda.is_available():
check_set_env_cublas_workspace_config()
setup_training(config)
logging.info("Starting training...")
logging.info("Config:")
Expand Down

0 comments on commit d29d377

Please sign in to comment.