Building PyTorch from source to support a 3.0 CC device (Quadro K4200)

username: joehays
cooked: <p>Hello,</p>
<p>I have 2 Quadro K4200 nvidia GPUs. They have a compute capability (CC) of 3.0. I’ve found many posting that indicate that I need to build PyTorch from source because a CC of 3.0 is too old. I have now built from source but am getting this common error:</p>
<pre><code class="lang-auto">RuntimeError: CUDA error: no kernel image is available for execution on the device
</code></pre>
<p>One posting indicated that I needed to modify, ~/torch/utils/cpp_extension.py, to specify my needed architecture. I found the following related code,</p>
<pre><code class="lang-auto">    named_arches = collections.OrderedDict([
        ('Kepler+Tesla', '3.7'),
        ('Kepler', '3.5+PTX'),
        ('Maxwell+Tegra', '5.3'),
        ('Maxwell', '5.0;5.2+PTX'),
        ('Pascal', '6.0;6.1+PTX'),
        ('Volta', '7.0+PTX'),
        ('Turing', '7.5+PTX'),
        ('Ampere', '8.0+PTX'),
    ])

    supported_arches = ['3.5', '3.7', '5.0', '5.2', '5.3', '6.0', '6.1', '6.2',
                        '7.0', '7.2', '7.5', '8.0']
</code></pre>
<p>but am unsure how to change this for my device.</p>
<p>Any advice here would be appreciated.</p>
<p>Some system information:</p>
<pre><code class="lang-auto">(SLLML-dev) joehays-local@sedacs17lx:~$ lspci | grep -i nvidia
03:00.0 VGA compatible controller: NVIDIA Corporation GK104GL [Quadro K4200] (rev a1)
03:00.1 Audio device: NVIDIA Corporation GK104 HDMI Audio Controller (rev a1)
04:00.0 VGA compatible controller: NVIDIA Corporation GK104GL [Quadro K4200] (rev a1)
04:00.1 Audio device: NVIDIA Corporation GK104 HDMI Audio Controller (rev a1)
(SLLML-dev) joehays-local@sedacs17lx:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
(SLLML-dev) joehays-local@sedacs17lx:~$ nvidia-smi
Wed Jul  8 18:26:37 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01    Driver Version: 440.33.01    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro K4200        Off  | 00000000:03:00.0 Off |                  N/A |
| 30%   41C    P8    14W / 110W |    164MiB /  4029MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Quadro K4200        Off  | 00000000:04:00.0 Off |                  N/A |
| 30%   36C    P8    13W / 110W |      1MiB /  4037MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1692      G   /usr/lib/xorg/Xorg                           161MiB |
+-----------------------------------------------------------------------------+
(SLLML-dev) joehays-local@sedacs17lx:~$ echo $CUDA_HOME
/usr/local/cuda-10.2
(SLLML-dev) joehays-local@sedacs17lx:~$ echo $LD_LIBRARY_PATH
:/home/joehays-local/.mujoco/mujoco200/bin:/usr/local/cuda-10.2/lib64:/home/joehays-local/.mujoco/mujoco200/bin:/usr/local/cuda-10.2/lib64:/usr/lib/nvidia-440:/usr/lib/nvidia-440
(SLLML-dev) joehays-local@sedacs17lx:~$ 
</code></pre>

username: ptrblck
cooked: <p>I don’t think you would need to modify <code>cpp_extension.py</code>, as it should only be used for custom C++/CUDA extensions, not the base build.</p>
<p>Try to build PyTorch via:</p>
<pre><code class="lang-auto">TORCH_CUDA_ARCH_LIST="3.0" python setup.py install
</code></pre>

username: joehays
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a>, that was it. Thank you!</p>
<p>Turns out that even after compiling with 3.0 support that the nature of my application isn’t supported.</p>
<p>Thanks again.</p>