Matt Billman
Matt Billman

Reputation: 472

How do I run the Sample files included in CUDA 8.0?

I'm installing CUDA 8.0 on my MacBook Pro running Sierra (by way of installing TensorFlow). Very new to GPU computing; I've only ever worked in Python at a very high level (lots of data analysis using numpy). Most of the language on the CUDA website assumes knowledge I don't have. Specifically, I have no idea how to 1) run the sample programs included in the Samples file, and 2) how to "change library pathnames in my .bashrc file" (I'm fairly sure I don't have a .bashrc file, just .bash_history and .bash_profile.

How to I do the above? And are there any good ground-up references online for someone very new to all this?

Upvotes: 2

Views: 7988

Answers (2)

Max K
Max K

Reputation: 71

First copy samples folder from installation folder somewhere else, for example your home directory. Then navigate to sample you wish to run type make and it should create executable file.

For example in folder samples/1_Utilities/deviceQuery you should get exec file named deviceQuery and you can run it ./deviceQuery

edit: Just noticed that you are familiar more with python than C, therefore you should check out pyCUDA

Upvotes: 3

einpoklum
einpoklum

Reputation: 131666

The samples directory - which may be different than the installation directory for the rest of CUDA - has a file named Makefile.

As a Python developer, you might not be familiar with this kinds of files. They are input file for the GNU Make build tool - used mostly for compiled, rather than interpreted languages.

Now, if you have all of the appropriate development tools (mostly a C++ compiler compatible with CUDA), and your environment variables are set properly, and you execute

make -C /path/to/cude/samples

the samples will get "built", i.e. source files will be compiled into object files, and those in turn will be linked into binaries which you can run.

Note that it is possible to build individual samples, using the Makefile in their respective directories instead of the general top-level Makefile.

About setting environment variables - you might need to set something like

export LD_LIBRARY_PATH=/usr/local/cuda/lib64

or better yet, append to that environment variable with:

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64

to append to it. This is assuming you installed CUDA to /usr/local/cuda. You can put this command into .bashrc (create it if it's missing, with permissions 0644).

Upvotes: 1

Related Questions