Commit dc9b5633 authored by Brian McMahan's avatar Brian McMahan
Browse files

updating notebooks to include the OMP_NUM_THREADS environment variable; DRAMATIC SPEED UP

parent 7cfbf065
...@@ -6,11 +6,14 @@ ...@@ -6,11 +6,14 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from argparse import Namespace\n",
"import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n",
"from annoy import AnnoyIndex\n", "from annoy import AnnoyIndex\n",
"import numpy as np\n", "import numpy as np\n",
"import torch\n", "import torch\n",
"from tqdm import tqdm_notebook\n", "from tqdm import tqdm_notebook\n"
"from argparse import Namespace"
] ]
}, },
{ {
...@@ -529,7 +532,7 @@ ...@@ -529,7 +532,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.0" "version": "3.6.8"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
} }
], ],
"source": [ "source": [
"import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n",
"import torch\n", "import torch\n",
"import numpy as np\n", "import numpy as np\n",
"torch.manual_seed(1234)" "torch.manual_seed(1234)"
...@@ -2758,7 +2761,7 @@ ...@@ -2758,7 +2761,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.0" "version": "3.6.8"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from argparse import Namespace\n", "from argparse import Namespace\n",
"import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
...@@ -1044,15 +1046,6 @@ ...@@ -1044,15 +1046,6 @@
"## Evaluate on test set" "## Evaluate on test set"
] ]
}, },
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"args.device = \"cuda\""
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 40, "execution_count": 40,
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
"from argparse import Namespace\n", "from argparse import Namespace\n",
"from collections import Counter\n", "from collections import Counter\n",
"import os\n", "import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
"from argparse import Namespace\n", "from argparse import Namespace\n",
"from collections import Counter\n", "from collections import Counter\n",
"import json\n", "import json\n",
"import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import numpy as np\n", "import numpy as np\n",
"import pandas as pd\n", "import pandas as pd\n",
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
"from collections import Counter\n", "from collections import Counter\n",
"import json\n", "import json\n",
"import os\n", "import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
"from collections import Counter\n", "from collections import Counter\n",
"import json\n", "import json\n",
"import os\n", "import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
"from collections import Counter\n", "from collections import Counter\n",
"import json\n", "import json\n",
"import os\n", "import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"import json\n", "import json\n",
"import os\n", "import os\n",
"import re\n", "import re\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"import json\n", "import json\n",
"import os\n", "import os\n",
"import re\n", "import re\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
"from collections import Counter\n", "from collections import Counter\n",
"import json\n", "import json\n",
"import os\n", "import os\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
"import json\n", "import json\n",
"import os\n", "import os\n",
"import re\n", "import re\n",
"os.environ['OMP_NUM_THREADS'] = '4' \n",
"\n", "\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import numpy as np\n", "import numpy as np\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment