Discussion:
[PyCUDA] test program hello_gpu.py
Arnold Tunick
2017-10-25 20:51:40 UTC
Permalink
FYI, I used pip install pycuda-2017.1.1+cuda8061-cp36-cp36m-win_amd64.whl.============================================================.

On ‎Wednesday‎, ‎October‎ ‎25‎, ‎2017‎ ‎04‎:‎44‎:‎33‎ ‎PM‎ ‎EDT, Arnold Tunick <***@yahoo.com> wrote:

I am testing the following python script in a miniconda shell on a win 10 notebook with cuda 9.0 amd python 3.6: 
import pycuda.autoinit
import pycuda.driver as drv
import numpyfrom pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""")multiply_them = mod.get_function("multiply_them")a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1), grid=(1,1))c= dest-a*b
print (c)
Unfortunately, I get the following error:
(C:\ProgramData\Miniconda3) C:\SciSoft>python hello_gpu.py
Traceback (most recent call last):
  File "hello_gpu.py", line 1, in <module>
    import pycuda.autoinit
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\autoinit.py", line 2, in <module>
    import pycuda.driver as cuda
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\driver.py", line 5, in <module>
    from pycuda._driver import *  # noqa
ImportError: DLL load failed: The specified module could not be found.

Please advise.Arnold
Andreas Kloeckner
2017-10-25 21:25:34 UTC
Permalink
Use dependency walker on _driver.pyd/dll to find the DLL you're missing.

Andreas
FYI, I used pip install pycuda-2017.1.1+cuda8061-cp36-cp36m-win_amd64.whl.============================================================.
I am testing the following python script in a miniconda shell on a win 10 notebook with cuda 9.0 amd python 3.6: 
import pycuda.autoinit
import pycuda.driver as drv
import numpyfrom pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""")multiply_them = mod.get_function("multiply_them")a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1), grid=(1,1))c= dest-a*b
print (c)
(C:\ProgramData\Miniconda3) C:\SciSoft>python hello_gpu.py
  File "hello_gpu.py", line 1, in <module>
    import pycuda.autoinit
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\autoinit.py", line 2, in <module>
    import pycuda.driver as cuda
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\driver.py", line 5, in <module>
    from pycuda._driver import *  # noqa
ImportError: DLL load failed: The specified module could not be found.
Please advise.Arnold
_______________________________________________
PyCUDA mailing list
https://lists.tiker.net/listinfo/pycuda
Arnold Tunick
2017-10-25 22:07:25 UTC
Permalink
Thank you for your email and rapid response.Please recommend how to implement your suggestion within the miniconda3 command window environment.Thank you,Arnold

On ‎Wednesday‎, ‎October‎ ‎25‎, ‎2017‎ ‎05‎:‎25‎:‎36‎ ‎PM‎ ‎EDT, Andreas Kloeckner <***@informa.tiker.net> wrote:

Use dependency walker on _driver.pyd/dll to find the DLL you're missing.

Andreas
  FYI, I used pip install pycuda-2017.1.1+cuda8061-cp36-cp36m-win_amd64.whl.============================================================.
 
  I am testing the following python script in a miniconda shell on a win 10 notebook with cuda 9.0 amd python 3.6: 
  import pycuda.autoinit
import pycuda.driver as drv
import numpyfrom pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""")multiply_them = mod.get_function("multiply_them")a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1), grid=(1,1))c= dest-a*b
print (c)
(C:\ProgramData\Miniconda3) C:\SciSoft>python hello_gpu.py
  File "hello_gpu.py", line 1, in <module>
    import pycuda.autoinit
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\autoinit.py", line 2, in <module>
    import pycuda.driver as cuda
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\driver.py", line 5, in <module>
    from pycuda._driver import *  # noqa
ImportError: DLL load failed: The specified module could not be found.
Please advise.Arnold
 
_______________________________________________
PyCUDA mailing list
https://lists.tiker.net/listinfo/pycuda
Arnold Tunick
2017-10-25 22:51:13 UTC
Permalink
I downloaded dependency walker software from the Dependency Walker (depends.exe) Home Page. I opened the file _driver.cp36-win_amd64.pyd.Hundreds of dlls could not be found, e.g., API-MS-WIN-CORE-FILE_L1-1.DLL, etc..Please advise.Arnold


On ‎Wednesday‎, ‎October‎ ‎25‎, ‎2017‎ ‎05‎:‎25‎:‎36‎ ‎PM‎ ‎EDT, Andreas Kloeckner <***@informa.tiker.net> wrote:

Use dependency walker on _driver.pyd/dll to find the DLL you're missing.

Andreas
  FYI, I used pip install pycuda-2017.1.1+cuda8061-cp36-cp36m-win_amd64.whl.============================================================.
 
  I am testing the following python script in a miniconda shell on a win 10 notebook with cuda 9.0 amd python 3.6: 
  import pycuda.autoinit
import pycuda.driver as drv
import numpyfrom pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""")multiply_them = mod.get_function("multiply_them")a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1), grid=(1,1))c= dest-a*b
print (c)
(C:\ProgramData\Miniconda3) C:\SciSoft>python hello_gpu.py
  File "hello_gpu.py", line 1, in <module>
    import pycuda.autoinit
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\autoinit.py", line 2, in <module>
    import pycuda.driver as cuda
  File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\driver.py", line 5, in <module>
    from pycuda._driver import *  # noqa
ImportError: DLL load failed: The specified module could not be found.
Please advise.Arnold
 
_______________________________________________
PyCUDA mailing list
https://lists.tiker.net/listinfo/pycuda
Arnold Tunick
2017-10-26 20:37:08 UTC
Permalink
Hi Andreas,    I tried to reinstall pycuda from within my Miniconda3 command window, i.e., using the command... pip install pycuda.    Everything goes well in the build until it tries to execute the following:
    C:\ProgramData\Miniconda3\Library\mingw-w64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DPYGPU_PYCUDA=1 -DHAVE_CURAND=1 -Isrc/cpp -Ibpl-subset/bpl_subset "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -IC:\ProgramData\Miniconda3\lib\site-packages\numpy\core\include -IC:\ProgramData\Miniconda3\lib\site-packages\numpy\core\include -IC:\ProgramData\Miniconda3\include -IC:\ProgramData\Miniconda3\include -c src/cpp/cuda.cpp -o build\temp.win-amd64-3.6\Release\src\cpp\cuda.o /EHsc
Then I get this error message:gcc: error: /EHsc: No such file or directory
error: command 'C:\\ProgramData\\Miniconda3\\Library\\mingw-w64\\bin\\gcc.exe' failed with exit status 1.So I thought that the gcc.exe folder needed to be added to the path, so I added it. Nevertheless, I got the same gcc: error: /EHsc: No such file or directory.
PATH=C:\ProgramData\Miniconda3;C:\ProgramData\Miniconda3\Library\mingw-w64\bin;C:\ProgramData\Miniconda3\Library\usr\bin;C:\ProgramData\Miniconda3\Library\;C:\ProgramData\Miniconda3\Scripts;C:\ProgramData\Miniconda3\Library\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\SciSoft\Python36\Scripts\;C:\SciSoft\Python36\; etc...
At the same time, the pip install provides the following message:
    *************************************************************
    *** I have detected that you have not run configure.py.
    *************************************************************
    *** Additionally, no global config files were found.
    *** I will go ahead with the default configuration.
    *** In all likelihood, this will not work out.
    ***
    *** See README_SETUP.txt for more information.
    ***
    *** If the build does fail, just re-run configure.py with the
    *** correct arguments, and then retry. Good luck!*****************************************************************However, there are no files named configure.py or README_SETUP.txt on my computer..Please advise.Thank you.Arnold
Andreas Kloeckner
2017-10-26 23:22:46 UTC
Permalink
    C:\ProgramData\Miniconda3\Library\mingw-w64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DPYGPU_PYCUDA=1 -DHAVE_CURAND=1 -Isrc/cpp -Ibpl-subset/bpl_subset "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -IC:\ProgramData\Miniconda3\lib\site-packages\numpy\core\include -IC:\ProgramData\Miniconda3\lib\site-packages\numpy\core\include -IC:\ProgramData\Miniconda3\include -IC:\ProgramData\Miniconda3\include -c src/cpp/cuda.cpp -o build\temp.win-amd64-3.6\Release\src\cpp\cuda.o /EHsc
Then I get this error message:gcc: error: /EHsc: No such file or directory
error: command 'C:\\ProgramData\\Miniconda3\\Library\\mingw-w64\\bin\\gcc.exe' failed with exit status 1.So I thought that the gcc.exe folder needed to be added to the path, so I added it. Nevertheless, I got the same gcc: error: /EHsc: No such file or directory.
PATH=C:\ProgramData\Miniconda3;C:\ProgramData\Miniconda3\Library\mingw-w64\bin;C:\ProgramData\Miniconda3\Library\usr\bin;C:\ProgramData\Miniconda3\Library\;C:\ProgramData\Miniconda3\Scripts;C:\ProgramData\Miniconda3\Library\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\SciSoft\Python36\Scripts\;C:\SciSoft\Python36\; etc...
    *************************************************************
    *** I have detected that you have not run configure.py.
    *************************************************************
    *** Additionally, no global config files were found.
    *** I will go ahead with the default configuration.
    *** In all likelihood, this will not work out.
    ***
    *** See README_SETUP.txt for more information.
    ***
    *** If the build does fail, just re-run configure.py with the
    *** correct arguments, and then retry. Good luck!*****************************************************************However, there are no files named configure.py or README_SETUP.txt on my computer..Please advise.Thank you.Arnold
I am not sure PyCUDA likes being built with Mingw; I'd recommend the
MS compiler (or Christoph Gohlke's binaries) on Windows. At the very
least, you'd have to adjust the CXXFLAGS config variable to not include
flags that only the MS compiler will recognize. Alternatively, PyOpenCL
does much the same thing as PyCUDA and is included in conda forge.

HTH,
Andreas
Arnold Tunick
2017-10-27 18:05:34 UTC
Permalink
Hi Andreas,    Thank you for your email. While PyOpenCL may be useful, in the long run my CNN has Pycuda as a software dependency and so I would like to keep trying.   Previously, I downloaded a .whl file directly from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycuda and used pip install. I tried that again today and it appeared to be successful.

(C:\ProgramData\Miniconda3) C:\Users\atunick\Documents>pip install pycuda-2017.1.1+cuda8061-cp36-cp36m-win_amd64.whl
Processing c:\users\atunick\documents\pycuda-2017.1.1+cuda8061-cp36-cp36m-win_amd64.whl
Installing collected packages: pycuda
Successfully installed pycuda-2017.1.1+cuda8061
However, when I try to run hello_gpu.py or simplespeedtest.py I get the error message that I reported earlier, i.e.,   File "C:\ProgramData\Miniconda3\lib\site-packages\pycuda\driver.py", line 5, in <module>
    from pycuda._driver import *  # noqa
ImportError: DLL load failed: The specified module could not be found.
.Don't I need to run a setup.py file or something similar for this .whl install to build pycuda?
Yet there is not a setup.py file in the newly created folder C:\ProgramData\Miniconda3\Lib\site-packages\pycuda.
Please adviseThank you.Arnold
ephi5757
2017-10-27 20:16:41 UTC
Permalink
Hi Andreas
I found that the pycuda .whl was a combination install for pycuda 2017.1.1 + Cuda 8.0.6.1 for win64 and python 3.6.

I suspect that while the install was successful my test programs are failing because I have Cuda 9.0.

I am home now for the Sabbath but on Sunday I will see if I can install a compatible who + cuda version.

I am sorry that I did not see this earlier. 

Best, Arnold 


Sent via the Samsung Galaxy S® 4 mini ™, an AT&T 4G LTE smartphone
Post by Arnold Tunick
C:\ProgramData\Miniconda3\Library\mingw-w64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DPYGPU_PYCUDA=1 -DHAVE_CURAND=1 -Isrc/cpp -Ibpl-subset/bpl_subset "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -IC:\ProgramData\Miniconda3\lib\site-packages\numpy\core\include -IC:\ProgramData\Miniconda3\lib\site-packages\numpy\core\include -IC:\ProgramData\Miniconda3\include -IC:\ProgramData\Miniconda3\include -c src/cpp/cuda.cpp -o build\temp.win-amd64-3.6\Release\src\cpp\cuda.o /EHsc
Then I get this error message:gcc: error: /EHsc: No such file or directory
error: command 'C:\\ProgramData\\Miniconda3\\Library\\mingw-w64\\bin\\gcc.exe' failed with exit status 1.So I thought that the gcc.exe folder needed to be added to the path, so I added it. Nevertheless, I got the same gcc: error: /EHsc: No such file or directory.
PATH=C:\ProgramData\Miniconda3;C:\ProgramData\Miniconda3\Library\mingw-w64\bin;C:\ProgramData\Miniconda3\Library\usr\bin;C:\ProgramData\Miniconda3\Library\;C:\ProgramData\Miniconda3\Scripts;C:\ProgramData\Miniconda3\Library\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\SciSoft\Python36\Scripts\;C:\SciSoft\Python36\; etc...
*************************************************************
*** I have detected that you have not run configure.py.
*************************************************************
*** Additionally, no global config files were found.
*** I will go ahead with the default configuration.
*** In all likelihood, this will not work out.
***
*** See README_SETUP.txt for more information.
***
*** If the build does fail, just re-run configure.py with the
*** correct arguments, and then retry. Good luck!*****************************************************************However, there are no files named configure.py or README_SETUP.txt on my computer..Please advise.Thank you.Arnold
I am not sure PyCUDA likes being built with Mingw; I'd recommend the
MS compiler (or Christoph Gohlke's binaries) on Windows. At the very
least, you'd have to adjust the CXXFLAGS config variable to not include
flags that only the MS compiler will recognize. Alternatively, PyOpenCL
does much the same thing as PyCUDA and is included in conda forge.

HTH,
Andreas
Andreas Kloeckner
2017-10-28 15:39:28 UTC
Permalink
Post by Arnold Tunick
Hi Andreas
I found that the pycuda .whl was a combination install for pycuda 2017.1.1 + Cuda 8.0.6.1 for win64 and python 3.6.
I suspect that while the install was successful my test programs are failing because I have Cuda 9.0.
I am home now for the Sabbath but on Sunday I will see if I can install a compatible who + cuda version.
I am sorry that I did not see this earlier. 
Happy to hear you were able to figure this out.

Andreas
Arnold Tunick
2017-11-01 19:07:30 UTC
Permalink
Hi Andreas,     my CNN training program has the following pycuda set up:
    import pycuda.driver as drv...    # pycuda set up
    drv.init()
    dev = drv.Device(int(config['gpu'][-1]))
    ctx = dev.make_context()
When I run the program I get the following error:  File "C:\Users\atunick\theano_alexnet\train.py", line 31, in train_net
    ctx = dev.make_context()
MemoryError: cuCtxCreate failed: out of memory
Note that I am using a new win 10 notebook and have everything re-installed and working, e.g., I have run without error two pycuda test programs...hello_gpu.py and simplespeedtest.py..I have not seen this problem before and when I search the web for solutions, the ones that you recommended earlier don't appear to work, i.e.,   import pycuda
   pycuda.tools.clear_context_caches()
or
   import gc
   and between calls add gc.collect().Please advise.Thank you.Arnold
Andreas Kloeckner
2017-11-02 14:37:00 UTC
Permalink
    import pycuda.driver as drv...    # pycuda set up
    drv.init()
    dev = drv.Device(int(config['gpu'][-1]))
    ctx = dev.make_context()
When I run the program I get the following error:  File "C:\Users\atunick\theano_alexnet\train.py", line 31, in train_net
    ctx = dev.make_context()
MemoryError: cuCtxCreate failed: out of memory
Note that I am using a new win 10 notebook and have everything re-installed and working, e.g., I have run without error two pycuda test programs...hello_gpu.py and simplespeedtest.py..I have not seen this problem before and when I search the web for solutions, the ones that you recommended earlier don't appear to work, i.e.,   import pycuda
   pycuda.tools.clear_context_caches()
or
   import gc
   and between calls add gc.collect().Please advise.Thank you.Arnold
Is there other code in that program that might also create a context?
Contexts are quite memory-intensive, so your device may not have enough
memory to fit more than one.

Andreas
Peter Walsh
2017-11-02 19:56:27 UTC
Permalink
Run nvidia-smi and see what process is using up all the memory. Possibly
some previous session which is still active.
Post by Arnold Tunick
import pycuda.driver as drv... # pycuda set up
drv.init()
dev = drv.Device(int(config['gpu'][-1]))
ctx = dev.make_context()
When I run the program I get the following error: File
"C:\Users\atunick\theano_alexnet\train.py", line 31, in train_net
ctx = dev.make_context()
MemoryError: cuCtxCreate failed: out of memory
Note that I am using a new win 10 notebook and have everything
re-installed and working, e.g., I have run without error two pycuda test
programs...hello_gpu.py and simplespeedtest.py..I have not seen this
problem before and when I search the web for solutions, the ones that you
recommended earlier don't appear to work, i.e., import pycuda
pycuda.tools.clear_context_caches()
or
import gc
and between calls add gc.collect().Please advise.Thank you.Arnold
Is there other code in that program that might also create a context?
Contexts are quite memory-intensive, so your device may not have enough
memory to fit more than one.
Andreas
_______________________________________________
PyCUDA mailing list
https://lists.tiker.net/listinfo/pycuda
Loading...