AssertionError: Torch not compiled with CUDA enabled

bugcreater: <p>when I ran my code in server with GPU is ok<br>
but when I ran the code in another pc using pycharm remote local,it shows:<br>
“AssertionError: Torch not compiled with CUDA enabled”</p>

albanD: <p>If there is no GPU on the machine and you try to use cuda elements, it will fail with this error message because you try to use cuda tools but they are not installed.</p>

bugcreater: <p>Is there other method can I use GPU?Jupyter?</p>

albanD: <p>Is your pycharm suppose to run on the server with GPU?<br>
It doesn’t matter what python interpreter you are using. To be able to use GPU, you need a computer with a GPU and install pytorch on this computer.</p>

ati: <p>Hi…i have the same problem<br>
i installed pytorch and my laptop has GPU also<br>
what’s wrong with that that i take the same error?</p>

albanD: <p>Hi,</p>
<p>You would need to give more informations here.<br>
Like what is your local machine, how do you install pytorch, what is already installed on the machine (do you already have cuda installed)?</p>

ati: <p>I am running this code:<br>
<aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/Hananel-Hazan/bindsnet/blob/master/examples/mnist/reservoir.py" target="_blank" rel="nofollow noopener">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/Hananel-Hazan/bindsnet/blob/master/examples/mnist/reservoir.py" target="_blank" rel="nofollow noopener">Hananel-Hazan/bindsnet/blob/master/examples/mnist/reservoir.py</a></h4>
<pre><code class="lang-py">import os
import numpy as np
import torch
import torch.nn as nn
import argparse
import matplotlib.pyplot as plt

from torchvision import transforms
from tqdm import tqdm

from bindsnet.analysis.plotting import (
    plot_input,
    plot_spikes,
    plot_voltages,
    plot_weights,
)
from bindsnet.datasets import MNIST
from bindsnet.encoding import PoissonEncoder
from bindsnet.network import Network
from bindsnet.network.nodes import Input
</code></pre>

  This file has been truncated. <a href="https://github.com/Hananel-Hazan/bindsnet/blob/master/examples/mnist/reservoir.py" target="_blank" rel="nofollow noopener">show original</a>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
</p>
<p>I did not install Cuda and i don’t want to do<br>
and just installed pytorch on windows10<br>
is there any way in this code that i run it on cpu???</p>

ati: <p>By the way , i installed torch by<br>
pip3 install torch==1.3.0+cpu torchvision==0.4.1+cpu -f <a href="https://download.pytorch.org/whl/torch_stable.html" rel="nofollow noopener">https://download.pytorch.org/whl/torch_stable.html</a></p>

albanD: <p>If you don’t want to use cuda, don’t use it <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"><br>
Make sure that the code you run does not use cuda stuff and you won’t see this error anymore !</p>

ati: <p>Thanks for your response <span class="mention">@alban</span> …yeah i don’t want it  <img src="https://discuss.pytorch.org/images/emoji/apple/smile.png?v=9" title=":smile:" class="emoji" alt=":smile:"><br>
I deleted all of cuda stuff<br>
but i don’t know where i am wrong that still it gives me this error<br>
in one line i see this code:<br>
parser.add_argument("–device_id", type=int, default=0)<br>
that i think it uses cuda as default …<br>
do u have any idea what value i set for default that it uses cpu<br>
i used -1 but it gives me error that it can not be negative</p>

albanD: <p>Hi,</p>
<p>You should get a stack trace with the error. Can you share it? It should point at the place where cuda is being used</p>

ati: <p>this is the full of error</p>
<pre><code class="lang-auto">type or pWarning (from warnings module):
  File "C:\python\Python37\lib\site-packages\sklearn\externals\joblib\externals\cloudpickle\cloudpickle.py", line 47
    import imp
DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
Traceback (most recent call last):
  File "C:\Users\Ati\Desktop\bindsnet-master\examples\mnist\reservoir.py", line 95, in &lt;module&gt;
    network.to("cuda")
  File "C:\python\Python37\lib\site-packages\torch\nn\modules\module.py", line 426, in to
    return self._apply(convert)
  File "C:\python\Python37\lib\site-packages\torch\nn\modules\module.py", line 202, in _apply
    module._apply(fn)
  File "C:\python\Python37\lib\site-packages\torch\nn\modules\module.py", line 245, in _apply
    self._buffers[key] = fn(buf)
  File "C:\python\Python37\lib\site-packages\torch\nn\modules\module.py", line 424, in convert
    return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
  File "C:\python\Python37\lib\site-packages\torch\cuda\__init__.py", line 192, in _lazy_init
    _check_driver()
  File "C:\python\Python37\lib\site-packages\torch\cuda\__init__.py", line 95, in _check_driver
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabledaste code here
</code></pre>

albanD: <p>There is the line <code>network.to("cuda")</code> at line 95 of your <code>reservoir.py</code> file.<br>
You need to remove this <code>.to()</code> or change the argument to <code>"cpu"</code> if you don’t want to use cuda.</p>

ati: <pre><code class="lang-auto">if gpu:
    network.to("cuda")
</code></pre>
<p>i changed it but it doesn’t work<br>
i think it says if gpu is true then run on cuda<br>
so i think i have to change where gpu is true and make it default as false<br>
but i don’t know where is that</p>

ati: <p>Hey…thank you i solved it finally by this your sentence help:<br>
“Make sure that the code you run does not use cuda stuff”<br>
I deleted all of Cuda , gpu and device_id words<br>
and it’s working now<br>
thank you   <img src="https://discuss.pytorch.org/images/emoji/apple/slightly_smiling_face.png?v=9" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:"><img src="https://discuss.pytorch.org/images/emoji/apple/hugs.png?v=9" title=":hugs:" class="emoji" alt=":hugs:"><img src="https://discuss.pytorch.org/images/emoji/apple/hugs.png?v=9" title=":hugs:" class="emoji" alt=":hugs:"></p>

FRahmani368: <p>Hi, I have an issue with using CUDA. I got this error “torch not compiled with cuda enabled” when I wanted to define a tensor on GPU.<br>
for pytorch installation, I used:<br>
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch<br>
and I have Geforce GTX 1080 Ti<br>
Nvidia CUDA driver is 11.0.197. GPU version 451.48<br>
I am using pycharm.<br>
when I run torch.cuda.is_available() --&gt; I get False.<br>
What is the problem? Please advise me. thank you</p>

ptrblck: <p>Maybe the installation of the binary has failed.<br>
Could you create a new conda environment, reinstall the binary, and post the install log here?</p>

surendra_mehra: <p>I have also same error.<br>
I have install <strong>conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch</strong> cuda toolkit but i have print the following command and show the result  print(torch.cuda.is_available())<br>
False.<br>
I have created new environment and installed it.<br>
please give me suggestion. how to resolv this error</p>

ptrblck: <p>Could you post the install log here, please?</p>