Today I installed PyCUDA and tried to run some samples from Eclipse/PyDev. Now, I had some problems getting Eclipse actually running my code. I’ll use this post to summarize the problems I encountered during installation or project setup and will update this post as if find new solutions or problems.
Importing pycuda.driver module fails when running the code
I tried to import the driver module with
import pycuda.driver as cuda
however this resulted in an ImportError in pycuda._driver import * saying
ImportError: libcurand.so.4: cannot open shared object file: No such file or directory
To resolve this issue the problem in my case was the missing LD_LIBRARY_PATH config in the Run Configurations of my project. Right-click the PyDev project, go to Run As… → Run Configurations… and select the Run Cofing for your project. Then click the tab Environment and hit Select…, check LD_LIBRARY_PATH in the list and hit OK. But wait! Check if your LD_LIBRARY_PATH config includes either /usr/local/cuda/lib64 (64-bit machines) or /usr/local/cuda/lib (32-bit machine). If this is not the case append it separated with a colon. Hit Apply → Run.
PyDev cannot resolve pycuda.driver.mem_alloc()
Open Issue. No solution found yet.
nvcc not found when running a PyCUDA script
My script fails with:
pytools.prefork.ExecError: error invoking 'nvcc --version': [Errno 2] No such file or directory
This is another case of a missing or wrong Environment configuration within PyDev/Eclipse. Right-click the PyDev project, go to Run As… → Run Configurations… and select the Run Cofing for your project. Then click the tab Environment and hit Select…, check PATH in the list and hit OK. Check if your PATH config includes /usr/local/cuda/bin. If this is not the case append it separated with a colon. Hit Apply → Run.

Initially I thought this book would be a good introduction to learn how to program CUDA but today I have to say it is not really an introduction. In my opinion the book has a nice start but then gets very fast into details on the GPU architecture and how to tune your program to high performance. I agree, in the end this is all CUDA is about but as an introduction I prefer to first get a global overview and then go further into details. In addition the book does never really says something about any CUDA API functions or what the API actually provides. I missed this stuff all along the reading.
RSS Feed