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

Reproducibility on Cudnn #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/learners/q_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def train(self, batch: EpisodeBatch, t_env: int, episode_num: int):

if t_env - self.log_stats_t >= self.args.learner_log_interval:
self.logger.log_stat("loss", loss.item(), t_env)
self.logger.log_stat("grad_norm", grad_norm, t_env)
self.logger.log_stat("grad_norm", grad_norm.item(), t_env)
mask_elems = mask.sum().item()
self.logger.log_stat("td_error_abs", (masked_td_error.abs().sum().item()/mask_elems), t_env)
self.logger.log_stat("q_taken_mean", (chosen_action_qvals * mask).sum().item()/(mask_elems * self.args.n_agents), t_env)
Expand Down
8 changes: 7 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def my_main(_run, _config, _log):
th.manual_seed(config["seed"])
config['env_args']['seed'] = config["seed"]

if config["use_cuda"]:
th.backends.cudnn.deterministic = True
th.backends.cudnn.benchmark = False

# run the framework
run(_run, config, _log)

Expand Down Expand Up @@ -92,7 +96,9 @@ def config_copy(config):

# Save to disk by default for sacred
logger.info("Saving to FileStorageObserver in results/sacred.")
file_obs_path = os.path.join(results_path, "sacred")
file_obs_path = os.path.join(os.path.join(
os.path.join(results_path, config_dict['env_args']['map_name']), config_dict['name']), "sacred")

ex.observers.append(FileStorageObserver.create(file_obs_path))

ex.run_commandline(params)
Expand Down