Can I "link" pytorch to already installed CUDA

v_pytorch: <p>Hi all,<br>
I have a DEll XPS laptop with GeForce GT 550 M Graphic card. OS is Ubuntu 18.04 LTS.</p>
<p>I was unable to install Pytorch with Cuda, because it prints “Your GPU too old, CUDA is not supported”,<br>
so I installed CPU-only configuration of Pytorch.</p>
<p>But, I have CUDA installed separately with no problem.</p>
<p>Can I somehow “link”/“connect” Pytorch with separately installed Cuda ?</p>
<p>Let me add that I was able to install tensorflow and it uses my graphic card</p>
<p>Thanks in advance</p>

rasbt: <aside class="quote no-group" data-username="v_pytorch" data-post="1" data-topic="36279">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/v/58956e/48.png" class="avatar"> v_pytorch:</div>
<blockquote>
<p>But, I have CUDA installed separately with no problem.</p>
<p>Can I somehow “link”/“connect” Pytorch with separately installed Cuda ?</p>
</blockquote>
</aside>
<p>I think you need to install PyTorch from source for using/linking your own CUDA version installed on your system. Have a look here: <a href="https://github.com/pytorch/pytorch#from-source" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration</a></p>
<p>But first, you may want to try to upgrade your graphics card drivers if you haven’t done so already. Then, try to install the PyTorch version with the lowest cuda version (i.e, <code>conda install pytorch torchvision cuda80 -c pytorch</code>)</p>

v_pytorch: <p>Hi Sebastian, thanks a lot for your reply and link.<br>
I’ve already have latest nvidia drivers for my card  Cuda 9.1 installed. Regarding.your suggestion to install PyTorch with lowest cuda version: if I am succesful, does it mean I’ll have two cuts versions installed simultaneously on my system, current 9.1 which is used by tensorflow, and lower one which will be used by PyTorch. Will there be a potential conflict between the versions, or they can coexist.<br>
Regards</p>

rasbt: <p>If you have cuda 9.1 installed and it works with TensorFlow, then it sounds like your card should at least support cuda 9.</p>
<p>But I assume you have tried</p>
<p><code>conda install pytorch torchvision -c pytorch</code></p>
<p>and it didn’t work?</p>
<blockquote>
<p>Will there be a potential conflict between the versions, or they can coexist.<br>
Regards</p>
</blockquote>
<p>No, don’t worry, there won’t be a conflict if you <strong>don’t</strong> install PyTorch from source. If you use the pip or conda installer, PyTorch will come with it’s own separate cuda and cudnn bundle. This will be kept entirely separate and only used for PyTorch. This is by design to make the installation easier (this is also the reason why the pytorch binaries are so large). The only thing you may want to do is to update your graphics card driver to the latest version.</p>

v_pytorch: <p>Hi Sebastian,</p>
<p>Thanks a gain for your prompt response, I did follow your advice and going the  way of lesser resistance, I simply use used<br>
<strong>conda install pytorch torchvision -c pytorch</strong><br>
, which you recommended. The installation was successful, but when I tried torch.cuda.current_device() I got a warning</p>
<p><strong>anaconda3/lib/python3.6/site-packages/torch/cuda/<strong>init</strong>.py:117: UserWarning: **<br>
**    Found GPU0 GeForce GT 550M which is of cuda capability 2.1.</strong><br>
**    PyTorch no longer supports this GPU because it is too old.**</p>
<p>When I tried to run a python script, it ended with</p>
<p><strong>RuntimeError: cuDNN error: CUDNN_STATUS_ARCH_MISMATCH</strong></p>
<p>I found out that CUDNN doesn’t support 2.1 Cards. May be it uses buit-in info to determine support and 2.1 is an “official” version for GT 550M, but the fact is installation with Cuda 8.0 was succesful, and as I mentioned I even can install use Cuda 9.</p>
<p>It looks PyTorch has some sort of mess with versions. I think even if I manage to install pytorch from sources and link it with separate installation of cuda 9, it will still be failing in CUDNN when checking the card support. I’ll try to contact PyTorch support for clarifications</p>
<p>Many thanks for your help</p>

adongyo: <p>I see your reply and be surprise about that.</p>
<blockquote>
<p>PyTorch will come with it’s own separate cuda and cudnn bundle. This will be kept entirely separate and only used for PyTorch.</p>
</blockquote>
<p>I hava a new PC, and I don’t install the cuda but when I install the pytorch with pip command , the “cuda_isavailable()” returns “Ture”,So I  was thought the  pip will install the  cuda and cudnn automaticly.<br>
But when I input “nvcc -V”  in CMD to inspect the cuda,the  does’t work!   I am confused!<br>
But someone syas that  pytorch does’t contain the cuda and cudnn ,I don’t know  who is right!<br>
Are you  sure about that ?<br>
Thanks !</p>

ptrblck: <p>The PyTorch binaries will ship with the CUDA, cudnn, etc. runtime libs, so that you can use it in PyTorch directly.<br>
The binaries will not install the complete CUDA toolkit on your machine with the compiler.</p>

adongyo: <p>Thank you very much!<br>
But I install the pytorch with pip, is  it " PyTorch binaries "?<br>
Thanks again!</p>

ptrblck: <p>Yes, <code>pip</code> will install the PyTorch wheel and based on the command you were using (from <a href="https://pytorch.org/get-started/locally/">here</a>), you would get the necessary libs to run PyTorch on your GPU.</p>

adongyo: <p>Thank you very much!<br>
Tensorflow can’t use the CUDA and cuDnn  in PyTorhc,right? So if I want  to learn tf, I should install  the CUDA and cuDnn manually right?</p>

adongyo: <p>I have another confusion, I use tensorboard to create an events,</p>
<pre><code class="lang-auto">from torch.utils.tensorboard import SummaryWriter

if __name__ == '__main__':
    write=SummaryWriter("log")
    write.add_scalar("test",1,1)
    write.add_scalar("test",2,2)
    write.close()
</code></pre>
<p>but How can I run it? When I input “tensorboard --logdir==‘logs’”, it told me has no exe named tensorboard.<br>
Thanks !</p>

ptrblck: <p>I don’t know, how TensorFlow uses CUDA and cudnn and if they are packaging it with their wheels/binaries.</p>
<p>I’m not using tensorboard personally, but would guess you would need to install the tensorboard binary to run it.</p>

adongyo: <p>I can run this code,and generate the file correctly.</p>
<blockquote>
<p>from torch.utils.tensorboard import SummaryWriter</p>
</blockquote>
<p>Does pytorch binary  include the tensorboard?<br>
If not, why I can use it?<br>
Or are there something eles can instead it?<br>
Thanks!</p>

ptrblck: <p>Based on the <a href="https://pytorch.org/docs/stable/tensorboard.html">docs</a>, it seems you would have to install <code>tensorboard</code> to use it from your terminal. PyTorch seems to ship only with the necessary tensorboard utilities to create the logs, not to visualize it in the browser.</p>
<blockquote>
<p>This can then be visualized with TensorBoard, which should be installable and runnable with:</p>
</blockquote>
<pre><code class="lang-auto">pip install tensorboard
tensorboard --logdir=runs
</code></pre>

adongyo: <p>I try it ,but  it doesn’t work, .<br>
Thank you !</p>

kuraga: <blockquote>
<p>The PyTorch binaries will ship with the CUDA, cudnn, etc. runtime libs, so that you can use it in PyTorch directly.</p>
</blockquote>
<p>Are there any change here?<br>
Are there some option to link to the system CUDA, cudnn, etc. runtime libs without building from source?</p>

ptrblck: <p>The current pip wheels use the CUDA PyPI wheels as their dependencies. We are specifying the used versions explicitly, so <code>pip install torch</code> will download these libs directly, but you could try to install newer versions e.g. via <code>pip install nvidia-cudnn-cu12==8.9.7.29</code> etc. as they should be backwards compatible.<br>
The safer way would be to build PyTorch from source.</p>