{
  "id": 74692,
  "title": "Pytorch runtime error",
  "url": "/competitions/quora-insincere-questions-classification/discussion/74692",
  "author_name": "",
  "post_date": "2018-12-14T14:46:19.984671100Z",
  "votes": null,
  "comment_count": 3,
  "views": 0,
  "content": "<p>How do you get pytorch to use the GPU in a kernel?  I have a script that runs great on my Windows 10 machine, but when I try to run it as a kernel, I get:</p>\n\n<pre><code>RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason.  The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols.  You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.\n</code></pre>\n\n<p>When I remove the offending line:</p>\n\n<pre><code>model.cuda()\n</code></pre>\n\n<p>The script does not use the GPU and is so slow I cannot perceive any progress.</p>",
  "messages": [
    {
      "id": "438996",
      "postDate": "12/14/2018 14:46:19",
      "content": "<p>How do you get pytorch to use the GPU in a kernel?  I have a script that runs great on my Windows 10 machine, but when I try to run it as a kernel, I get:</p>\n\n<pre><code>RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason.  The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols.  You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.\n</code></pre>\n\n<p>When I remove the offending line:</p>\n\n<pre><code>model.cuda()\n</code></pre>\n\n<p>The script does not use the GPU and is so slow I cannot perceive any progress.</p>",
      "rawMarkdown": "How do you get pytorch to use the GPU in a kernel?  I have a script that runs great on my Windows 10 machine, but when I try to run it as a kernel, I get:\n\n    RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason.  The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols.  You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.\n\nWhen I remove the offending line:\n\n    model.cuda()\n\nThe script does not use the GPU and is so slow I cannot perceive any progress.",
      "votes": null
    },
    {
      "id": "439015",
      "postDate": "12/14/2018 15:46:09",
      "content": "<p>Have you activated GPU feature on the notebook?</p>",
      "rawMarkdown": "Have you activated GPU feature on the notebook?",
      "votes": null
    },
    {
      "id": "439026",
      "postDate": "12/14/2018 16:04:36",
      "content": "<p>It is not a notebook, it is a script.  The kaggle interface shows that the GPU is on.</p>",
      "rawMarkdown": "It is not a notebook, it is a script.  The kaggle interface shows that the GPU is on.",
      "votes": null
    },
    {
      "id": "439083",
      "postDate": "12/14/2018 17:48:10",
      "content": "<p>More information on this if anyone can help.  Using this article <a href=\"https://www.kaggle.com/leighplt/simple-pytorch-with-kaggle-s-gpu\">https://www.kaggle.com/leighplt/simple-pytorch-with-kaggle-s-gpu</a> , I added at the top of my script</p>\n\n<pre><code>\nUSE_GPU = True\n\nif USE_GPU and torch.cuda.is_available():\n    print('using device: cuda')\nelse:\n    print('using device: cpu')\n</code>\n</pre>\n\n<p>The script interface indicated the GPU is on, but it indicated that I am using the cpu.</p>\n\n<p>Maybe Kaggle staff could weigh-in on this one</p>",
      "rawMarkdown": "More information on this if anyone can help.  Using this article https://www.kaggle.com/leighplt/simple-pytorch-with-kaggle-s-gpu , I added at the top of my script\n\n<pre><code>\nUSE_GPU = True\n\nif USE_GPU and torch.cuda.is_available():\n    print('using device: cuda')\nelse:\n    print('using device: cpu')\n</code>\n</pre>\n\nThe script interface indicated the GPU is on, but it indicated that I am using the cpu.\n\nMaybe Kaggle staff could weigh-in on this one",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 439015,
      "author_name": "jlochter",
      "author_url": "",
      "post_date": "12/14/2018 15:46:09",
      "content": "<p>Have you activated GPU feature on the notebook?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 439026,
      "author_name": "arkerpay",
      "author_url": "",
      "post_date": "12/14/2018 16:04:36",
      "content": "<p>It is not a notebook, it is a script.  The kaggle interface shows that the GPU is on.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 439083,
      "author_name": "arkerpay",
      "author_url": "",
      "post_date": "12/14/2018 17:48:10",
      "content": "<p>More information on this if anyone can help.  Using this article <a href=\"https://www.kaggle.com/leighplt/simple-pytorch-with-kaggle-s-gpu\">https://www.kaggle.com/leighplt/simple-pytorch-with-kaggle-s-gpu</a> , I added at the top of my script</p>\n\n<pre><code>\nUSE_GPU = True\n\nif USE_GPU and torch.cuda.is_available():\n    print('using device: cuda')\nelse:\n    print('using device: cpu')\n</code>\n</pre>\n\n<p>The script interface indicated the GPU is on, but it indicated that I am using the cpu.</p>\n\n<p>Maybe Kaggle staff could weigh-in on this one</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "438996": "How do you get pytorch to use the GPU in a kernel?  I have a script that runs great on my Windows 10 machine, but when I try to run it as a kernel, I get:\n\n    RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason.  The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols.  You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.\n\nWhen I remove the offending line:\n\n    model.cuda()\n\nThe script does not use the GPU and is so slow I cannot perceive any progress.",
    "439015": "Have you activated GPU feature on the notebook?",
    "439026": "It is not a notebook, it is a script.  The kaggle interface shows that the GPU is on.",
    "439083": "More information on this if anyone can help.  Using this article https://www.kaggle.com/leighplt/simple-pytorch-with-kaggle-s-gpu , I added at the top of my script\n\n<pre><code>\nUSE_GPU = True\n\nif USE_GPU and torch.cuda.is_available():\n    print('using device: cuda')\nelse:\n    print('using device: cpu')\n</code>\n</pre>\n\nThe script interface indicated the GPU is on, but it indicated that I am using the cpu.\n\nMaybe Kaggle staff could weigh-in on this one"
  },
  "source": "meta"
}