Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No output after using PyCUDA

I've installed PyCUDA using pip. I tried this in two computers.
One with a fresh install of Python 3.7.1 and one with Python 3.6.5.

Everything fails after using PuCUDA with no error message.

The minimum example is this:

import sys
import pycuda.driver as cuda
import pycuda.autoinit # <-- Comment in order for `print` to work

if __name__ == '__main__':
    print('Print works')
    sys.stdout.write("Sys print works")

This doesn't print anything unless I remove pycuda.autoinit.

Another example would be using printf:

import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule

if __name__ == '__main__':
    mod = SourceModule("""
        #include <stdio.h>

        __global__ void test() {
          printf("I am %d.%d\\n", threadIdx.x, threadIdx.y);
        }
        """)

    func = mod.get_function("test")
    func(block=(4, 4, 1))

This does not return any output also.

I think that CUDA fails but nothing gets reported.

My configuration:

+--------------------+--------------------+
|        PC1         |        PC2         |
+--------------------+--------------------+
| Python 3.6.5       | Python 3.7.1       |
| Windows 10         | Windows 10         |
| Cuda toolkit 9     | Cuda toolkit 10    |
| GeForce GTX 1050   | GeForce GTX 1080   |
| Visual Studio 2015 | Visual Studio 2015 |
+--------------------+--------------------+

Drivers:

GeForce Game Ready Driver
Version        : 418.91 WHQL
Release Date   : Wed Feb 13, 2019

I've noticed that this is a common problem but there is no solution.

like image 516
Panos Kal. Avatar asked Dec 11 '18 06:12

Panos Kal.


2 Answers

I'm not sure if this would help you out, but similar issue was solved by reinstall cuda(with anoconda).

In case you need it, you can install it via conda console

conda install -c anaconda cudatoolkit

And to check if it runs well,

type numba -s

Hope this can help

like image 153
M T Avatar answered Sep 24 '22 03:09

M T


I'm not sure but I hope this help you address the problem.

  1. Check whether you've installed CUDA toolkit on your Windows.
  2. Check whether PATH environments for CUDA is set properly.
  3. If you are using the latest version of VS, it may be difficult(or impossible) for PyCUDA to work with it. So if you want to install an older version of VS additionally on your current system, after your installation, you may need to specify the path to your new (old-versioned) compiler.

For example, you can add this line into compiler function in site-packages\pycuda\compiler.py:

options.extend(['-ccbin', 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\cl.exe'])

like image 45
overfit Avatar answered Sep 23 '22 03:09

overfit