2

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?

Matt Billman
  • 472
  • 5
  • 19
  • First of all, does your mbp have a nvidia gpu? Apple has turned to AMD GPU for several years. Secondly, normally you don't need adding cuda bin dir to PATH to run samples. Run `make` or `sudo make` under some sample dir and all will be fine, for the default Makefile should include the right cuda bin path. At last, if you really need a bashrc, just touch it.... – halfelf Apr 17 '17 at 10:52
  • @halfelf, I do have an NVIDIA GeForce 750 card – Matt Billman Apr 17 '17 at 11:07
  • 2
    There is some information available in [the CUDA macOS install guide](http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#verification). That doesn't explain how to run a text editor, of course. – Robert Crovella Apr 17 '17 at 16:01

2 Answers2

3

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

Max K
  • 71
  • 1
  • 11
1

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).

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • I don't have a .bashrc file, but I DO have .bash_profile and .profile files. Would either of those work? – Matt Billman Apr 18 '17 at 07:12
  • 1
    @MattBillman: Well, it would [sort of work](http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment), but you can just create a `.bashrc` by editing it. Execute `vi .bashrc` in your home directory, or `vi $HOME/.bashrc` anywhere - or use any editor, and save the result as `.bashrc` in your home folder. – einpoklum Apr 18 '17 at 09:05