{
  "id": 74873,
  "title": "Deterministic results in PyTorch: The slings and arrows of outrageous fortune",
  "url": "/competitions/quora-insincere-questions-classification/discussion/74873",
  "author_name": "",
  "post_date": "2018-12-16T23:59:14.251250800Z",
  "votes": 2,
  "comment_count": 1,
  "views": 0,
  "content": "<p><strong>Edit - verified this is working for me, no changes even in the last decimal places.</strong></p>\n\n<p>I was disappointed to get randomly changing results in my PyTorch (GPU) model.   These are the settings I have collected that allegedly lock PyTorch's Cudnn into a deterministic state.  Running w/ them now and will report back w/ findings.   Hope this saves somebody some effort, additions welcome : </p>\n\n<pre><code>def um_no_id_rather_not_have_randomly_changing_results_thank_you_very_much():\n    seed=1492\n    random.seed(seed)\n    torch.manual_seed(seed)\n    torch.cuda.manual_seed_all(seed)\n    np.random.seed(seed)\n    os.environ['PYTHONHASHSEED'] = str(seed)\n    torch.backends.cudnn.deterministic = True\n</code></pre>",
  "messages": [
    {
      "id": "440043",
      "postDate": "12/16/2018 23:59:14",
      "content": "<p><strong>Edit - verified this is working for me, no changes even in the last decimal places.</strong></p>\n\n<p>I was disappointed to get randomly changing results in my PyTorch (GPU) model.   These are the settings I have collected that allegedly lock PyTorch's Cudnn into a deterministic state.  Running w/ them now and will report back w/ findings.   Hope this saves somebody some effort, additions welcome : </p>\n\n<pre><code>def um_no_id_rather_not_have_randomly_changing_results_thank_you_very_much():\n    seed=1492\n    random.seed(seed)\n    torch.manual_seed(seed)\n    torch.cuda.manual_seed_all(seed)\n    np.random.seed(seed)\n    os.environ['PYTHONHASHSEED'] = str(seed)\n    torch.backends.cudnn.deterministic = True\n</code></pre>",
      "rawMarkdown": "**Edit - verified this is working for me, no changes even in the last decimal places.**\n\nI was disappointed to get randomly changing results in my PyTorch (GPU) model.   These are the settings I have collected that allegedly lock PyTorch's Cudnn into a deterministic state.  Running w/ them now and will report back w/ findings.   Hope this saves somebody some effort, additions welcome : \n\n    def um_no_id_rather_not_have_randomly_changing_results_thank_you_very_much():\n        seed=1492\n        random.seed(seed)\n        torch.manual_seed(seed)\n        torch.cuda.manual_seed_all(seed)\n        np.random.seed(seed)\n        os.environ['PYTHONHASHSEED'] = str(seed)\n        torch.backends.cudnn.deterministic = True",
      "votes": null
    },
    {
      "id": "440233",
      "postDate": "12/17/2018 09:09:06",
      "content": "<p>I'm happy to chime back that this is working for me, and my results are completely repeatable.</p>",
      "rawMarkdown": "I'm happy to chime back that this is working for me, and my results are completely repeatable.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 440233,
      "author_name": "iridiumblue",
      "author_url": "",
      "post_date": "12/17/2018 09:09:06",
      "content": "<p>I'm happy to chime back that this is working for me, and my results are completely repeatable.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "440043": "**Edit - verified this is working for me, no changes even in the last decimal places.**\n\nI was disappointed to get randomly changing results in my PyTorch (GPU) model.   These are the settings I have collected that allegedly lock PyTorch's Cudnn into a deterministic state.  Running w/ them now and will report back w/ findings.   Hope this saves somebody some effort, additions welcome : \n\n    def um_no_id_rather_not_have_randomly_changing_results_thank_you_very_much():\n        seed=1492\n        random.seed(seed)\n        torch.manual_seed(seed)\n        torch.cuda.manual_seed_all(seed)\n        np.random.seed(seed)\n        os.environ['PYTHONHASHSEED'] = str(seed)\n        torch.backends.cudnn.deterministic = True",
    "440233": "I'm happy to chime back that this is working for me, and my results are completely repeatable."
  },
  "source": "meta"
}