From 05c896d6f7b30b265ca2f73269d25373b3f03868 Mon Sep 17 00:00:00 2001 From: Andy Jones Date: Fri, 26 Apr 2019 21:22:26 +0100 Subject: [PATCH] Adds a note on how to avoid contention when using PyTorch. (#4692) --- doc/source/troubleshooting.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/source/troubleshooting.rst b/doc/source/troubleshooting.rst index 86f56e775..33894cc48 100644 --- a/doc/source/troubleshooting.rst +++ b/doc/source/troubleshooting.rst @@ -39,13 +39,17 @@ application! The most common reasons are the following. - **Multi-threaded libraries:** Are all of your tasks attempting to use all of the cores on the machine? If so, they are likely to experience contention and - prevent your application from achieving a speedup. You can diagnose this by - opening ``top`` while your application is running. If one process is using - most of the CPUs, and the others are using a small amount, this may be the - problem. This is very common with some versions of ``numpy``, and in that case - can usually be setting an environment variable like ``MKL_NUM_THREADS`` (or - the equivalent depending on your installation) to ``1``. + prevent your application from achieving a speedup. This is very common with + some versions of ``numpy``, and in that case can usually be setting an + environment variable like ``MKL_NUM_THREADS`` (or the equivalent depending + on your installation) to ``1``. + For many - but not all - libraries, you can diagnose this by opening ``top`` + while your application is running. If one process is using most of the CPUs, + and the others are using a small amount, this may be the problem. The most + common exception is PyTorch, which will appear to be using all the cores + despite needing ``torch.set_num_threads(1)`` to be called to avoid contention. + If you are still experiencing a slowdown, but none of the above problems apply, we'd really like to know! Please create a `GitHub issue`_ and consider submitting a minimal code example that demonstrates the problem.