{
  "id": 129276,
  "title": "How to use GPU with pytorch on my local machine",
  "url": "/competitions/deepfake-detection-challenge/discussion/129276",
  "author_name": "",
  "post_date": "2020-02-06T19:13:43.506405400Z",
  "votes": 1,
  "comment_count": 8,
  "views": 0,
  "content": "<p>Hi,</p>\n\n<p>Can anyone help me, on how I can use GPU on my local machine with pytorch? I asked question here as well: <a href=\"https://stackoverflow.com/questions/60101973/how-to-use-gpu-in-pytorch\">https://stackoverflow.com/questions/60101973/how-to-use-gpu-in-pytorch</a></p>\n\n<p>I tried following steps at: <a href=\"https://pytorch.org/get-started/locally/\">https://pytorch.org/get-started/locally/</a></p>\n\n<p>First I created a conda environment as:</p>\n\n<p><code>conda create -n facenet37_2 python=3.7</code>\nThen on above site I selected:</p>\n\n<p><code>\nPyTorch Build: Stable (1.4)\nOS: Linux (I am using Ubuntu 18.04)\nPackage: conda\nLanguage: python\nCUDA: 10.1\n</code>\nand it asked me to run following command:</p>\n\n<p><code>conda install pytorch torchvision cudatoolkit=10.1 -c pytorch</code>\nBut after that when I opened python and typed:</p>\n\n<p><code>\nimport torch\ntorch.cuda.is_available()\n</code>\nI get False</p>\n\n<p>I have GeForce GT 630M (computeCapability: 2.1). But it is not getting detected. Why? Is it too old and no longer supported? How can I fix the issue?</p>",
  "messages": [
    {
      "id": "738612",
      "postDate": "02/06/2020 19:13:43",
      "content": "<p>Hi,</p>\n\n<p>Can anyone help me, on how I can use GPU on my local machine with pytorch? I asked question here as well: <a href=\"https://stackoverflow.com/questions/60101973/how-to-use-gpu-in-pytorch\">https://stackoverflow.com/questions/60101973/how-to-use-gpu-in-pytorch</a></p>\n\n<p>I tried following steps at: <a href=\"https://pytorch.org/get-started/locally/\">https://pytorch.org/get-started/locally/</a></p>\n\n<p>First I created a conda environment as:</p>\n\n<p><code>conda create -n facenet37_2 python=3.7</code>\nThen on above site I selected:</p>\n\n<p><code>\nPyTorch Build: Stable (1.4)\nOS: Linux (I am using Ubuntu 18.04)\nPackage: conda\nLanguage: python\nCUDA: 10.1\n</code>\nand it asked me to run following command:</p>\n\n<p><code>conda install pytorch torchvision cudatoolkit=10.1 -c pytorch</code>\nBut after that when I opened python and typed:</p>\n\n<p><code>\nimport torch\ntorch.cuda.is_available()\n</code>\nI get False</p>\n\n<p>I have GeForce GT 630M (computeCapability: 2.1). But it is not getting detected. Why? Is it too old and no longer supported? How can I fix the issue?</p>",
      "rawMarkdown": "Hi,\n\nCan anyone help me, on how I can use GPU on my local machine with pytorch? I asked question here as well: https://stackoverflow.com/questions/60101973/how-to-use-gpu-in-pytorch\n\nI tried following steps at: https://pytorch.org/get-started/locally/\n\nFirst I created a conda environment as:\n\n`conda create -n facenet37_2 python=3.7`\nThen on above site I selected:\n\n```\nPyTorch Build: Stable (1.4)\nOS: Linux (I am using Ubuntu 18.04)\nPackage: conda\nLanguage: python\nCUDA: 10.1\n```\nand it asked me to run following command:\n\n`conda install pytorch torchvision cudatoolkit=10.1 -c pytorch`\nBut after that when I opened python and typed:\n\n```\nimport torch\ntorch.cuda.is_available()\n```\nI get False\n\nI have GeForce GT 630M (computeCapability: 2.1). But it is not getting detected. Why? Is it too old and no longer supported? How can I fix the issue?",
      "votes": null
    },
    {
      "id": "738636",
      "postDate": "02/06/2020 19:59:50",
      "content": "<p>Check <a href=\"https://discuss.pytorch.org/t/torch-cuda-is-available-returns-false-nvidia-smi-is-working/20614\">this link</a> please. I think you need to update your display driver. </p>",
      "rawMarkdown": "Check [this link](https://discuss.pytorch.org/t/torch-cuda-is-available-returns-false-nvidia-smi-is-working/20614) please. I think you need to update your display driver.",
      "votes": null
    },
    {
      "id": "738684",
      "postDate": "02/06/2020 21:33:11",
      "content": "<p>I have four local PC's - using Ubuntu 19.10.  I often go down a rabbit hole trying to get something to work and end up making a mess of my machine.   So I do lots of fresh re-installations of Ubuntu and often would have trouble getting the GPU's running in Python.  I think the correct name for the condition is \"cuda hell\".   Getting drivers and cuda toolkit and cudnn ..... all on the same page a super pain.</p>\n\n<p>As noted by Ekran - the most frequent cause of my issues is the display driver.  At times the display on the motherboard wants to be the MFIC and other times when my GeForce is found the driver is old.</p>\n\n<p>This is my path - seems to work.</p>\n\n<p>All the following takes place in a terminal window.</p>\n\n<p>nvcc --version</p>\n\n<p>should be something like this if cuda ready to rock - when I run this after the fresh install I get message telling me to install</p>\n\n<p>`nvcc: NVIDIA (R) Cuda compiler driver'\n'Copyright (c) 2005-2019 NVIDIA Corporation'\n'Built on Wed_Apr_24_19:10:27_PDT_2019'\n'Cuda compilation tools, release 10.1, V10.1.168'</p>\n\n<p>When the above not what you get</p>\n\n<p><code>sudo apt install nvidia-cuda-toolkit</code></p>\n\n<p>when doing a fresh install I now would install anaconda python</p>\n\n<p>than google for \"pytorch install\" and use \"get started\" to get the current command line which for me would be the same as you used</p>\n\n<p>conda install pytorch torchvision cudatoolkit=10.1 -c pytorch</p>\n\n<p>Two days ago I tried with 10.2 and it made a mess - nothing worked. Did a fresh install</p>\n\n<p>Than check again in python with your test</p>\n\n<p>import torch\ntorch.cuda.is_available()</p>\n\n<p>I like the info you can get using this as part of your python checkout</p>\n\n<p>```</p>\n\n<h1>display current status</h1>\n\n<p>from fastai.utils.show_install import show_install; show_install()\n```</p>\n\n<p>that generates this for me</p>\n\n<p>=== Software === \npython        : 3.7.6\nfastai        : 1.0.60\nfastprogress  : 0.2.2\ntorch         : 1.3.1\nnvidia driver : 435.21\ntorch cuda    : 10.0.130 / is available\ntorch cudnn   : 7605 / is enabled</p>\n\n<p>=== Hardware === \nnvidia gpus   : 2\ntorch devices : 2\n  - gpu0      : 8119MB | GeForce GTX 1070\n  - gpu1      : 8111MB | GeForce GTX 1070</p>\n\n<p>If you decide to do a full fresh install send me a email and I will send you my step by step</p>",
      "rawMarkdown": "I have four local PC's - using Ubuntu 19.10.  I often go down a rabbit hole trying to get something to work and end up making a mess of my machine.   So I do lots of fresh re-installations of Ubuntu and often would have trouble getting the GPU's running in Python.  I think the correct name for the condition is \"cuda hell\".   Getting drivers and cuda toolkit and cudnn ..... all on the same page a super pain.\n\nAs noted by Ekran - the most frequent cause of my issues is the display driver.  At times the display on the motherboard wants to be the MFIC and other times when my GeForce is found the driver is old.\n\nThis is my path - seems to work.\n\nAll the following takes place in a terminal window.\n\nnvcc --version\n\nshould be something like this if cuda ready to rock - when I run this after the fresh install I get message telling me to install\n\n`nvcc: NVIDIA (R) Cuda compiler driver'\n'Copyright (c) 2005-2019 NVIDIA Corporation'\n'Built on Wed_Apr_24_19:10:27_PDT_2019'\n'Cuda compilation tools, release 10.1, V10.1.168'\n\nWhen the above not what you get\n\n`sudo apt install nvidia-cuda-toolkit`\n\nwhen doing a fresh install I now would install anaconda python\n\nthan google for \"pytorch install\" and use \"get started\" to get the current command line which for me would be the same as you used\n\nconda install pytorch torchvision cudatoolkit=10.1 -c pytorch\n\nTwo days ago I tried with 10.2 and it made a mess - nothing worked. Did a fresh install\n\nThan check again in python with your test\n\nimport torch\ntorch.cuda.is_available()\n\nI like the info you can get using this as part of your python checkout\n\n```\n# display current status\nfrom fastai.utils.show_install import show_install; show_install()\n```\n\nthat generates this for me\n\n=== Software === \npython        : 3.7.6\nfastai        : 1.0.60\nfastprogress  : 0.2.2\ntorch         : 1.3.1\nnvidia driver : 435.21\ntorch cuda    : 10.0.130 / is available\ntorch cudnn   : 7605 / is enabled\n\n=== Hardware === \nnvidia gpus   : 2\ntorch devices : 2\n  - gpu0      : 8119MB | GeForce GTX 1070\n  - gpu1      : 8111MB | GeForce GTX 1070\n\nIf you decide to do a full fresh install send me a email and I will send you my step by step",
      "votes": null
    },
    {
      "id": "738735",
      "postDate": "02/06/2020 23:55:49",
      "content": "<p>Thanks Jimmy, for such a detail answer.</p>\n\n<p>I'll get to fresh installation in a day or two. Few ppl have pointed that my graphics card is too old (my PC is 7 years old so..). Anyways, how can I check if my graphics card will even work or it is too old. I wanted to see how much speedup I get, using my GPU for facenet (on this simple kernel: <a href=\"https://www.kaggle.com/timesler/facial-recognition-model-in-pytorch\">https://www.kaggle.com/timesler/facial-recognition-model-in-pytorch</a>).</p>\n\n<p>On a side note, while facenet seems to be a good starting point, but I guess we are going deeper in this competition, which seems very interesting.</p>",
      "rawMarkdown": "Thanks Jimmy, for such a detail answer.\n\nI'll get to fresh installation in a day or two. Few ppl have pointed that my graphics card is too old (my PC is 7 years old so..). Anyways, how can I check if my graphics card will even work or it is too old. I wanted to see how much speedup I get, using my GPU for facenet (on this simple kernel: https://www.kaggle.com/timesler/facial-recognition-model-in-pytorch).\n\nOn a side note, while facenet seems to be a good starting point, but I guess we are going deeper in this competition, which seems very interesting.",
      "votes": null
    },
    {
      "id": "738757",
      "postDate": "02/07/2020 01:03:13",
      "content": "<p>run the nvcc --version in terminal as start.  If it's not installed than do the\nsudo apt install nvidia-cuda-toolkit</p>\n\n<p>If supported the install should be successful - but other issue may be that the available GPU memory is going to be too small to be useful.</p>\n\n<p>I have a supported 2GB card that is next to useless (now sitting in my junk drawer).  For most models the batch size with that card needed to be 2 or less.  </p>\n\n<p>You might still see a speed improvement as I would assume your CPU is pretty old/slow.</p>",
      "rawMarkdown": "run the nvcc --version in terminal as start.  If it's not installed than do the\nsudo apt install nvidia-cuda-toolkit\n\nIf supported the install should be successful - but other issue may be that the available GPU memory is going to be too small to be useful.\n\nI have a supported 2GB card that is next to useless (now sitting in my junk drawer).  For most models the batch size with that card needed to be 2 or less.  \n\nYou might still see a speed improvement as I would assume your CPU is pretty old/slow.",
      "votes": null
    },
    {
      "id": "738758",
      "postDate": "02/07/2020 01:06:59",
      "content": "<p><a href=\"https://developer.nvidia.com/cuda-gpus#compute\">Check for your card here</a></p>",
      "rawMarkdown": "[Check for your card here](https://developer.nvidia.com/cuda-gpus#compute)",
      "votes": null
    },
    {
      "id": "738760",
      "postDate": "02/07/2020 01:13:59",
      "content": "<p>As I read that web your card should be compatible.   But as pointed out by some folks on stack being compatiable with cuda might be of no value as you might not be at a high enough version level.  I think install nvidia-cuda-toolkit might get the right version levels - if cuda less than 9 than your SOL.</p>",
      "rawMarkdown": "As I read that web your card should be compatible.   But as pointed out by some folks on stack being compatiable with cuda might be of no value as you might not be at a high enough version level.  I think install nvidia-cuda-toolkit might get the right version levels - if cuda less than 9 than your SOL.",
      "votes": null
    },
    {
      "id": "740281",
      "postDate": "02/09/2020 07:00:24",
      "content": "<p>If you are using CUDA 10.X, the minimum compute capability is 3.0. Source: <a href=\"https://stackoverflow.com/questions/28932864/cuda-compute-capability-requirements\">https://stackoverflow.com/questions/28932864/cuda-compute-capability-requirements</a></p>",
      "rawMarkdown": "If you are using CUDA 10.X, the minimum compute capability is 3.0. Source: https://stackoverflow.com/questions/28932864/cuda-compute-capability-requirements",
      "votes": null
    },
    {
      "id": "740764",
      "postDate": "02/09/2020 18:55:32",
      "content": "<p>Great!</p>",
      "rawMarkdown": "Great!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 738636,
      "author_name": "erkanhatipoglu",
      "author_url": "",
      "post_date": "02/06/2020 19:59:50",
      "content": "<p>Check <a href=\"https://discuss.pytorch.org/t/torch-cuda-is-available-returns-false-nvidia-smi-is-working/20614\">this link</a> please. I think you need to update your display driver. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 738684,
      "author_name": "pcjimmmy",
      "author_url": "",
      "post_date": "02/06/2020 21:33:11",
      "content": "<p>I have four local PC's - using Ubuntu 19.10.  I often go down a rabbit hole trying to get something to work and end up making a mess of my machine.   So I do lots of fresh re-installations of Ubuntu and often would have trouble getting the GPU's running in Python.  I think the correct name for the condition is \"cuda hell\".   Getting drivers and cuda toolkit and cudnn ..... all on the same page a super pain.</p>\n\n<p>As noted by Ekran - the most frequent cause of my issues is the display driver.  At times the display on the motherboard wants to be the MFIC and other times when my GeForce is found the driver is old.</p>\n\n<p>This is my path - seems to work.</p>\n\n<p>All the following takes place in a terminal window.</p>\n\n<p>nvcc --version</p>\n\n<p>should be something like this if cuda ready to rock - when I run this after the fresh install I get message telling me to install</p>\n\n<p>`nvcc: NVIDIA (R) Cuda compiler driver'\n'Copyright (c) 2005-2019 NVIDIA Corporation'\n'Built on Wed_Apr_24_19:10:27_PDT_2019'\n'Cuda compilation tools, release 10.1, V10.1.168'</p>\n\n<p>When the above not what you get</p>\n\n<p><code>sudo apt install nvidia-cuda-toolkit</code></p>\n\n<p>when doing a fresh install I now would install anaconda python</p>\n\n<p>than google for \"pytorch install\" and use \"get started\" to get the current command line which for me would be the same as you used</p>\n\n<p>conda install pytorch torchvision cudatoolkit=10.1 -c pytorch</p>\n\n<p>Two days ago I tried with 10.2 and it made a mess - nothing worked. Did a fresh install</p>\n\n<p>Than check again in python with your test</p>\n\n<p>import torch\ntorch.cuda.is_available()</p>\n\n<p>I like the info you can get using this as part of your python checkout</p>\n\n<p>```</p>\n\n<h1>display current status</h1>\n\n<p>from fastai.utils.show_install import show_install; show_install()\n```</p>\n\n<p>that generates this for me</p>\n\n<p>=== Software === \npython        : 3.7.6\nfastai        : 1.0.60\nfastprogress  : 0.2.2\ntorch         : 1.3.1\nnvidia driver : 435.21\ntorch cuda    : 10.0.130 / is available\ntorch cudnn   : 7605 / is enabled</p>\n\n<p>=== Hardware === \nnvidia gpus   : 2\ntorch devices : 2\n  - gpu0      : 8119MB | GeForce GTX 1070\n  - gpu1      : 8111MB | GeForce GTX 1070</p>\n\n<p>If you decide to do a full fresh install send me a email and I will send you my step by step</p>",
      "votes": null,
      "replies": [
        {
          "id": 738735,
          "author_name": "aknirala",
          "author_url": "",
          "post_date": "02/06/2020 23:55:49",
          "content": "<p>Thanks Jimmy, for such a detail answer.</p>\n\n<p>I'll get to fresh installation in a day or two. Few ppl have pointed that my graphics card is too old (my PC is 7 years old so..). Anyways, how can I check if my graphics card will even work or it is too old. I wanted to see how much speedup I get, using my GPU for facenet (on this simple kernel: <a href=\"https://www.kaggle.com/timesler/facial-recognition-model-in-pytorch\">https://www.kaggle.com/timesler/facial-recognition-model-in-pytorch</a>).</p>\n\n<p>On a side note, while facenet seems to be a good starting point, but I guess we are going deeper in this competition, which seems very interesting.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 738757,
          "author_name": "pcjimmmy",
          "author_url": "",
          "post_date": "02/07/2020 01:03:13",
          "content": "<p>run the nvcc --version in terminal as start.  If it's not installed than do the\nsudo apt install nvidia-cuda-toolkit</p>\n\n<p>If supported the install should be successful - but other issue may be that the available GPU memory is going to be too small to be useful.</p>\n\n<p>I have a supported 2GB card that is next to useless (now sitting in my junk drawer).  For most models the batch size with that card needed to be 2 or less.  </p>\n\n<p>You might still see a speed improvement as I would assume your CPU is pretty old/slow.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 738758,
          "author_name": "pcjimmmy",
          "author_url": "",
          "post_date": "02/07/2020 01:06:59",
          "content": "<p><a href=\"https://developer.nvidia.com/cuda-gpus#compute\">Check for your card here</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 738760,
          "author_name": "pcjimmmy",
          "author_url": "",
          "post_date": "02/07/2020 01:13:59",
          "content": "<p>As I read that web your card should be compatible.   But as pointed out by some folks on stack being compatiable with cuda might be of no value as you might not be at a high enough version level.  I think install nvidia-cuda-toolkit might get the right version levels - if cuda less than 9 than your SOL.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 740281,
      "author_name": "anjum48",
      "author_url": "",
      "post_date": "02/09/2020 07:00:24",
      "content": "<p>If you are using CUDA 10.X, the minimum compute capability is 3.0. Source: <a href=\"https://stackoverflow.com/questions/28932864/cuda-compute-capability-requirements\">https://stackoverflow.com/questions/28932864/cuda-compute-capability-requirements</a></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 740764,
      "author_name": "mielek",
      "author_url": "",
      "post_date": "02/09/2020 18:55:32",
      "content": "<p>Great!</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "738612": "Hi,\n\nCan anyone help me, on how I can use GPU on my local machine with pytorch? I asked question here as well: https://stackoverflow.com/questions/60101973/how-to-use-gpu-in-pytorch\n\nI tried following steps at: https://pytorch.org/get-started/locally/\n\nFirst I created a conda environment as:\n\n`conda create -n facenet37_2 python=3.7`\nThen on above site I selected:\n\n```\nPyTorch Build: Stable (1.4)\nOS: Linux (I am using Ubuntu 18.04)\nPackage: conda\nLanguage: python\nCUDA: 10.1\n```\nand it asked me to run following command:\n\n`conda install pytorch torchvision cudatoolkit=10.1 -c pytorch`\nBut after that when I opened python and typed:\n\n```\nimport torch\ntorch.cuda.is_available()\n```\nI get False\n\nI have GeForce GT 630M (computeCapability: 2.1). But it is not getting detected. Why? Is it too old and no longer supported? How can I fix the issue?",
    "738636": "Check [this link](https://discuss.pytorch.org/t/torch-cuda-is-available-returns-false-nvidia-smi-is-working/20614) please. I think you need to update your display driver.",
    "738684": "I have four local PC's - using Ubuntu 19.10.  I often go down a rabbit hole trying to get something to work and end up making a mess of my machine.   So I do lots of fresh re-installations of Ubuntu and often would have trouble getting the GPU's running in Python.  I think the correct name for the condition is \"cuda hell\".   Getting drivers and cuda toolkit and cudnn ..... all on the same page a super pain.\n\nAs noted by Ekran - the most frequent cause of my issues is the display driver.  At times the display on the motherboard wants to be the MFIC and other times when my GeForce is found the driver is old.\n\nThis is my path - seems to work.\n\nAll the following takes place in a terminal window.\n\nnvcc --version\n\nshould be something like this if cuda ready to rock - when I run this after the fresh install I get message telling me to install\n\n`nvcc: NVIDIA (R) Cuda compiler driver'\n'Copyright (c) 2005-2019 NVIDIA Corporation'\n'Built on Wed_Apr_24_19:10:27_PDT_2019'\n'Cuda compilation tools, release 10.1, V10.1.168'\n\nWhen the above not what you get\n\n`sudo apt install nvidia-cuda-toolkit`\n\nwhen doing a fresh install I now would install anaconda python\n\nthan google for \"pytorch install\" and use \"get started\" to get the current command line which for me would be the same as you used\n\nconda install pytorch torchvision cudatoolkit=10.1 -c pytorch\n\nTwo days ago I tried with 10.2 and it made a mess - nothing worked. Did a fresh install\n\nThan check again in python with your test\n\nimport torch\ntorch.cuda.is_available()\n\nI like the info you can get using this as part of your python checkout\n\n```\n# display current status\nfrom fastai.utils.show_install import show_install; show_install()\n```\n\nthat generates this for me\n\n=== Software === \npython        : 3.7.6\nfastai        : 1.0.60\nfastprogress  : 0.2.2\ntorch         : 1.3.1\nnvidia driver : 435.21\ntorch cuda    : 10.0.130 / is available\ntorch cudnn   : 7605 / is enabled\n\n=== Hardware === \nnvidia gpus   : 2\ntorch devices : 2\n  - gpu0      : 8119MB | GeForce GTX 1070\n  - gpu1      : 8111MB | GeForce GTX 1070\n\nIf you decide to do a full fresh install send me a email and I will send you my step by step",
    "738735": "Thanks Jimmy, for such a detail answer.\n\nI'll get to fresh installation in a day or two. Few ppl have pointed that my graphics card is too old (my PC is 7 years old so..). Anyways, how can I check if my graphics card will even work or it is too old. I wanted to see how much speedup I get, using my GPU for facenet (on this simple kernel: https://www.kaggle.com/timesler/facial-recognition-model-in-pytorch).\n\nOn a side note, while facenet seems to be a good starting point, but I guess we are going deeper in this competition, which seems very interesting.",
    "738757": "run the nvcc --version in terminal as start.  If it's not installed than do the\nsudo apt install nvidia-cuda-toolkit\n\nIf supported the install should be successful - but other issue may be that the available GPU memory is going to be too small to be useful.\n\nI have a supported 2GB card that is next to useless (now sitting in my junk drawer).  For most models the batch size with that card needed to be 2 or less.  \n\nYou might still see a speed improvement as I would assume your CPU is pretty old/slow.",
    "738758": "[Check for your card here](https://developer.nvidia.com/cuda-gpus#compute)",
    "738760": "As I read that web your card should be compatible.   But as pointed out by some folks on stack being compatiable with cuda might be of no value as you might not be at a high enough version level.  I think install nvidia-cuda-toolkit might get the right version levels - if cuda less than 9 than your SOL.",
    "740281": "If you are using CUDA 10.X, the minimum compute capability is 3.0. Source: https://stackoverflow.com/questions/28932864/cuda-compute-capability-requirements",
    "740764": "Great!"
  },
  "source": "meta"
}