Ignore specific GPU with pytorch in Anaconda

Asmaron: <p>For context, I am trying to get whisperX running locally and followed this guide, installing it in Anaconda (<a href="https://www.youtube.com/watch?v=zIvcu8szpxw" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=zIvcu8szpxw</a>)</p>
<p>for a little more context…. my coding is FULLY reliant on instructions (I’m trying to transcribe DnD sessions I am running)</p>
<p>so….<br>
right now when I  try to run the whisperX python code (<a href="https://github.com/m-bain/whisperX?tab=readme-ov-file#python-usage-" class="inline-onebox" rel="noopener nofollow ugc">GitHub - m-bain/whisperX: WhisperX: Automatic Speech Recognition with Word-level Timestamps (&amp; Diarization)</a>) I am getting the following message before the Kernel dies.</p>
<blockquote>
<p>C:\Users\XXX.conda\envs\whisperx\lib\site-packages\torch\cuda_<em>init</em>_.py:283: UserWarning:<br>
Found GPU1 NVIDIA GeForce GTX 1070 which is of cuda capability 6.1.<br>
Minimum and Maximum cuda capability supported by this version of PyTorch is<br>
(7.0) - (12.0)</p>
<p>(followed by some related warnings telling me where to download the correct version, etc)</p>
</blockquote>
<p>Besides this 1070 which I am using for it’s additional VRam when playing with LLMs, I have an RTX 3070 installed that does support the correct CUDA version</p>
<p>running <em>nvidia-smi</em> will list the RTX 3070 as GPU-0 and the 1070 as GPU-1 (which is the way it’s supposed to be)</p>
<p>and lists the current cuda version as 13.0 (trying to install v12.6 as per the torch website gives the response that the requirements are already fulfilled)</p>
<hr>
<p>I can change the python code to</p>
<blockquote>
<p>device = “cpu”<br>
compute_type = "int8</p>
</blockquote>
<p>and it will run correctly</p>
<p>how can I make sure that Torch only tries to run off GPU-0, aka the 3070 while ignoring the 1070 and it’s insufficient CUDA version</p>
<p>no combination of gpu, gpu_0, GPU_0, etc I try to throw into the device = ““ will work….. it will just return</p>
<p><em>unsupported device [choosen name]</em></p>
<p>I hope i was able to provide enough information about the problem and what I’m trying to do, but I’m open to answer any questions… within my limited capacity</p>

KFrank: <p>Hi Asmaron!</p>
<aside class="quote no-group" data-username="Asmaron" data-post="1" data-topic="222746" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/asmaron/48/74608_2.png" class="avatar"> Asmaron:</div>
<blockquote>
<p>how can I make sure that Torch only tries to run off GPU-0, aka the 3070 while ignoring the 1070 and it’s insufficient CUDA version</p>
</blockquote>
</aside>
<p>Run the process that runs your pytorch code under control of the<br>
<code>CUDA_VISIBLE_DEVICES</code> environment variable.  See, for example, this<br>
thread:</p>
<aside class="quote quote-modified" data-post="1" data-topic="90340">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/1/74df32/48.png" class="avatar">
    <div class="quote-title__text-content">
      <a href="https://discuss.pytorch.org/t/what-does-export-cuda-visible-devices-1-really-do/90340">What does “export CUDA_VISIBLE_DEVICES=1” really do?</a> 
    </div>
  </div>
  <blockquote>
    In a multi-GPU computer(Ubuntu 16), 
I want to use GPU1 and do the following setting in the shell: 
$ export CUDA_VISIBLE_DEVICES=1
$ python

But, I got an error when I set the device of the tensor: 
Python 3.8.3 (default, May 19 2020, 18:47:26) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; a = torch.Tensor(1).to("cuda:0")
&gt;&gt;&gt; a = torch.Tensor(1).to("cuda:1")
Traceback (most recent call last):
  File "&lt;stdin&gt;",…
  </blockquote>
</aside>

<p>For example, if you were to run your pytorch code under a simple python<br>
session (on unix – I’m not sure how to modify this for windows), you would<br>
run</p>
<pre><code class="lang-auto">CUDA_VISIBLE_DEVICES=0 python
</code></pre>
<p>to launch your python session.</p>
<p>Best.</p>
<p>K. Frank</p>

Asmaron: <p>I haven’t found a way to use the <code>CUDA_VISIBLE_DEVICES=0</code> to set it as an environment rule for…. whatever I’m working with here (using the Anaconda Spyder environmen), and I will continue looking later</p>
<p>BUT</p>
<p>playing around with a few commands, I found that I in the console part of the environment, I can do:</p>
<p><code>torch.cuda.set_device(0)</code> or <code>torch.cuda.set_device(1)</code></p>
<p>with<br>
<code>torch.cuda.get_device_name()</code><br>
depending on which device I set, giving the correct name (RTX3070 being 0) as a response</p>
<p>curiously though<br>
<code>torch.cuda.get_device_properties() </code><br>
will show<br>
<code>pci_device_id=0, pci_domain_id=0</code><br>
for both of them (amongst their correct name, uuid and other stats)</p>

Asmaron: <p>I found a solution</p>
<p>within the python script, I need these two lines of code, after which it will only see the 3070</p>
<p><code>import os</code><br>
<code>os.environ[“CUDA_VISIBLE_DEVICES”] = “0”</code></p>